public static void ReplacePart(Item item, RobotLoadout robot) { for (int i = 0; i < robot.loadout.Length; i++) { if (robot.loadout[i].itemLoc == item.itemLoc) { robot.loadout[i] = item; robot.hitPoints[i] = item.itemHitpoints; // switch players items power with drops power robot.power[i] = item.itemPower; if (robot.loadout[i].itemType == ItemType.melee) { AnimationSwap(robot, i); } else if (robot.loadout[i].itemType == ItemType.range) { AnimationSwap(robot, i); } if (robot.loadout[i].itemSpecial) { Debug.Log("Checking Specials"); robot.GetComponent <PlayerSpecial> ().ActivateSpecialPassive(robot.loadout[i]); } break; } } }
public static void ReplaceDropPart(Drops drop, RobotLoadout player) { Item tempItem = IdentifyReplacePart(drop.thisItem, player); for (int i = 0; i < player.loadout.Length; i++) { if (player.loadout[i].itemLoc == drop.thisItem.itemLoc) { player.loadout[i] = drop.thisItem; // switch players items heath with drops health drop.thisItem = tempItem; int tempHP = player.hitPoints[i]; player.hitPoints[i] = drop.hitPoints; drop.hitPoints = tempHP; // switch players items power with drops power float tempPower = player.power[i]; player.power[i] = drop.power; drop.power = tempPower; if (player.loadout[i].itemType == ItemType.melee || player.loadout[i].itemType == ItemType.range || player.loadout[i].itemLoc == ItemLoc.legs) { AnimationSwap(player, i); } if (player.loadout[i].itemSpecial) { Debug.Log("Checking Specials"); player.GetComponent <PlayerSpecial> ().ActivateSpecialPassive(player.loadout[i]); } break; } } }
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); } }