Пример #1
0
        public AttackEventArgs(Character target, int xloc, int yloc, int zloc)
        {
            this.combatTarget = target;

            this.x = xloc;
            this.y = yloc;
            this.z = zloc;
        }
Пример #2
0
        public override void ReceiveAttack(Character sender, int potentialdamage, string attackerName)
        {
            base.ReceiveAttack(sender, potentialdamage, attackerName);

            this.attackTimer = new System.Timers.Timer();
            this.attackTimer.Elapsed += new ElapsedEventHandler(attackTimer_Elapsed);
            this.attackTimer.Interval = Math.Ceiling((double)(60000 / this.agility));
            this.attackTimer.Start();
        }
Пример #3
0
        public virtual void ReceiveAttack(Character sender, int potentialdamage, string attackerName)
        {
            bool success = true;
            this.inCombat = true;

            this.combatTarget = sender;

            //dodging an attack
            if (this.rand.Next(1, 101) <= this.agility)
            {
                //raise attacked and dodged event
                this.OnAttackedAndDodge(new AttackedAndDodgeEventArgs(attackerName, this.name, this.x, this.y, this.z));
                success = false;
            }

            //TODO: implement parrying an attack

            if (success)
            {
                Monitor.TryEnter(this.hplock);
                try
                {
                    this.currentHitpoints -= potentialdamage;
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error: {0}", ex.Message);
                    Console.WriteLine("Trace: {0}", ex.StackTrace);
                }
                finally
                {
                    Monitor.Exit(this.hplock);
                }

                this.OnAttackedAndHit(new AttackedAndHitEventArgs(attackerName, this.name, this.x, this.y, this.z));

                if (this.currentHitpoints <= 0)
                {
                    this.Die();
                }
            }
        }