Ejemplo n.º 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.EntityFactionLists(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;
            foreach (List <string> factionEntities in entityStorage.factionEntityList)
            {
                foreach (string entity in factionEntities)
                {
                    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.BuildingFactionLists(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))
        {
            char currPlayer = playerManager.currPlayer[0];
            bool checkall   = locate.CheckAllPoints(currPlayer);
            if (checkall == true)
            {
                turn++;
                //ensures if player currently selects some entity, they can`t move it after clicking next turn
                selectedindex = 0;
                //add points back to units
                locate.SetAllIdleStatus(false, currPlayer);
                locate.SetAllMovementPoints();
                locate.SetAllAttackPoints();
                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"))
        {
            char currPlayer = playerManager.currPlayer[0];
            locate.SetAllIdleStatus(true, currPlayer);
        }
    }