Exemplo n.º 1
0
 public void PopupTop(String content)
 {
     topPopupText.color = defaultColor;
     topPopupText.SetText(Traducer.Translate(content));
     topPopupText.gameObject.SetActive(true);
     StartCoroutine(DelayCorouting(3, topPopupText));
 }
Exemplo n.º 2
0
    public void OnUpgrade(int number)
    {
        Player player = GameSingleton.Instance.GetPlayer();

        Player.Gamemode playerGamemode = player.gamemode;

        int gold = player.gamemode == Player.Gamemode.LEVEL
            ? player.gold
            : player.arcadeGold;

        if (gold >= _currentCost)
        {
            if (playerGamemode == Player.Gamemode.LEVEL)
            {
                player.gold -= _currentCost;
            }
            else
            {
                player.arcadeGold -= _currentCost;
            }
            StoreUnit upgradedUnit = (number == 1) ? _unit.upgrades[0] : _unit.upgrades[1];
            Popups.instance.Popup(Traducer.Translate("Upgraded ") + Traducer.Translate(_unit.name) + Traducer.Translate(" to ") + Traducer.Translate(
                                      upgradedUnit.name));
            _inventory.RemoveUnit(_unit);
            _inventory.AddItem(upgradedUnit);
            ToggleUpgradePannel();
            GameSingleton.Instance.uiManager.descriptionBox.SetActive(false);
        }
        else
        {
            Popups.instance.Popup(Traducer.Translate("Not enough gold!"), Color.red);
            GameSingleton.Instance.uiManager.descriptionBox.SetActive(false);
            ToggleUpgradePannel();
        }
    }
Exemplo n.º 3
0
 public void Popup(String content, Color color)
 {
     popupText.color = color;
     popupText.SetText(Traducer.Translate(content));
     popupText.gameObject.SetActive(true);
     StartCoroutine(DelayCorouting(3, popupText));
 }
Exemplo n.º 4
0
        public void BuyItem()
        {
            Player player = GameSingleton.Instance.GetPlayer();

            Player.Gamemode playerGamemode = player.gamemode;

            int gold = player.gamemode == Player.Gamemode.LEVEL
                ? player.gold
                : player.arcadeGold;

            if (gold >= item.price)
            {
                if (playerGamemode == Player.Gamemode.LEVEL)
                {
                    player.gold -= item.price;
                }
                else
                {
                    player.arcadeGold -= item.price;
                }
                ItemSlot boughtSlot = inventoryPrefab;
                boughtSlot.item        = item;
                boughtSlot.icon.sprite = icon.sprite;
                boughtSlot.itemName.SetText(itemName.text);
                _inventory.AddItem(boughtSlot.item);
                GameSingleton.Instance.soundManager.Play("Buy");
                _popup.Popup(Traducer.Translate("Bought ") + Traducer.Translate(item.name) + "!");
            }
            else
            {
                _popup.Popup(Traducer.Translate("Not enough gold!"), Color.red);
            }
        }
Exemplo n.º 5
0
        public void UpdateUiEquipment(Equipment equipment)
        {
            var addedItem = Instantiate(prefabSlot, equipmentsParent, false);

            addedItem.item = equipment;
            addedItem.itemName.SetText(Traducer.Translate(equipment.itemName));
            addedItem.icon.sprite = equipment.icon;
        }
Exemplo n.º 6
0
        private void Start()
        {
            Size  = "50";
            Money = "200";
            Dropdown dropdown = UIToolSelect.GetComponent <Dropdown>();

            dropdown.options[0].text = Traducer.Translate("Brush");
            dropdown.options[1].text = Traducer.Translate("Difficulty Brush");
        }
Exemplo n.º 7
0
        public void EnterItem()
        {
            _descriptionBox.SetActive(true);

            Item item = (isUpgrade) ? upgradeManager.GetUnit(isFirstUpgrade) : GetComponent <ItemSlot>().item;;

            _description.SetText(Traducer.Translate(item.description));
            _isTouchingItem = true;
        }
Exemplo n.º 8
0
        public void UpdateUiConsumable(Consumable consumable)
        {
            var addedItem = Instantiate(prefabSlot, itemsParent, false);

            addedItem.item = consumable;
            addedItem.itemName.SetText(Traducer.Translate(consumable.itemName));
            addedItem.icon.sprite = consumable.icon;

            _consumableSlots.Add(addedItem);
        }
