Exemple #1
0
        void DoCheats()
        {
            if (Input.GetKeyDown(KeyCode.F))
            {
                // selected unit gets 1000 damage (dies xD)
                GameRound.instance.currentPlayer.selectedUnit.TakeDamage(GameRound.instance.currentPlayer.selectedUnit, 1000);
            }

            if (Input.GetKeyDown(KeyCode.X))
            {
                if (GameRound.instance.currentPlayer.selectedUnit != null && !GameRound.instance.currentPlayer.selectedUnit.buffs.IsEmpty())
                {
                    GameRound.instance.currentPlayer.selectedUnit.buffs[0].RemoveFromTargetInstantly();
                }
            }
            if (Input.GetKeyDown(KeyCode.Z))
            {
                StatisticChangeBuff defenceDebuff = Instantiate(Resources.Load("Buffs/MechanicsBuffs/Combat Wound") as GameObject).GetComponent <StatisticChangeBuff>();
                defenceDebuff.ApplyOnTarget(GameRound.instance.currentPlayer.selectedUnit);
            }
            if (Input.GetKeyDown(KeyCode.P))
            {
                Debug.Log(Global.instance.currentEntity);
            }
        }
Exemple #2
0
        //in the future most likely more functions might want to do things OnAttack - abilities and so on
        //public event Action<Unit, Unit, int> AttackEvent;


        //if damage is 0, it's a miss, if it's somehow TOTALLY blocked it could be negative maybe or just not send this.
        public void HitTarget(IDamageable target, Damage damage)
        {
            foreach (AbstractAttackModifier modifier in modifiers)
            {
                modifier.ModifyDamage(damage);
            }
            foreach (AbstractAttackModifier modifier in modifiers)
            {
                modifier.ModifyAttack(target, damage);
            }
            PlayerInput.instance.isInputBlocked = false;
            if (damage == 0)
            {
                StatisticChangeBuff defenceDebuff = Instantiate(Resources.Load("Buffs/MechanicsBuffs/Combat Wound") as GameObject).GetComponent <StatisticChangeBuff>();
                defenceDebuff.ApplyOnTarget(target);
                LogConsole.instance.SpawnLog(this.info.unitName + " attacks " + target.GetMyName() + ", but misses completely!");
                LogConsole.instance.SpawnLog(target.GetMyName() + " loses 1 point of Defence temporarily.");
                PopupTextController.AddPopupText("-1 Defence", PopupTypes.Stats);
            }
            else if (damage > 0)
            {
                LogConsole.instance.SpawnLog(this.info.unitName + " deals " + damage + " damage to " + target.GetMyName() + "!");
                PopupTextController.AddPopupText("-" + damage, PopupTypes.Damage);
                target.TakeDamage(this, damage);
                foreach (AbstractBuff buff in target.buffs.FindAllBuffsOfType("Combat Wound"))
                {
                    buff.RemoveFromTargetInstantly();
                }
            }
            if (target is Unit)
            {
                var targetUnit = target as Unit;
                if (targetUnit.CanRetaliate(this) && owner.type != PlayerType.Network)
                {
                    Networking.instance.SendCommandToGiveChoiceOfRetaliation(targetUnit, this);
                }
            }
        }