Esempio n. 1
0
    /// <summary>
    /// When a mouse button down is register on the tile, the base turret is created and a reference to the
    /// instantiated tower is stored as this space's current tower.
    /// <para>Then each desired ability is added to this current tower.</para>
    /// </summary>
    private void OnMouseDown()
    {
        // Check if the mouse was clicked over a UI element
        if (!EventSystem.current.IsPointerOverGameObject())
        {
            if (myTurret != null)
            {
                Debug.Log("Cant Build Here, already have a tower");
                // TODO
                // Activate this tower and display it on the UI
                return;
            }
            else
            {
                myTurret = Instantiate(baseTurret, transform.position, transform.rotation);
                myTurret.transform.parent = transform;
                PolyTower tower = myTurret.GetComponent <PolyTower>();

                foreach (TowerAbility ta in towerToBuild.myAbilities)
                {
                    tower.myAbilities.Add(ta);
                    foreach (Effect e in ta.GetEffects())
                    {
                        if (e is TowerEffect)
                        {
                            TowerEffect temp = (TowerEffect)e;
                            temp.AlterTower(tower);
                        }
                    }
                }
                TowerConstructed.Raise();
            }
        }
    }
Esempio n. 2
0
        //Инициализация башен
        public Tower(int id, int level)
        {
            switch (id)     //Проход по id башен
            {
                case 1:
                    switch (level)      //Проход по уровням башен
                    {
                        case 1:         //Первый уровень
                            Name = "";
                            Reload = 2f;
                            Damage = 200;
                            IsGroundDamage = true;
                            IsAirDamage = true;
                            TowerEffect = new TowerEffect()
                            {
                                    //Эффекты отсытствуют пока что
                            };
                            Radius = 3f;
                            Price = 100;
                            PriceNextLevel = 500;
                            Sell = 50;
                            HasMassAttack = false;
                            IsTower = true;
                            break;

                        case 2:
                                    //Второй уровень по аналогии и далее
                            break;

                        default:
                            break;
                    }
                    break;

                case 2:
                            //Второй id по аналогии и далее
                    break;
                default:
                    break;
            }
        }