Beispiel #1
0
    private void Update()
    {
        //this is where you could run the ai code.

        List <Unit> units  = grid.GetUnits();
        List <City> cities = grid.GetCities();

        CurrentState = ActionButtonState.EndTurn;

        foreach (Unit u in units)
        {
            if (u.UnitWaitingForOrders())
            {
                CurrentState = ActionButtonState.UnitWaitingForOrders;
                break;
            }
        }

        foreach (City c in cities)
        {
            if (c.GetCurrentBuildingJob() == null)
            {
                CurrentState = ActionButtonState.CityReadyForProduction;
                break;
            }
        }
    }
Beispiel #2
0
    public void EndTurn()
    {
        //to-do: make it only get the current player's units.
        List <Unit> units  = grid.GetUnits();
        List <City> cities = grid.GetCities();

        //if there is a unit waiting for orders, halt the end turn function and select the unit
        foreach (Unit u in units)
        {
            if (u.UnitWaitingForOrders())
            {
                selectionController.SelectedUnit = u;
                CurrentState = ActionButtonState.UnitWaitingForOrders;
                FindObjectOfType <MapCamera>()?.MoveToPosition(u.transform.position);
                return;
            }
        }

        Debug.Log("no units waiting for orders.");

        //units that have a current path should travel
        foreach (Unit u in units)
        {
            u.Travel(u.GetCurrentPath());
        }

        //TO-DO heal units that are resting

        //do city logic
        foreach (City c in cities)
        {
            c.DoTurn();
        }

        //unselect units and go to next player
        selectionController.SelectedUnit = null;

        turnNumber++;

        //anything that's waiting for the turn to end can subscribe to this and will be called here
        //unit movement is restored through the on turn ended event

        onTurnEnded?.Invoke();
    }
        private void LoadActionButtonState()
        {
            try
            {
                ActionButtonState state = XmlLoader <ActionButtonState> .Load(
                    "GameMapDisplayWindowActionButtonState.xml", true);

                if (state != null)
                {
                    mode        = state.Mode;
                    brushSize   = state.BrushSize;
                    markerColor = state.MarkerColor;
                    markerStyle = state.MarkerStyle;
                    eraseMode   = state.EraseMode;
                }
            }
            catch (Exception)
            {
            }
            actionButtonStateLoaded = true;
        }
Beispiel #4
0
 private void SetActionButtonStateAbort()
 {
     _actionButtonState = ActionButtonState.Abort;
     UpdateActionButtonText();
 }
Beispiel #5
0
 private void SetActionButtonStateSearch()
 {
     _actionButtonState = ActionButtonState.Search;
     UpdateActionButtonText();
 }