本文整理汇总了C#中Inventory.getPlayer方法的典型用法代码示例。如果您正苦于以下问题:C# Inventory.getPlayer方法的具体用法?C# Inventory.getPlayer怎么用?C# Inventory.getPlayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory.getPlayer方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: beginInvoke
public override void beginInvoke(Inventory invoker)
{
Transform cam = invoker.getPlayer().cam.transform;
GameObject rock = new GameObject("Rock");
rock.transform.localPosition = cam.TransformPoint(releaseLocation);
rock.transform.localScale *= 0.2f;
rock.AddComponent<MeshFilter>().sharedMesh = rockMesh;
rock.AddComponent<MeshRenderer>().sharedMaterial = rockMaterial;
Rigidbody rb = rock.AddComponent<Rigidbody>();
rb.velocity = cam.TransformVector(throwVelocity);
rb.collisionDetectionMode = CollisionDetectionMode.Continuous;
rock.AddComponent<Rock>().clip = collisionSound;
}
示例2: invoke
public override void invoke(Inventory invoker) {
if (reelingIn()) {
breakConnection();
return;
}
attachPoint = getTarget(invoker);
if ((attachPoint -invoker.transform.position).sqrMagnitude < 1) {
return;
}
player = invoker.getPlayer();
player.mover.lockMovement();
playerRigidbody = player.GetComponent<Rigidbody>();
playerTransform = player.transform;
playerRigidbody.useGravity = false;
//Vector3 desiredVel = (attachPoint -player.transform.position).normalized *reelSpeed;
//playerRigidbody.velocity = desiredVel;
targetReached = false;
StartCoroutine(reelIn());
}
示例3: getTargetObjects
protected List<GameObject> getTargetObjects(Inventory invoker) {
List<GameObject> availables = new List<GameObject>();
GameObject[] grapplePoints = GameObject.FindGameObjectsWithTag("Grapple Point");
Transform camTrans = invoker.getPlayer().cam.transform;
foreach (GameObject point in grapplePoints) {
float distanceSqr = (point.transform.position - camTrans.position).sqrMagnitude;
//filter out objects that are too far away
if (distanceSqr > length * length)
continue;
// filter out points that are behind the camera
if (Vector3.Dot(camTrans.forward, point.transform.position -camTrans.position) < 0) continue;
// filter out obstructed points
RaycastHit[] hits = cast(camTrans.position, point.transform.position -camTrans.position, Mathf.Sqrt(distanceSqr) -0.1f);
if (hits.Length > 0) {
continue;
}
availables.Add(point);
}
return availables;
}
示例4: getTargetObject
protected GameObject getTargetObject(Inventory invoker) {
List<GameObject> availables = getTargetObjects(invoker);
print("Available: " +availables.Count);
GameObject selected = null;
float min = new Vector2(Screen.width /4, Screen.height /4).magnitude;
RaycastHit hit = new RaycastHit();
hit.distance = length + 0.5f;
hit.point = invoker.getPlayer().cam.transform.position + invoker.getPlayer().cam.transform.forward * hit.distance;
RaycastHit[] hits = Physics.RaycastAll(invoker.getPlayer().cam.transform.position, invoker.getPlayer().cam.transform.forward, length + 0.5f);
foreach (RaycastHit h in hits) {
if (!h.collider.isTrigger && hit.distance > h.distance)
hit = h;
}
foreach (GameObject point in availables) {
Vector3 center = invoker.getPlayer().cam.WorldToScreenPoint(point.transform.position);
Vector2 screenCenter = new Vector2(Screen.width / 2, Screen.height / 2);
Vector2 pointCenter = new Vector2(center.x, center.y);
float dist = (screenCenter - pointCenter).magnitude;
if (dist < min) {
min = dist;
selected = point;
}
}
//hitSpot.transform.position = hit.point;
return selected;
}
示例5: getTarget
protected Vector3 getTarget(Inventory invoker) {
Transform camTrans = invoker.getPlayer().cam.transform;
RaycastHit[] hits = cast(camTrans.position, camTrans.forward, length);
if (hits.Length < 1 || !canGrapple(hits[0].collider)) {
GameObject target = getTargetObject(invoker);
if (target == null)
return invoker.transform.position;
print("Used grapple point point.");
return target.transform.position;
}
return hits[0].point;
}
示例6: onEquip
public override void onEquip(Inventory equipper)
{
base.onEquip(equipper);
createLight(equipper.getPlayer().cam.gameObject);
turnOn();
}