Example #1
0
    public override void Damage(float damage, string attackerType)
    {
        if (isKilling)
        {
            return;
        }

        float lastDefence = defence;

        if (TowersSettings.Buffs(attackerType).Contains(Tower.Buff.MagicSkills.ToString()) &&
            Settings.IsLearned("Chaotic"))
        {
            defence = 0;
        }

        if (TowersSettings.Buffs(attackerType).Contains(Tower.Buff.MagicSkills.ToString()) &&
            Settings.IsLearned("Fatal"))
        {
            damage = 100000017;
        }

        health -= damage;

        if (TowersSettings.Buffs(attackerType).Contains(Tower.Buff.LazerSkills.ToString()) &&
            Settings.IsLearned("LazerEffect"))
        {
            effects [Effect.Visible] = 1f;
        }

        if (TowersSettings.Buffs(attackerType).Contains(Tower.Buff.LazerSkills.ToString()) &&
            Settings.IsLearned("UnitSlow"))
        {
            effects [Effect.Slow] = 1f;
        }

        defence = lastDefence;

        if (health <= 0)
        {
            if (TowersSettings.Buffs(attackerType).Contains(Tower.Buff.MagicSkills.ToString()) &&
                Settings.IsLearned("UnitGold"))
            {
                GameController.IncreaseGold(color == TeamColor.Red?TeamColor.Blue:TeamColor.Red, goldReward / 2);
            }

            if (TowersSettings.Buffs(attackerType).Contains(Tower.Buff.MagicSkills.ToString()) &&
                Settings.IsLearned("UnitLife"))
            {
                GameController.killedUnitsToHeal++;
            }
        }
    }
Example #2
0
    public Tower(string _type, Colorable.TeamColor _color)
    {
        reloadTime = 0.6f;
        type       = _type;
        color      = _color;

        gameObject = GamePullController.CreateImage();
        animation  = new ObjectAnimation(gameObject);

        gameObject.name += "Tower";
        gameObject.GetComponent <BoxCollider> ().enabled = true;

        texture = Resources.Load("Textures/Towers/" + type + "Tower") as Texture;

        attackAnimaton     = type + "TowerAttack";
        attackAnimatonTime = 0.2f;

        try {
            damage      = BalanceSettings.damage [type];
            damageDelta = BalanceSettings.deltaDamage [type];
            attackRange = BalanceSettings.attackRange [type];
            attackSpeed = BalanceSettings.attackSpeed [type];
        } catch (Exception) {
            Debug.LogError("Wrong tower type: " + type);
        }

        layer = 6;
        size  = new Vector2(texture.width / 50f, texture.height / 50f) / 2f * Settings.FhdToHD;

        GameController.towers.Add(this);
        GameController.towersDictionary.Add(gameObject, this);

        buffs = new Dictionary <Buff, float> (GameController.buffs[color]);

        foreach (var buff in TowersSettings.Buffs(type))
        {
            buffs.Add((Buff)Enum.Parse(typeof(Buff), buff), 1);
        }
    }