Beispiel #1
0
        public void Update(float dt)
        {
            if (target != null)
            {
                targetPosition = target.GetPosition();
            }
            Vector3 diff   = targetPosition - position;
            float   length = diff.Length();

            diff     /= length;
            position += diff * dt * Speed;

            if (target != null && target.IsDead())
            {
                map.Attacks.Remove(this);
                return;
            }

            if (target != null && length < 1)
            {
                map.Attacks.Remove(this);
                switch (type)
                {
                case DamageType.Physical: target.TakePhysDmg(damage, pen); break;

                case DamageType.Magical: target.TakeMagDmg(damage, pen); break;
                }
                if (target.IsDead())
                {
                    if (attacker != null)
                    {
                        attacker.ReceiveGold(target.GoldValue);
                        attacker.ReceiveXP(target.ExpValue);
                    }
                }
            }
        }