Пример #1
0
    void OnGUI()
    {
        //TODO show which player is currently active
        // Make a background box
        //x position, y position, width, length
        GUI.Box(new Rect(10, 120, 140, 150), "Menu");

        //drop down menu after summon for various entities, non-editor with validation for souls
        GameObject currEntityObject = hexGrid.GetEntityObject(currIndex);

        if (currEntityObject == null)
        {
            if (GUI.Button(new Rect(20, 150, 120, 20), "Summon"))
            {
                if (summonclicked == false)
                {
                    summonclicked = true;
                }
                else
                {
                    summonclicked = false;
                }
            }
        }
        if (summonclicked)
        {
            int    i             = 0;
            string playerFaction = playerManager.activePlayersFaction[playerManager.currPlayer];
            foreach (string entity in entityStorage.GetEntityFactionLists(playerFaction))
            {
                int spacing = i * 20;
                if (GUI.Button(new Rect(150, 150 + spacing, 120, 20), "Summon" + entity))
                {
                    bool validsummon = summon.ValidSummon(entity);
                    if (validsummon)
                    {
                        summon.SummonEntity(currIndex, entity, playerManager.currPlayer);
                    }
                    summonclicked = false;
                }
                i++;
            }
        }
        //drop down menu after summon for various entities
        if (currEntityObject == null)
        {
            if (GUI.Button(new Rect(20, 180, 120, 20), "Summon"))
            {
                if (summonclickededitor == false)
                {
                    summonclickededitor = true;
                }
                else
                {
                    summonclickededitor = false;
                }
            }
        }
        if (summonclickededitor)
        {
            int           i           = 0;
            List <string> allEntities = new List <string>();
            allEntities.AddRange(entityStats.humanEntities);
            allEntities.AddRange(entityStats.undeadEntities);
            foreach (string entity in allEntities)
            {
                int spacing = i * 20;
                if (GUI.Button(new Rect(150, 150 + spacing, 120, 20), "Summon" + entity))
                {
                    if (editmode == true)
                    {
                        summon.SummonEntity(currIndex, entity, playerManager.currPlayer);
                        summonclickededitor = false;
                    }
                }
                i++;
            }
        }

        //drop down menu after summon for various buildings
        GameObject currBuildingObject = hexGrid.GetBuildingObject(currIndex);

        if (currBuildingObject == null)
        {
            if (GUI.Button(new Rect(20, 210, 120, 20), "Building"))
            {
                if (buildingclicked == false)
                {
                    buildingclicked = true;
                }
                else
                {
                    buildingclicked = false;
                }
            }
        }
        if (buildingclicked)
        {
            int    i             = 0;
            string playerFaction = playerManager.activePlayersFaction[playerManager.currPlayer];
            foreach (string building in buildingStorage.GetBuildingFactionLists(playerFaction))
            {
                int spacing = i * 20;
                if (GUI.Button(new Rect(150, 150 + spacing, 120, 20), "Building " + building))
                {
                    bool validbuilding = build.ValidBuilding(building, currIndex);
                    if (validbuilding)
                    {
                        build.BuildBuilding(currIndex, building, playerManager.currPlayer);
                    }
                    buildingclicked = false;
                }
                i++;
            }
        }

        //toggles editor mode
        if (GUI.Button(new Rect(20, 240, 120, 20), "Toggle Map Edit"))
        {
            if (editmode == false)
            {
                editmode = true;
            }
            else
            {
                editmode = false;
            }
        }

        //determine if all troops moved and turn can end
        string turnstring = turn.ToString();

        if (GUI.Button(new Rect(30, 330, 60, 60), turnstring))
        {
            bool checkall = locate.CheckAllPoints(playerManager.currPlayer);
            if (checkall == true)
            {
                turn++;
                //ensures if player currently selects some entity, they can`t move it after clicking next turn
                selIndex = 0;
                //add points back to units
                locate.SetAllIdleStatus(false, playerManager.currPlayer);
                locate.SetAllMovementPoints(playerManager.currPlayer);
                locate.SetAllAttackPoints(playerManager.currPlayer);
                buildingManager.TickProduction();
                //next player's turn
                playerManager.NextActivePlayer();
                //vision.AddMissingFog();
                //vision.EntityCurrPlayerVision();
                //ai actions
                //aiBehaviour.Actions(15);
            }
        }

        //sets remaining units idle
        if (GUI.Button(new Rect(30, 300, 60, 20), "Set All Idle"))
        {
            locate.SetAllIdleStatus(true, playerManager.currPlayer);
        }

        if (hexGrid.GetEntityObject(selIndex) != null)
        {
            GUI.Box(new Rect(100, 280, 120, 20), entityStats.GetType(hexGrid.GetEntityObject(selIndex)));
        }

        //choose different attacks
        if (GUI.Button(new Rect(100, 300, 120, 20), "Attack"))
        {
            chosenAction = "Attack"; //TODO add this to const
        }
        if (avaliableActions.Count > 0)
        {
            int i = 0;
            foreach (string action in avaliableActions)
            {
                int spacing = i * 20;
                if (GUI.Button(new Rect(100, 320 + spacing, 120, 20), action))
                {
                    chosenAction = action;
                }
                i++;
            }
        }
        else
        {
            chosenAction = string.Empty;
        }
    }