Ejemplo n.º 1
0
    protected void addBuildingToScene(Vector3 position)
    {
        //GameObject currentObject = FindObjectOfType<All3DObjects>().getCurrentObject();

        // Ici ajouter currentObject = batiment selectionné

        if (currentObject != null)
        {
            Debug.Log("OK");
            //Instantiate

            _myVillage = FindObjectOfType <VillageManager>();
            Debug.Log(currentObject.name);
            switch (currentObject.name)
            {
            case "BasicHousePrefab":
                if (player.getGold() >= 100 && _myVillage.getWood() >= 60 && _myVillage.getStone() >= 30)
                {
                    _myVillage.setStone(_myVillage.getStone() - 30);
                    _myVillage.setWood(_myVillage.getWood() - 60);
                    player.setGold(player.getGold() - 100);
                    _myVillage.setPeople(_myVillage.getPeople() + 5);
                    Instantiate(currentObject, position, Quaternion.identity);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }

                break;

            case "MediumHousePrefab":
                if (player.getGold() >= 180 && _myVillage.getWood() >= 150 && _myVillage.getStone() >= 100)
                {
                    _myVillage.setStone(_myVillage.getStone() - 100);
                    _myVillage.setWood(_myVillage.getWood() - 150);
                    player.setGold(player.getGold() - 180);
                    _myVillage.setPeople(_myVillage.getPeople() + 10);
                    Instantiate(currentObject, position, Quaternion.identity);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }
                break;

            case "BigHousePrefab":
                if (player.getGold() >= 300 && _myVillage.getWood() >= 350 && _myVillage.getStone() >= 220)
                {
                    _myVillage.setStone(_myVillage.getStone() - 220);
                    _myVillage.setWood(_myVillage.getWood() - 350);
                    _myVillage.setPeople(_myVillage.getPeople() + 25);
                    player.setGold(player.getGold() - 300);
                    Instantiate(currentObject, position, Quaternion.identity);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }
                break;

            case "LumberPrefab":
                if (player.getGold() >= 220 && _myVillage.getWood() >= 250)
                {
                    _myVillage.setWood(_myVillage.getWood() - 250);
                    _myVillage.setLumber(_myVillage.getLumber() + 1);
                    player.setGold(player.getGold() - 220);
                    Instantiate(currentObject, position, Quaternion.identity);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }
                break;

            case "MinerPrefab":
                if (player.getGold() >= 220 && _myVillage.getStone() >= 180)
                {
                    _myVillage.setStone(_myVillage.getStone() - 180);
                    _myVillage.setMiner(_myVillage.getMiner() + 1);
                    player.setGold(player.getGold() - 220);
                    Instantiate(currentObject, position, Quaternion.identity);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }
                break;

            case "WareHousePrefab":
                if (player.getGold() >= 350 && _myVillage.getStone() >= 350 && _myVillage.getWood() >= 400 && _myVillage.getPeople() >= 30)
                {
                    _myVillage.setWood(_myVillage.getWood() - 400);
                    _myVillage.setStone(_myVillage.getStone() - 350);
                    player.setGold(player.getGold() - 350);
                    player.setMaxWood(player.getMaxWood() + 800);
                    player.setMaxStone(player.getMaxStone() + 600);
                    Instantiate(currentObject, position, Quaternion.identity);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else if (_myVillage.getPeople() < 30)
                {
                    OpenMessagePanel("Not enough inhabitants");
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }
                break;

            case "GoldWareHousePrefab":
                if (player.getGold() >= 400 && _myVillage.getStone() >= 450 && _myVillage.getWood() >= 500 && _myVillage.getPeople() >= 50)
                {
                    _myVillage.setWood(_myVillage.getWood() - 500);
                    _myVillage.setStone(_myVillage.getStone() - 450);
                    player.setGold(player.getGold() - 400);
                    player.setMaxGold(player.getMaxGold() + 700);
                    Instantiate(currentObject, position, Quaternion.identity);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else if (_myVillage.getPeople() < 50)
                {
                    OpenMessagePanel("Not enough inhabitants");
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }
                break;

            case "ForgePrefab":
                if (player.getGold() >= 320 && _myVillage.getStone() >= 250 && _myVillage.getWood() >= 300 && _myVillage.getPeople() >= 40)
                {
                    _myVillage.setWood(_myVillage.getWood() - 300);
                    _myVillage.setStone(_myVillage.getStone() - 250);
                    player.setGold(player.getGold() - 320);
                    Instantiate(currentObject, position, Quaternion.identity);
                    player.setDEF(player.getDEF() + 10);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else if (_myVillage.getPeople() < 40)
                {
                    OpenMessagePanel("Not enough inhabitants");
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }
                break;

            case "ArmureriePrefab":
                if (player.getGold() >= 320 && _myVillage.getStone() >= 240 && _myVillage.getWood() >= 320 && _myVillage.getPeople() >= 40)
                {
                    _myVillage.setWood(_myVillage.getWood() - 320);
                    _myVillage.setStone(_myVillage.getStone() - 240);
                    player.setGold(player.getGold() - 320);
                    player.setATK(player.getATK() + 10);
                    Instantiate(currentObject, position, Quaternion.identity);
                    CloseMessagePanel();
                    CloseMessageDetailedPanel();
                }
                else if (_myVillage.getPeople() < 40)
                {
                    OpenMessagePanel("Not enough inhabitants");
                }
                else
                {
                    OpenMessagePanel("Not enough ressources");
                }
                break;
            }
        }
    }