void Update() { ExtendedAction extendedAction = CheckSwitch(); switch (extendedAction) { case ExtendedAction.SwitchLeft: case ExtendedAction.SwitchRight: Switch(extendedAction); break; } }
private Int32 SwitchCurrentCharacterIndex(ExtendedAction extendedAction, List <IInventoryOwner> allies) { Int32 currentIndex = allies.FindIndex(cc => cc.Inventory == _hud.LeftInventory); switch (extendedAction) { case ExtendedAction.SwitchLeft: return(allies.LoopedDecrementIndex(currentIndex)); case ExtendedAction.SwitchRight: return(allies.LoopedIncrementIndex(currentIndex)); default: throw new NotSupportedException(extendedAction.ToString()); } }
private void Switch(ExtendedAction extendedAction) { List <IInventoryOwner> allies = GetLeftSideAllies(); if (allies.Count < 2) { return; } Int32 newIndex = SwitchCurrentCharacterIndex(extendedAction, allies); if (newIndex == -1) { return; } IInventoryOwner leftAlly = allies[newIndex]; ChangeLeftBackpack(leftAlly); _hud.TradeBoxText.text = leftAlly.DisplayName; }