本文整理汇总了C#中Utils.getDirection方法的典型用法代码示例。如果您正苦于以下问题:C# Utils.getDirection方法的具体用法?C# Utils.getDirection怎么用?C# Utils.getDirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utils
的用法示例。
在下文中一共展示了Utils.getDirection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetHit
private IEnumerator GetHit(float amount, GameObject attacker) {
if (attacker != null) {
RaycastHit hit;
if (playerScript.isBlocking) {
Utils utils = new Utils ();
Utils.DIRECTION dir = utils.getDirection (transform.position, attacker.transform.position, transform.forward, transform.right);
if (dir == Utils.DIRECTION.FRONT) {
playerScript.model.GetComponent<Animation>().wrapMode = WrapMode.Once;
yield return StartCoroutine (Utils.WaitForAnimation
(playerScript.shieldBlookAnimation, .2f, true, playerScript.model)
);
Soldier soldierScript = attacker.GetComponent<Soldier> ();
soldierScript.state = Soldier.STATES.GotBlocked;
} else {
if (attacker != null)
GotHitAnimation (attacker.transform.position);
}
} else {
//health -= amount;
if (attacker != null)
GotHitAnimation (attacker.transform.position);
}
}
}
示例2: CheckCollisions
void CheckCollisions(Collider other) {
if (other.gameObject.tag == "NPC" ) {
//Debug.Log ("!! found " + other.gameObject.name);
//TODO: Check if other is an enemy first, check if this is a soldier first
//TODO: Raycast and see if there's an obstruction, if so try using hearing
//TODO: Check for player
//Soldier soldierScript = transform.parent.GetComponent<Soldier>();
BaseCharacter otherCharScript = other.GetComponent<BaseCharacter>();
//Soldier otherSoldierScript = other.gameObject.GetComponent<Soldier>();
if (otherCharScript.myTownCenter !=
mySoldierScript.myTownCenter) {
//soldierScript.state = Soldier.STATES.Chase;
mySoldierScript.Target = other.gameObject.transform;
//soldierScript.SetTarget(other.gameObject);
}
}
//test git
else if (other.gameObject.tag == "Player" ) {
//check if the player is in front
Utils utils = new Utils();
Utils.DIRECTION dir = utils.getDirection(transform.position, other.transform.position, transform.forward, transform.right);
Debug.Log(dir.ToString());
if (dir == Utils.DIRECTION.FRONT) {
//raycast to see if there is a line of sight
RaycastHit hit;
Vector3 startPos = eyes.position;
Vector3 direction = (new Vector3(other.transform.position.x,other.transform.position.y + 1.5f, other.transform.position.z) - startPos).normalized;
if (Physics.Raycast(
new Ray(startPos ,
direction),
out hit,
enemySight,
layerMask
)) {
Debug.DrawRay(startPos , direction * enemySight, Color.red, 5f);
if (hit.collider.gameObject.tag == "Player") {
makePlayerTarget(other);
}
}
else {
Debug.DrawRay(startPos , direction * enemySight, Color.green, 5f);
}
}
else {
}
}
}
示例3: GotHitAnimation
private void GotHitAnimation(Vector3 targetPosition) {
Utils utils = new Utils();
Utils.DIRECTION dir = utils.getDirection(transform.position, targetPosition, transform.forward, transform.right);
switch (dir) {
case
Utils.DIRECTION.FRONT:
default:
playerScript.model.GetComponent<Animation>().wrapMode = WrapMode.Once;
playerScript.model.GetComponent<Animation>().CrossFade (playerScript.getHitAnimation);
break;
case
Utils.DIRECTION.BEHIND:
playerScript.model.GetComponent<Animation>().wrapMode = WrapMode.Once;
playerScript.model.GetComponent<Animation>().CrossFade (playerScript.getHitAnimationBehind);
break;
case
Utils.DIRECTION.LEFT:
playerScript.model.GetComponent<Animation>().wrapMode = WrapMode.Once;
playerScript.model.GetComponent<Animation>().CrossFade (playerScript.getHitAnimationLeft);
break;
case
Utils.DIRECTION.RIGHT:
playerScript.model.GetComponent<Animation>().wrapMode = WrapMode.Once;
playerScript.model.GetComponent<Animation>().CrossFade (playerScript.getHitAnimationRight);
break;
}
}