public bool createBuilding(Vector3 position)
    {
        var           buildingTransform = Instantiate(buildingPrefab) as Transform;
        Tuto_Building building          = buildingTransform.GetComponent <Tuto_Building>();

        if (building != null)
        {
            building.init(this.tuto_minorIsland);
            building.transform.SetParent(this.transform);
            tuto_building = building;

            Vector3 newPosition = Camera.main.ScreenToWorldPoint(position);
            newPosition.z = -5;
            building.transform.position = newPosition;
            //rotation of image according to the place of the island
            char id = tuto_minorIsland.nameTuto_MinorIsland[tuto_minorIsland.nameTuto_MinorIsland.Length - 1];
            if (id == '1' || id == '2')
            {
                building.transform.Rotate(Vector3.forward * 180);
            }
            tuto_minorIsland.harborBuilt = true;
            tuto_minorIsland.displayPopup("Bien ! Une fois le port construit, appuyez sur le port et déplacez-le où vous le souhaitez sur l'île.", 5);
            return(true);
        }
        return(false);
    }
Exemplo n.º 2
0
    public void createBuildingTouch(Tuto_Building building)
    {
        this.nameBuildingTouchCanvas = building.name;

        Canvas touchBuildingCanvasPrefab = Resources.Load <Canvas>("Prefab/Tuto/touchBuildingCanvasTuto");
        Canvas touchBuildingCanvas       = Instantiate(touchBuildingCanvasPrefab);

        touchBuildingCanvas.transform.SetParent(this.transform);
        touchBuildingCanvas.name = "touchBuilding_" + this.nameBuildingTouchCanvas;
        touchBuildingCanvas.transform.position = GameObject.Find(this.nameBuildingTouchCanvas).transform.position;

        foreach (Tuto_TouchBuilding touchBuilding in touchBuildingCanvas.GetComponentsInChildren <Tuto_TouchBuilding>())
        {
            touchBuilding.island   = this;
            touchBuilding.building = building;
        }
        //touchBuildingCanvas.GetComponent<TouchBuilding>().island = this;

        //rotation of image according to the place of the island
        char id = this.nameTuto_MinorIsland[this.nameTuto_MinorIsland.Length - 1];

        if (id == '1' || id == '2')
        {
            touchBuildingCanvas.transform.Rotate(Vector3.forward * 180);
        }
    }
Exemplo n.º 3
0
    void OnMouseDownSimulation()
    {
        island = GameObject.Find(this.transform.parent.parent.parent.name).GetComponent <Tuto_MinorIsland>();
        Debug.Log(island.nameBuildingTouchCanvas);
        building = island.building;

        if (this.name == "Upgrade")
        {
            island.buildingInfoPresent = false;
            island.createTuto_ChallengeUpgrade(building);
        }

        Destroy(GameObject.Find(this.transform.parent.parent.name));
        island.nameBuildingTouchCanvas = string.Empty;
    }
    void OnMouseDownSimulation()
    {
        island = GameObject.Find(this.transform.parent.parent.parent.name).GetComponent<Tuto_MinorIsland>();
        Debug.Log(island.nameBuildingTouchCanvas);
        building = island.building;

        if (this.name == "Upgrade")
        {
            island.buildingInfoPresent = false;
            island.createTuto_ChallengeUpgrade(building);
        }

        Destroy(GameObject.Find(this.transform.parent.parent.name));
        island.nameBuildingTouchCanvas = string.Empty;
    }
Exemplo n.º 5
0
    public void createBuildingTouch(Tuto_Building building)
    {
        this.nameBuildingTouchCanvas = building.name;

        Canvas touchBuildingCanvasPrefab = Resources.Load<Canvas>("Prefab/Tuto/touchBuildingCanvasTuto");
        Canvas touchBuildingCanvas = Instantiate(touchBuildingCanvasPrefab);
        touchBuildingCanvas.transform.SetParent(this.transform);
        touchBuildingCanvas.name = "touchBuilding_" + this.nameBuildingTouchCanvas;
        touchBuildingCanvas.transform.position = GameObject.Find(this.nameBuildingTouchCanvas).transform.position;

        foreach (Tuto_TouchBuilding touchBuilding in touchBuildingCanvas.GetComponentsInChildren<Tuto_TouchBuilding>())
        {
            touchBuilding.island = this;
            touchBuilding.building = building;
        }
        //touchBuildingCanvas.GetComponent<TouchBuilding>().island = this;

        //rotation of image according to the place of the island
        char id = this.nameTuto_MinorIsland[this.nameTuto_MinorIsland.Length - 1];
        if (id == '1' || id == '2')
            touchBuildingCanvas.transform.Rotate(Vector3.forward * 180);
    }
