Ejemplo n.º 1
0
        private void UpdateDOT(GameTime gameTime)
        {
            float deltaseconds = (float)(gameTime.ElapsedGameTime.TotalSeconds * Session.singleton.Speed);

            dottimer    += deltaseconds;
            deltahealth += dothealth * deltaseconds;
            int damage = (int)deltahealth;

            if (damage > 0)
            {
                Health     -= damage;
                deltahealth = deltahealth - damage;

                if (Health <= 0)
                {
                    Wave.Remove(this);
                    Die();
                    Session.singleton.AddMoney(IsBoss ? (int)(Wave.MoneyPerKill * Wave.BossMoneyScalar) : Wave.MoneyPerKill);
                    if (DieEvent != null)
                    {
                        DieEvent(this, EventArgs.Empty);
                    }
                }
                else
                {
                    hittimer   = 0.2f;
                    hitDisplay = new Text(damage.ToString(), new Vector2(Rectangle.Right + 3, Rectangle.Top), new Vector2(Velocity.X, -Speed));
                }
            }
        }
Ejemplo n.º 2
0
 public void hit(Bullet bullet, Tower Owner)
 {
     AudioManager.singleton.PlaySound(HitCueName);
     Health -= Owner.CurrentStatistics.Damage;
     if (Health <= 0)
     {
         Wave.Remove(this);
         Die();
         Session.singleton.AddMoney(IsBoss ? (int)(Wave.MoneyPerKill * Wave.BossMoneyScalar) : Wave.MoneyPerKill);
         if (DieEvent != null)
         {
             DieEvent(this, EventArgs.Empty);
         }
     }
     else
     {
         hittimer   = 0.4f;
         hitDisplay = new Text(Owner.CurrentStatistics.Damage.ToString(), new Vector2(Rectangle.Right + 3, Rectangle.Top), new Vector2(Velocity.X, -Speed));
     }
 }
Ejemplo n.º 3
0
        public override void Update(GameTime gameTime)
        {
            if (dothealth > 0 && dottime > 0)
            {
                UpdateDOT(gameTime);
                if (dottimer > dottime)
                {
                    deltahealth = 0.0f;
                    dothealth   = 0;
                    dottime     = 0.0f;
                    dottimer    = 0.0f;
                }
            }

            if (hittimer > 0)
            {
                hittimer -= (float)gameTime.ElapsedGameTime.TotalSeconds * Session.singleton.Speed;
                hitDisplay.Update(gameTime);

                if (hittimer <= 0)
                {
                    hitDisplay = null;
                }
            }

            if (Delay > 0)
            {
                Delay -= (float)gameTime.ElapsedGameTime.TotalSeconds * Session.singleton.Speed;
            }
            else
            {
                Pathfinding ShortestPath = Wave.Path.ShortestPath;

                if (PathIndex == ShortestPath.path.Count && DistanceTraveled > DistanceToTravel)
                {
                    Die();
                    Wave.Remove(this);
                }
                else
                {
                    int i = PathIndex + 1;
                    if (DistanceTraveled > DistanceToTravel)
                    {
                        if (i < ShortestPath.path.Count)
                        {
                            NewNodeInPath(ShortestPath.path[i]);
                        }
                        else
                        {
                            NewNodeInPath(Wave.Path.End);
                        }
                    }
                    else
                    {
                        DistanceTraveled += (Speed * (float)gameTime.ElapsedGameTime.TotalSeconds * Session.singleton.Speed);
                    }
                }

                base.Update(gameTime);
            }
        }