public void Update(float _dt, InputParams _ip) { if (!_ip.Consumed) { UI.Update(_ip); } //If a squad isn't actually moving if (!MoveSquad) { // Debug fast cursor travel if (UI.IsPlayable() && !_ip.Consumed) { if (_ip.onePressed) { ShowedNearLoc = Cities[0]; } if (_ip.twoPressed) { ShowedNearLoc = Cities[1]; } if (_ip.threePressed) { ShowedNearLoc = Cities[2]; } //Show diferent nearest locations if (_ip.Direction.x != 0 || _ip.Direction.y != 0) { if (ShowedNearLoc == null) { Iterator = 0; } else if (_ip.Direction.x > 0) { Iterator++; Iterator = Iterator.Clamp(NearLoc.Count - 1); } else if (_ip.Direction.x < 0) { Iterator--; Iterator = Iterator.Clamp(NearLoc.Count - 1); } else if (_ip.Direction.y > 0) { Iterator++; Iterator = Iterator.Clamp(NearLoc.Count - 1); } else if (_ip.Direction.y < 0) { Iterator--; Iterator = Iterator.Clamp(NearLoc.Count - 1); } ShowedNearLoc = NearLoc[Iterator]; UI.ShowCapturable(ShowedNearLoc.GetComponent <Capturable>()); SuggestSelect(ShowedNearLoc); } // If comfirm pressed, go to the next lock if (_ip.Confirm) { if (ShowedNearLoc != null) { Select(); } else { List <Choice> list = new List <Choice>(); if (SelectObject.GetComponent <Capturable>().HasBuilding) { Choice CreateUnitC = new Choice("Create Unit", CreateUnit); list.Add(CreateUnitC); } if (SelectObject.GetComponent <Capturable>().Units.Count > 0) { Choice SelectSquadC = new Choice("Select Squad", SelectSquad); list.Add(SelectSquadC); } if (SelectObject.GetComponent <Capturable>().Units.Count > 1) { Choice Battle = new Choice("Battle", LaunchBattle); list.Add(Battle); } UI.UpChoices(list); } } _ip.Use(); } } else if (!_ip.Consumed) { if (ShowedNearLoc == null) { Iterator = 0; } else if (_ip.Direction.x > 0) { Iterator++; Iterator = Iterator.Clamp(NearLoc.Count - 1); } else if (_ip.Direction.x < 0) { Iterator--; Iterator = Iterator.Clamp(NearLoc.Count - 1); } else if (_ip.Direction.y > 0) { Iterator++; Iterator = Iterator.Clamp(NearLoc.Count - 1); } else if (_ip.Direction.y < 0) { Iterator--; Iterator = Iterator.Clamp(NearLoc.Count - 1); } ShowedNearLoc = NearLoc[Iterator]; UI.ShowCapturable(ShowedNearLoc.GetComponent <Capturable>()); SuggestSelect(ShowedNearLoc); if (_ip.Confirm) { SelectObject.GetComponent <Capturable>().MoveSquad(selectedSquad, ShowedNearLoc.GetComponent <Capturable>()); MoveSquad = false; } } if (_ip.Cancel) { //Debug.Log("Cancel called"); if (UI.IsPlayable()) { UI.HideChoices(); UI.HideMenu(); } else { //Debug.Log("Menu called"); UI.ShowMenu(); } } }
public void Update(InputParams input) { //*********************************// // CHOICE PANEL MANAGEMENT //*********************************// if (panels[BattleUIPanels.choice].activeInHierarchy && !panels[BattleUIPanels.menu].activeInHierarchy) { if (Choices.GetCountNotNull() == 0) { Debug.Log("Error hav been catch"); panels[BattleUIPanels.choice].SetActive(false); } IteratorChoiceUpdate(); if (input.Direction.y > 0) { iteratorChoices++; iteratorChoices = iteratorChoices.Clamp(Choices.GetCountNotNull() - 1); } else if (input.Direction.y < 0) { iteratorChoices--; iteratorChoices = iteratorChoices.Clamp(Choices.GetCountNotNull() - 1); } if (input.Confirm) { try { Choices[iteratorChoices].Value.Call(); } catch { Debug.Log("iteratorChoices : " + iteratorChoices); Debug.Log("Clamp : " + iteratorChoices.Clamp(Choices.GetCountNotNull() - 1)); } } if (input.Cancel) { HideChoices(); } input.Use(); } //*********************************// // MENU PANEL MANAGEMENT //*********************************// else if (panels[BattleUIPanels.menu].activeInHierarchy) { if (input.Direction.y > 0) { iteratorMenu++; } else if (input.Direction.y < 0) { iteratorMenu--; } IteratorMenuUpdate(); if (input.Confirm) { switch (iteratorMenu) { case 0: Exit(); HideMenu(); break; case 1: Save(); HideMenu(); break; case 2: HideMenu(); Option(); break; case 3: HideMenu(); Flee(); break; case 4: HideMenu(); End(); break; default: break; } } if (input.Cancel) { HideMenu(); } } else { if (input.Cancel) { ShowMenu(); } } if (panels[BattleUIPanels.choice].activeInHierarchy || panels[BattleUIPanels.menu].activeInHierarchy) { Playable = false; } else { Playable = true; } }
public void Update(InputParams _ip) { Unit unit = UnitsManager.Instance.GetUnitAtPos(selectorPosition); if (unit != null) { UI.ShowSelect(unit); } else { UI.HideSelect(); } if (!_ip.Consumed) { UI.Update(_ip); } if (UI.Playable && !_ip.Consumed) { if (_ip.Direction.x < 0) { if (selectorPosition.x > 0) { selectorPosition.x--; } } else if (_ip.Direction.x > 0) { if (selectorPosition.x < battlefield.GetComponent <BattleField>().GetSize().x - 1) { selectorPosition.x++; } } if (_ip.Direction.y < 0) { if (selectorPosition.y < battlefield.GetComponent <BattleField>().GetSize().y - 1) { selectorPosition.y++; } } else if (_ip.Direction.y > 0) { if (selectorPosition.y > 0) { selectorPosition.y--; } } SelectorPosUpdate(); if (_ip.Confirm && unit != null && !attackMod) { selectedOne = unit; Choice move = new Choice("Move", MoveHandler); Choice attack = new Choice("Attack", AttackHandler); List <Choice> choices = new List <Choice>(); choices.Add(move); choices.Add(attack); UI.UpChoices(choices); } else if (_ip.Confirm && selectedOne != null && !attackMod) { selectedOne.Move(battlefield.GetComponent <BattleField>().GetMapPos(selector.transform.position)); selectedOne = null; } else if (_ip.Confirm && attackMod && unit != null) { attackMod = false; selectedOne.Attack(unit); selectedOne = null; } _ip.Use(); } }