Exemplo n.º 6
0
    void OnMouseDownSimulation()
    {
        Vector3 pos;
        island = GameObject.Find(this.transform.parent.parent.parent.name).GetComponent<Tuto_MinorIsland>();
        island.building = GameObject.Find(island.nameTuto_MinorIsland + "_Harbor").GetComponent<Tuto_Building>();
        building = island.building;

        switch (this.name)
        {
            case "Upgrade":
                if (island.harborMoved)
                {
                    Canvas upgradeTuto_BuildingWindowCanvasPrefab = Resources.Load<Canvas>("Prefab/Tuto/UpgradeBuildingWindowCanvasTuto");
                    Canvas upgradeTuto_BuildingWindowCanvas = Instantiate(upgradeTuto_BuildingWindowCanvasPrefab);
                    upgradeTuto_BuildingWindowCanvas.name = "UpgradeBuildingWindowCanvas_" + building.name + "_" + island.nameTuto_MinorIsland;
                    upgradeTuto_BuildingWindowCanvas.transform.SetParent(this.transform.parent.parent.parent);  //parent : sous_ile
                    pos = GameObject.Find("Virtual_" + island.nameTuto_MinorIsland).transform.position;
                    pos.z = -2;
                    upgradeTuto_BuildingWindowCanvas.GetComponentInChildren<Image>().transform.position = pos;
                    //rotation of image according to the place of the island
                    char id = island.nameTuto_MinorIsland[island.nameTuto_MinorIsland.Length - 1];
                    if (id == '1' || id == '2')
                        upgradeTuto_BuildingWindowCanvas.GetComponentInChildren<Image>().transform.Rotate(Vector3.forward * 180);
                    //modification of the content of the different Text Children of the Canvas
                    foreach (Text textInCanvas in upgradeTuto_BuildingWindowCanvas.GetComponent<Canvas>().GetComponentsInChildren<Text>())
                    {
                        switch (textInCanvas.name)
                        {
                            case "Name":
                                textInCanvas.text = "Amélioration 1";
                                break;
                            case "CostValue1":
                                textInCanvas.text = "0";
                                break;
                            case "CostValue2":
                                textInCanvas.text = "0";
                                break;
                        }
                    }
                    //modification of the background of the different Image Children of the Canvas
                    foreach (Image imageInCanvas in upgradeTuto_BuildingWindowCanvas.GetComponent<Canvas>().GetComponentsInChildren<Image>())
                    {
                        switch (imageInCanvas.name)
                        {
                            case "CostImage1":
                                imageInCanvas.sprite = null;
                                break;
                            case "CostImage2":
                                imageInCanvas.sprite = null;
                                break;
                            //mêmes images
                            case "ProductionImage":
                                imageInCanvas.sprite = Resources.Load<Sprite>("infoBatiments/ResourcesIcons/FoodIcon");
                                break;
                            case "ProductionImage2":
                                imageInCanvas.sprite = Resources.Load<Sprite>("infoBatiments/ResourcesIcons/FoodIcon");
                                break;
                        }
                    }
                    Destroy(GameObject.Find(this.transform.parent.parent.name));
                }
                else
                {
                    island.displayPopup("Commencez par déplacer le port.", 5);
                }
                break;
            case "Remove":
                if (island.exchangeResourceOpened)
                {
                    StartCoroutine(building.tuto_minorIsland.tuto_buildingManager.destroyBuilding());
                    Destroy(GameObject.Find("touchBuilding_" + this.island.nameTuto_MinorIsland + "_Harbor"));
                }
                else
                {
                    if (island.harborMoved)
                        island.displayPopup("Maintenant, améliorez le port.", 5);
                    else
                        island.displayPopup("Commencez par déplacer le port.", 5);
                }

                break;
            case "Move":
                if (!island.harborMoved)
                {
                    island.displayPopup("Appuyez sur l'endroit où placer le bâtiment", 3);
                    island.moveBuilding = true;
                    Destroy(GameObject.Find(this.transform.parent.parent.name));
                }
                else
                {
                    if (island.harborUpgraded)
                        island.displayPopup("Affichez ensuite la fenêtre d'échange de ressources (appui long sur la table).", 5);
                    else
                        island.displayPopup("Maintenant, améliorez le port.", 5);
                }
                break;
        }
    }
Exemplo n.º 7
0
 public void createTuto_ChallengeUpgrade(Tuto_Building tuto_building)
 {
     tuto_building.level += 1;
     tuto_building.buildState = 0;
     StartCoroutine(tuto_building.launchUpgradeAnimation());
 }
