void Start() { attack = GetComponentInChildren <RobotAttack> (); animCont = GetComponentInParent <RobotAnimationController> (); anim = GetComponent <Animator> (); roLo = GetComponentInParent <RobotLoadout> (); isPlayer = GetComponentInParent <PlayerController> (); aoc = new AnimatorOverrideController(anim.runtimeAnimatorController); anim.runtimeAnimatorController = aoc; }
public static void AnimationSwap(RobotLoadout robot, int i) { RobotAnimationController mainAnim = robot.GetComponent <RobotAnimationController> (); RobotArmsAnim[] anim = robot.GetComponentsInChildren <RobotArmsAnim> (); if (robot.loadout[i].itemLoc == ItemLoc.leftArm) { anim[0].SwapWeapons(robot.loadout[i].itemAnim); } if (robot.loadout[i].itemLoc == ItemLoc.rightArm) { anim[1].SwapWeapons(robot.loadout[i].itemAnim); } if (robot.loadout[i].itemLoc == ItemLoc.legs) { mainAnim.SwapLegs(robot.loadout[i].itemAnim); } }
public void TakeDamage(int rawDamage, bool stopAction) { int damage = rawDamage; if (shield.specialID >= 0) { int specialLoc = (int)Database.instance.items[shield.specialItemID].itemLoc; if (power[specialLoc] > 0) { damage -= shield.specialDefence; damage = (damage < 0) ? 0 : damage; power[specialLoc] -= shield.specialPowerUse; print("reduced damage by " + shield.specialDefence); } } stopped = stopAction; if (robotType == RobotType.player) { List <int> liveParts = new List <int> (); //StartCoroutine(ChangeColor(transform.Find("Body").GetComponent<SpriteRenderer>())); for (int i = 0; i < hitPoints.Length; i++) { if (hitPoints[i] > 0) { liveParts.Add(i); // twice as likely to hit everything but the head if (loadout[i].itemLoc != ItemLoc.head) { liveParts.Add(i); } } } int rand = Random.Range(0, liveParts.Count); if (!player.activeBlock && !player.activeDodge) { hitPoints[liveParts[rand]] -= damage; } else { //assigns a new damage value for damageText, CHANGE THIS ONCE WE IMPLEMENT ARMOR / SHIELD ARM damage = (damage / 3); hitPoints[liveParts[rand]] -= damage; print("damage blocked"); } if (hitPoints[liveParts[rand]] < 0) { hitPoints[liveParts[rand]] = 0; } } else if (robotType == RobotType.boss) { hitPoints[(int)ItemLoc.body] -= damage; } else { hitPoints[(int)ItemLoc.body] -= damage; } if ((hitPoints[0] <= 0 && loadout[0].itemID != -1) || hitPoints[1] <= 0) { StartDeath(); } if (stopAction || stopped) { RobotArmsAnim[] anims = GetComponentsInChildren <RobotArmsAnim> (); foreach (RobotArmsAnim a in anims) { a.DoneAttacking(); a.StartHitStall(); } RobotAnimationController roAn = GetComponent <RobotAnimationController> (); if (robotType != RobotType.turret && robotType != RobotType.boss) { roAn.StartHitStall(); } } // Creates damage text GameObject damageText = Instantiate(Resources.Load("DamageText"), transform.position, Quaternion.identity) as GameObject; damageText.GetComponent <DamageText> ().DamageSetup(damage, damageColor, transform.position); }