Exemplo n.º 9
0
        public void UpdateUiUnit(StoreUnit unit)
        {
            ItemSlot targetSlot = (unit.upgrades.Count > 0) ? unitPrefabSlot : prefabSlot;

            var addedItem = Instantiate(targetSlot, unitsParent, false);

            addedItem.item = unit;
            addedItem.itemName.SetText(Traducer.Translate(unit.itemName));
            addedItem.icon.sprite = unit.icon;

            _unitSlots.Add(addedItem);
        }
Exemplo n.º 10
0
 public void save()
 {
     if (map != null)
     {
         map.Save();
         Popups.instance.Popup(Traducer.Translate("Map saved!"));
     }
     else
     {
         Popups.instance.Popup(Traducer.Translate("Select settings first!"), Color.red);
     }
 }
Exemplo n.º 11
0
        //par défaut a un nom, prix, sprite, tu peux ajouter d'autre type en faisant des variables public comme healAmount ici
        public override void Use()
        {
            if (UnitLibData.selectedUnit != null)
            {
                UnitLibData.selectedUnit.AddEffect(0, 3, 10f);

                base.Use();
            }
            else
            {
                Popups.instance.PopupTop(Traducer.Translate("Select a unit first."), Color.red);
            }
        }
Exemplo n.º 12
0
        private void UpdateUiUnits()
        {
            List <StoreUnit> shopUnits = _shop.shopUnits;

            for (int i = 0; i < shopUnits.Count; i++)
            {
                ItemSlot addedItem = Instantiate(prefabSlot, unitsParent, false);
                addedItem.item = shopUnits[i];
                addedItem.itemName.SetText(Traducer.Translate(shopUnits[i].itemName));
                addedItem.icon.sprite = shopUnits[i].icon;
                addedItem.price.SetText(shopUnits[i].price.ToString());
            }
        }
Exemplo n.º 13
0
        private void UpdateUiItems()
        {
            List <Consumable> shopConsummables = _shop.shopConsummables;

            for (int i = 0; i < shopConsummables.Count; i++)
            {
                ItemSlot addedItem = Instantiate(prefabSlot, itemsParent, false);
                addedItem.item = shopConsummables[i];
                addedItem.itemName.SetText(Traducer.Translate(shopConsummables[i].itemName));
                addedItem.icon.sprite = shopConsummables[i].icon;
                addedItem.price.SetText(shopConsummables[i].price.ToString());
            }
        }
Exemplo n.º 14
0
        public override void Use()
        {
            if (UnitLibData.selectedUnit != null)
            {
                UnitLibData.selectedUnit.AddEffect(1, level, 1000);
                //UnitLibData.selectedUnit.AddEquipment(1,level, this);

                base.Use();
            }
            else
            {
                Popups.instance.Popup(Traducer.Translate("No Unit Selected!"), Color.red);
            }//TODO gérer un message d'erreur
        }
Exemplo n.º 15
0
        public void Fight()
        {
            int playerCount = FindObjectsOfType <PlayerUnit>().Length;

            if (playerCount == 0)
            {
                Popups.instance.Popup(Traducer.Translate("At least one unit must be placed first"), Color.red);
                return;
            }
            systemUnit.SetRunning(true);
            fightButton.SetActive(false);
            //shopPanel.SetActive(false);
            GameSingleton.Instance.StartFight();
        }
Exemplo n.º 16
0
 public void loadMap()
 {
     if (currentSel != null)
     {
         GameSingleton.Instance.filename = currentSel;
         GameSingleton.Instance.soundManager.StopPlayingAllMusics();
         GameSingleton.Instance.soundManager.Play("Level theme");
         //set player gold with settings added during map creation
         UnityEngine.SceneManagement.SceneManager.LoadScene(6);
     }
     else
     {
         Popups.instance.Popup(Traducer.Translate("Please select a level."), Color.red);
     }
 }
Exemplo n.º 17
0
    public void SetUIUnits(StoreUnit storeUnit)
    {
        GameSingleton.Instance.uiManager.inventoryUi.UpdateGold();
        _currentCost = storeUnit.upgradeCost;
        UpdateCost(_currentCost);
        _unit = storeUnit;
        unitName.SetText(Traducer.Translate(storeUnit.name));
        unitImage.sprite = storeUnit.icon;

        unitUpgrade1Name.SetText(Traducer.Translate(storeUnit.upgrades[0].name));
        unitUpgrade1Image.sprite = storeUnit.upgrades[0].icon;

        unitUpgrade2Name.SetText(Traducer.Translate(storeUnit.upgrades[1].name));
        unitUpgrade2Image.sprite = storeUnit.upgrades[1].icon;

        ToggleUpgradePannel();
    }
