本文整理汇总了C#中PlayerController.getHalfHeight方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerController.getHalfHeight方法的具体用法?C# PlayerController.getHalfHeight怎么用?C# PlayerController.getHalfHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerController
的用法示例。
在下文中一共展示了PlayerController.getHalfHeight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: handlePlayerHit
//returns false if game is over
private bool handlePlayerHit(PlayerController attacker, PlayerController defender, bool player1Attacker) {
// If the attacker is engaged in an attack that needs to be handled:
if (attacker.attackHandle ()) {
// See if the attack box is in the body box.
bool blocked = false;
float xdistance = Mathf.Abs (defender.getXPos () - attacker.getHitXPos ());
xdistance -= (attacker.getHitHalfWidth () + defender.getHalfWidth ());
float ydistance = attacker.getHitYPos () - attacker.getHitHalfHeight ();
ydistance -= (defender.getYPos () + defender.getHalfHeight ());
if (xdistance <= 0.0f && ydistance <= 0.0f) {
// This was a hit. Handle it.
if ((attacker.isHighAttack () && defender.isHighBlocking ()) || (!attacker.isHighAttack () && defender.isLowBlocking ())) {
blocked = true;
Debug.Log ("Blocked!");
attacker.tellHit ();
defender.receiveAttack (attacker.getAttackDamage (), true);
} else {
Debug.Log ("Hit!!");
Debug.Log ("Health: " + defender.getHealth ().ToString ());
attacker.tellHit ();
defender.receiveAttack (attacker.getAttackDamage (), false);
}
healthbarcontroller.setPercent (player1Attacker, defender.getHealthPercent ());
if (defender.getHealth () <= 0.0f) {
GameObject defenderFighter = defender.fighter;
Animator defenderAnimator;
defenderAnimator = defenderFighter.GetComponent<Animator> ();
defenderAnimator.SetBool ("lost_game", true);
GameObject attackerFighter = attacker.fighter;
Animator attackerAnimator;
attackerAnimator = attackerFighter.GetComponent<Animator> ();
attackerAnimator.SetBool ("won_game", true);
winText.text = "Victory for " + (defender.player1 ? "player2!" : "player1!") + "\n PRESS ESC TO RETURN TO MENU";
wait_for_start = true;
return false;
} else if (!blocked) {
// set animation for punch
GameObject defenderFighter = defender.fighter;
Animator defenderAnimator;
defenderAnimator = defenderFighter.GetComponent<Animator> ();
Debug.Log (attacker.lastAttackThrown ());
if (attacker.lastAttackThrown () == ActionType.attack1) {
defenderAnimator.SetBool ("facePunched", true);
}
if (attacker.lastAttackThrown () == ActionType.attack2) {
defenderAnimator.SetBool ("faceKicked", true);
}
if (attacker.lastAttackThrown () == ActionType.attack3) {
Debug.Log ("shin kicked");
defenderAnimator.SetBool ("shinKicked", true);
}
if (attacker.lastAttackThrown () == ActionType.attack4) {
defenderAnimator.SetBool ("isTripped", true);
}
}
}
}
return true;
}