Exemplo n.º 1
0
    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();
            }
        }
    }