Ejemplo n.º 1
0
    public void AddToQueue(int enemy)
    {
        if (GameyManager.gameState != GameyManager.GameState.Play)
        {
            if (enemies[enemy].GetComponent <EnemyAI>().enemy.UnitCost <= GameyManager.levelResources)
            {
                oldQueueUnits.Add(enemy);
                enemiesToSpawn.Add(enemies[enemy]);
                Transform unit = Instantiate(queueItem);
                unit.SetParent(wholeQueue);
                coords.y -= queueSize;
                unit.transform.localPosition = coords;
                Image imageComponent = unit.GetComponent <Image>();
                imageComponent.sprite        = enemies[enemy].GetComponent <SpriteRenderer>().sprite;
                GameyManager.levelResources -= enemies[enemy].GetComponent <EnemyAI>().enemy.UnitCost;

                queueUnits.Add(unit);

                bar.UpdateImage();
            }

            for (int i = 0; i < enemies.Count; i++)
            {
                if (enemies[i].GetComponent <EnemyAI>().enemy.UnitCost > GameyManager.levelResources)
                {
                    unitButtons[i].interactable = false;
                }
            }
        }
    }
Ejemplo n.º 2
0
    void Update()
    {
        if (GameyManager.levelMana < 100 && spellsEnabled == true)
        {
            foreach (Button button in spellButtons)
            {
                button.interactable = false;
            }
            spellsEnabled = false;
        }

        if (currentSpell != 0)
        {
            if (Input.GetMouseButtonDown(0))
            {
                spellArea.activateCircle();
                currentSpell             = 0;
                GameyManager.spellsCast += 1;
            }
            if (Input.GetMouseButtonDown(1))
            {
                currentSpell            = 0;
                GameyManager.levelMana += 100;
                Destroy(spellArea.gameObject);
                foreach (Button button in spellButtons)
                {
                    if (button.name != "disabled")
                    {
                        button.interactable = true;
                    }
                }
                spellsEnabled = true;
            }

            bar.UpdateImage();
        }

        if (GameyManager.gameState == GameyManager.GameState.Play)
        {
            if (Input.GetKeyDown(KeyCode.Alpha1) && spellButtons[0].interactable == true)
            {
                useSpell(1);
                GameyManager.spellsCast += 1;
            }
            else if (Input.GetKeyDown(KeyCode.Alpha2) && spellButtons[1].interactable == true)
            {
                useSpell(2);
                GameyManager.spellsCast += 1;
            }
            else if (Input.GetKeyDown(KeyCode.Alpha3) && spellButtons[2].interactable == true)
            {
                useSpell(3);
                GameyManager.spellsCast += 1;
            }

            bar.UpdateImage();
        }
    }