Exemplo n.º 18
0
 public void UpdateConnecteIndication()
 {
     if (connecteIndication != null)
     {
         string token = GameSingleton.Instance.GetPlayer().token;
         if (string.IsNullOrEmpty(token) || token.Length < 8)
         {
             connecteIndication.text  = Traducer.Translate("Not connected");
             connecteIndication.color = Color.white;
         }
         else
         {
             connecteIndication.text  = Traducer.Translate("Connected");
             connecteIndication.color = Color.green;
         }
     }
 }
Exemplo n.º 19
0
 //par défaut a un nom, prix, sprite, tu peux ajouter d'autre type en faisant des variables public comme healAmount ici
 public override void Use()
 {
     if (UnitLibData.selectedUnit != null)
     {
         for (int i = 0; i < UnitLibData.selectedUnit.entityCount; i++)
         {
             if (UnitLibData.selectedUnit.GetEntity(i) != null && UnitLibData.selectedUnit.GetEntity(i).GetLife() > 0) // REGEN IF LIFE > 0
             {
                 UnitLibData.selectedUnit.GetEntity(i).SetLife(UnitLibData.selectedUnit.GetEntity(i).GetLife() + (UnitLibData.selectedUnit.GetEntity(i).GetMaxLife() / 2));
             }
         }
         base.Use();
     }
     else
     {
         Popups.instance.PopupTop(Traducer.Translate("Select a unit first."), Color.red);
     }
 }
Exemplo n.º 20
0
 private void ProcessConnectionResult(UnityWebRequest www)
 {
     if (www.isNetworkError || www.isHttpError)
     {
     }
     else
     {
         string result = www.downloadHandler.text;
         if (result.Contains("NOK"))
         {
             GameObject password   = connectionPanel.transform.Find("PasswordInput").gameObject;
             InputField passwordIn = password.GetComponent <InputField>();
             passwordIn.text = "";
             Popups.instance.Popup(Traducer.Translate("Wrong identifications!"), Color.red);
         }
         else
         {
             GameSingleton.Instance.GetPlayer().token = result;
             PlayerPrefs.Save();
             connectionPanel.gameObject.SetActive(false);
             background.SetActive(false);
         }
     }
 }
Exemplo n.º 21
0
 // Called when the item is pressed in the inventory
 public virtual void Use()
 {
     Popups.instance.Popup(Traducer.Translate("using ") + Traducer.Translate(itemName));
 }
Exemplo n.º 22
0
        public void LoadScene(string sceneName)
        {
            Player       player       = GameSingleton.Instance.GetPlayer();
            SoundManager soundManager = GameSingleton.Instance.soundManager;

            PoolManager.PoolManager.Instance().ReleaseAll();

            switch (sceneName)
            {
            case "Menu":
                //soundManager.StopPlaying("Level theme");
                soundManager.StopPlayingAllMusics();
                soundManager.Play("Menu");

                if (player.gamemode != Player.Gamemode.LEVEL)
                {
                    player.arcadeModeInventory.Clear();
                    Shop.Instance.ClearShop();
                    player.arcadeGold         = 150;
                    player.currentLevelArcade = 0;
                }
                else
                {
                    player.storyModeInventory = player.inventoryBackup;
                    player.gold = player.goldStartLevel;
                    //player.storyModeInventory.Clear();
                }

                player.gamemode = Player.Gamemode.NONE;
                UnitySceneManager.LoadScene(_storedScenesIds[sceneName]);
                break;

            case "StoryMode":
                if (player.gamemode == Player.Gamemode.LEVEL)          // button restart
                {
                    player.storyModeInventory = player.inventoryBackup;
                    player.gold = player.goldStartLevel;
                }
                Shop.Instance.ClearShop();

                player.gamemode = Player.Gamemode.LEVEL;

                soundManager.StopPlayingAllMusics();

                //soundManager.StopPlaying("Menu");
                soundManager.Play("Level theme");
                UnitySceneManager.LoadScene(_storedScenesIds[sceneName]);
                break;

            case "freeMode":
                string token = player.token;

                if (string.IsNullOrEmpty(token) || token.Length < 8)
                {
                    Popups.instance.Popup(Traducer.Translate("Not connected!"), Color.red);
                }
                else
                {
                    GameSingleton.Instance.tokenManager.CheckToken(token, "scene.load.freeMode");
                    Shop.Instance.ClearShop();

                    player.currentLevelArcade = 0;
                    player.arcadeModeInventory.Clear();
                    player.arcadeGold = 150;

                    player.gamemode = Player.Gamemode.ARCADE;

                    soundManager.StopPlayingAllMusics();
                    soundManager.Play("Level theme");
                    UnitySceneManager.LoadScene(_storedScenesIds[sceneName]);
                }
                break;

            case "loadLvl":
                GameSingleton.Instance.GetPlayer().gamemode = Player.Gamemode.PERSONNALIZED;
                player.arcadeModeInventory.Clear();
                player.arcadeGold = 150;
                UnitySceneManager.LoadScene(_storedScenesIds[sceneName]);
                break;

            case "creator":
                UnitySceneManager.LoadScene(_storedScenesIds[sceneName]);
                break;
            }
        }
