示例#1
0
        public override void Update()
        {
            Act();
            if (!Attacking)
            {
                Velocity = Velocity.Add2(Acceleration);
                Velocity = Velocity.Limit(MaxSpeed);

                Vector vn = this.Location.ToVector();
                vn.Add(Velocity);

                Location.FromVector(vn);

                PreviousAcceleration = Acceleration;
                Acceleration         = Acceleration.Mult2(0);
            }

            if (Attacking)
            {
                Velocity = new Vector(0, 0);
                float DamageRatio = 0;
                if (CurrentEnemy.ArmorType == Entities.ArmorType.Plate)
                {
                    DamageRatio = this.DamageAgainstPlateRatio;
                }
                else
                {
                    DamageRatio = this.DamageAgainstNonPlateRatio;
                }

                CurrentEnemy.HitPoints -= (int)(this.Damage * DamageRatio);

                if (CurrentEnemy.HitPoints <= 0)
                {
                    CurrentEnemy = null;
                    Attacking    = false;
                }
            }

            var UnitsThatIMightHit = MyArena.AllUnits.Where(x => x.Distance(x) <= (this.Radius + x.Radius) * 2F).ToList();

            UnitsThatIMightHit.Remove(this);

            foreach (var unit in UnitsThatIMightHit)
            {
                if (Distance(this.Location.ToVector(), unit.Location.ToVector()) < this.Radius + unit.Radius)
                {
                    Vector v         = unit.Location.ToVector().Subtract(this.Location.ToVector());
                    var    nDistance = Distance(this.Location.ToVector(), unit.Location.ToVector());
                    var    Overlap   = (this.Radius + unit.Radius) - nDistance;

                    v.Normalize();
                    v.Mult((float)Overlap / 2);

                    this.Location.FromVector(this.Location.ToVector().Subtract(v));
                    unit.Location.FromVector(unit.Location.ToVector().Add2(v));
                }
            }
        }
示例#2
0
        public Vector GetIntendedVelocity(Vector Force)
        {
            if (!Attacking)
            {
                Vector ExagerratedAcceleration = Acceleration.Mult2(1);
                Velocity = Velocity.Add2(ExagerratedAcceleration);
                Velocity = Velocity.Limit(MaxSpeed);

                return(Velocity);
            }
            else
            {
                return(new Vector(0, 0));
            }
        }