Exemplo n.º 8
0
    void OnMouseDownSimulation()
    {
        Vector3 pos;

        island          = GameObject.Find(this.transform.parent.parent.parent.name).GetComponent <Tuto_MinorIsland>();
        island.building = GameObject.Find(island.nameTuto_MinorIsland + "_Harbor").GetComponent <Tuto_Building>();
        building        = island.building;

        switch (this.name)
        {
        case "Upgrade":
            if (island.harborMoved)
            {
                Canvas upgradeTuto_BuildingWindowCanvasPrefab = Resources.Load <Canvas>("Prefab/Tuto/UpgradeBuildingWindowCanvasTuto");
                Canvas upgradeTuto_BuildingWindowCanvas       = Instantiate(upgradeTuto_BuildingWindowCanvasPrefab);
                upgradeTuto_BuildingWindowCanvas.name = "UpgradeBuildingWindowCanvas_" + building.name + "_" + island.nameTuto_MinorIsland;
                upgradeTuto_BuildingWindowCanvas.transform.SetParent(this.transform.parent.parent.parent);      //parent : sous_ile
                pos   = GameObject.Find("Virtual_" + island.nameTuto_MinorIsland).transform.position;
                pos.z = -2;
                upgradeTuto_BuildingWindowCanvas.GetComponentInChildren <Image>().transform.position = pos;
                //rotation of image according to the place of the island
                char id = island.nameTuto_MinorIsland[island.nameTuto_MinorIsland.Length - 1];
                if (id == '1' || id == '2')
                {
                    upgradeTuto_BuildingWindowCanvas.GetComponentInChildren <Image>().transform.Rotate(Vector3.forward * 180);
                }
                //modification of the content of the different Text Children of the Canvas
                foreach (Text textInCanvas in upgradeTuto_BuildingWindowCanvas.GetComponent <Canvas>().GetComponentsInChildren <Text>())
                {
                    switch (textInCanvas.name)
                    {
                    case "Name":
                        textInCanvas.text = "Amélioration 1";
                        break;

                    case "CostValue1":
                        textInCanvas.text = "0";
                        break;

                    case "CostValue2":
                        textInCanvas.text = "0";
                        break;
                    }
                }
                //modification of the background of the different Image Children of the Canvas
                foreach (Image imageInCanvas in upgradeTuto_BuildingWindowCanvas.GetComponent <Canvas>().GetComponentsInChildren <Image>())
                {
                    switch (imageInCanvas.name)
                    {
                    case "CostImage1":
                        imageInCanvas.sprite = null;
                        break;

                    case "CostImage2":
                        imageInCanvas.sprite = null;
                        break;

                    //mêmes images
                    case "ProductionImage":
                        imageInCanvas.sprite = Resources.Load <Sprite>("infoBatiments/ResourcesIcons/FoodIcon");
                        break;

                    case "ProductionImage2":
                        imageInCanvas.sprite = Resources.Load <Sprite>("infoBatiments/ResourcesIcons/FoodIcon");
                        break;
                    }
                }
                Destroy(GameObject.Find(this.transform.parent.parent.name));
            }
            else
            {
                island.displayPopup("Commencez par déplacer le port.", 5);
            }
            break;

        case "Remove":
            if (island.exchangeResourceOpened)
            {
                StartCoroutine(building.tuto_minorIsland.tuto_buildingManager.destroyBuilding());
                Destroy(GameObject.Find("touchBuilding_" + this.island.nameTuto_MinorIsland + "_Harbor"));
            }
            else
            {
                if (island.harborMoved)
                {
                    island.displayPopup("Maintenant, améliorez le port.", 5);
                }
                else
                {
                    island.displayPopup("Commencez par déplacer le port.", 5);
                }
            }

            break;

        case "Move":
            if (!island.harborMoved)
            {
                island.displayPopup("Appuyez sur l'endroit où placer le bâtiment", 3);
                island.moveBuilding = true;
                Destroy(GameObject.Find(this.transform.parent.parent.name));
            }
            else
            {
                if (island.harborUpgraded)
                {
                    island.displayPopup("Affichez ensuite la fenêtre d'échange de ressources (appui long sur la table).", 5);
                }
                else
                {
                    island.displayPopup("Maintenant, améliorez le port.", 5);
                }
            }
            break;
        }
    }
Exemplo n.º 9
0
 public void createTuto_ChallengeUpgrade(Tuto_Building tuto_building)
 {
     tuto_building.level     += 1;
     tuto_building.buildState = 0;
     StartCoroutine(tuto_building.launchUpgradeAnimation());
 }