Exemplo n.º 23
0
        public void DoClick()
        {
            if (!_uiManager && GameSingleton.Instance && GameSingleton.Instance.uiManager)
            {
                _uiManager = GameSingleton.Instance.uiManager;
            }
            else if (_uiManager)
            {
                if (_uiManager.upgradePanel.activeSelf || _uiManager.pausePanel.activeSelf ||
                    GameSingleton.Instance.endGamePanel.winMessage.IsActive() ||
                    GameSingleton.Instance.endGamePanel.loseMessage.IsActive() || GameSingleton.Instance.endGamePanel.endMessage.IsActive() || GameSingleton.Instance.cameraController.isZooming)
                {
                    _uiActivated = true;
                }
                else
                {
                    _uiActivated = false;
                }

                /* if (_uiManager.inventoryPanel.activeSelf || _uiManager.shopPanel.activeSelf ||
                 *  _uiManager.upgradePanel.activeSelf || _uiManager.pausePanel.activeSelf ||
                 *  GameSingleton.Instance.endGamePanel.winMessage.IsActive() ||
                 *  GameSingleton.Instance.endGamePanel.loseMessage.IsActive()) _uiActivated = true;
                 * else
                 *  _uiActivated = false;*/
            }


            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            Inventory  inventory = GameSingleton.Instance.GetPlayer().gamemode == Player.Gamemode.LEVEL
                ? GameSingleton.Instance.GetPlayer().storyModeInventory
                : GameSingleton.Instance.GetPlayer().arcadeModeInventory;

            // Placement d'une unité de l'inventaire
            if (inventory.selectedStoreUnit != null &&
                Physics.Raycast(ray, out hit, 100f, 1 << 8))
            {
                Vector3 position = new Vector3(Mathf.Floor(hit.point.x) + 0.5f, YPos,
                                               Mathf.Floor(hit.point.z) + 0.5f);

                bool isPlaceable = CheckPlaceable();
                if (isPlaceable && !_uiActivated)
                {
                    StoreUnit unit = inventory.selectedStoreUnit;
                    SpawnUnit(unit.entityType, playerUnitPrefab, position);
                    inventory.RemoveUnit(unit);
                    inventory.selectedStoreUnit = null;
                }
                else
                {
                    Popups.instance.PopupTop(Traducer.Translate("Unit is not placeable here, please try somewhere else"), Color.red);
                }
            }

            // Fight start
            if (!isRunning)
            {
                return;
            }
            if (_uiActivated)
            {
                return;
            }
            // Allied Unit selection
            if (Physics.Raycast(ray, out hit, 100f, 1 << 9))
            {
                if (UnitLibData.selectedUnit != null)
                {
                    DeselectUnit();
                }
                SelectUnit(hit.transform.GetComponentInParent <PlayerUnit>());
            }
            else if (UnitLibData.selectedUnit != null)
            {
                // Click on ground
                if (Physics.Raycast(ray, out hit, 100f, 1 << 8))
                {
                    bool placeable = CheckPlaceable();
                    if (placeable)
                    {
                        UnitLibData.selectedUnit.SetTargetPosition(TerrainGrid.Instance.cursor.transform.position);
                        DeselectUnit();
                    }
                }
            }
        }
Exemplo n.º 24
0
        public void UseItem()
        {
            item.Use();

            _popup.Popup(Traducer.Translate("Used ") + Traducer.Translate(item.name) + "!");
        }