Пример #1
0
    //detects click and selects tile and biome
    void OnMouseUp()
    {
        if (bb.selected != this)
        {
            if (BuildingSpaces.active == false)
            {
                gameManager.GetComponent <MultiplayerBiomeBuilding>().SelectBiome(this);
            }
            else
            {
                gameManager.GetComponent <MultiplayerBiomeBuilding>().DeselectBiome();
            }
        }

        else if (bb.selected.spr.sprite == null)
        {
            if ((player.Equals("host")) && FindObjectOfType <MultiplayerTurnManager>().GetTurn() % 2 == 0)
            {
                //building menu
                bm.ActivityOnBuildingsMenu(true);
            }
            else if (player.Equals("client") && FindObjectOfType <MultiplayerTurnManager>().GetTurn() % 2 != 0)
            {
                //building menu
                bm.ActivityOnBuildingsMenu(true);
            }
            else
            {
                Debug.Log("Not your turn");
            }
        }
    }
Пример #2
0
    //selects data about building to buy and sendsthem to player commands
    public void Buy()
    {
        if (tm.currentTurn == "Blue")
        {
            if (rm.blueResources[1] >= building.prices[0] && rm.blueResources[2] >= building.prices[1] && rm.blueResources[3] >= building.prices[2] && rm.blueResources[4] >= building.prices[3] && Array.Exists <BiomeType>(building.possibleBiomes, element => element == bb.selected.type))
            {
                rm.blueResources[1] -= building.prices[0];
                rm.blueResources[2] -= building.prices[1];
                rm.blueResources[3] -= building.prices[2];
                rm.blueResources[4] -= building.prices[3];
                change1              = building.prices[0];
                change2              = building.prices[1];
                change3              = building.prices[2];
                change4              = building.prices[3];

                if (building.gain[0] != 0)
                {
                    rm.blueResources[0] += building.gain[0];
                    change5              = building.gain[0];
                }
                else if (building.gain[1] != 0)
                {
                    rm.blueSandMultiplier += building.gain[1];
                    change6 = building.gain[1];
                }
                else if (building.gain[2] != 0)
                {
                    rm.blueWoodMultiplier += building.gain[2];
                    change7 = building.gain[2];
                }
                else if (building.gain[3] != 0)
                {
                    rm.blueStoneMultiplier += building.gain[3];
                    change8 = building.gain[3];
                }
                else if (building.gain[4] != 0)
                {
                    rm.blueIceMultiplier += building.gain[4];
                    change9 = building.gain[4];
                }

                if ((player.Equals("host")) && FindObjectOfType <MultiplayerTurnManager>().GetTurn() % 2 == 0)
                {
                    FindObjectOfType <AudioManager>().Play("Build");
                    bb.selected.gameObject.GetComponentInParent <SyncTile>().SetTile(building.ToString());
                    FindObjectOfType <PlayerCommands>().SetMultipliers(change1, change2, change3, change4, change5, change6, change7, change8, change9, tm.currentTurn);
                    FindObjectOfType <PlayerCommands>().ChangeTurn();
                }
                else if (player.Equals("client") && FindObjectOfType <MultiplayerTurnManager>().GetTurn() % 2 != 0)
                {
                    FindObjectOfType <AudioManager>().Play("Build");
                    bb.selected.gameObject.GetComponentInParent <SyncTile>().SetTile(building.ToString());
                    FindObjectOfType <PlayerCommands>().SetMultipliers(change1, change2, change3, change4, change5, change6, change7, change8, change9, tm.currentTurn);
                    FindObjectOfType <PlayerCommands>().ChangeTurn();
                }
                bm.ActivityOnBuildingsMenu(false);
                bb.DeselectBiome();
            }
            else
            {
                Debug.Log("Not enough resources, Blue.");
                return;
            }
        }
        else if (tm.currentTurn == "Red")
        {
            if (rm.redResources[1] >= building.prices[0] && rm.redResources[2] >= building.prices[1] && rm.redResources[3] >= building.prices[2] && rm.redResources[4] >= building.prices[3] && Array.Exists <BiomeType>(building.possibleBiomes, element => element == bb.selected.type))
            {
                rm.redResources[1] -= building.prices[0];
                rm.redResources[2] -= building.prices[1];
                rm.redResources[3] -= building.prices[2];
                rm.redResources[4] -= building.prices[3];
                change1             = building.prices[0];
                change2             = building.prices[1];
                change3             = building.prices[2];
                change4             = building.prices[3];
                if (building.gain[0] != 0)
                {
                    rm.redResources[0] += building.gain[0];
                    change5             = building.gain[0];
                }
                else if (building.gain[1] != 0)
                {
                    rm.redSandMultiplier += building.gain[1];
                    change6 = building.gain[1];
                }
                else if (building.gain[2] != 0)
                {
                    rm.redWoodMultiplier += building.gain[2];
                    change7 = building.gain[2];
                }
                else if (building.gain[3] != 0)
                {
                    rm.redStoneMultiplier += building.gain[3];
                    change8 = building.gain[3];
                }
                else if (building.gain[4] != 0)
                {
                    rm.redIceMultiplier += building.gain[4];
                    change9              = building.gain[4];
                }


                if ((player.Equals("host")) && FindObjectOfType <MultiplayerTurnManager>().GetTurn() % 2 == 0)
                {
                    FindObjectOfType <AudioManager>().Play("Build");
                    bb.selected.gameObject.GetComponentInParent <SyncTile>().SetTile(building.ToString());
                    FindObjectOfType <PlayerCommands>().SetMultipliers(change1, change2, change3, change4, change5, change6, change7, change8, change9, tm.currentTurn);
                    FindObjectOfType <PlayerCommands>().ChangeTurn();
                }
                else if (player.Equals("client") && FindObjectOfType <MultiplayerTurnManager>().GetTurn() % 2 != 0)
                {
                    FindObjectOfType <AudioManager>().Play("Build");
                    bb.selected.gameObject.GetComponentInParent <SyncTile>().SetTile(building.ToString());
                    FindObjectOfType <PlayerCommands>().SetMultipliers(change1, change2, change3, change4, change5, change6, change7, change8, change9, tm.currentTurn);
                    FindObjectOfType <PlayerCommands>().ChangeTurn();
                }
                bm.ActivityOnBuildingsMenu(false);
                bb.DeselectBiome();
            }
            else
            {
                Debug.Log("Not enough resources, Red.");
                return;
            }
        }
    }