Пример #1
0
        protected virtual Shot CreateShotInstance()
        {
            var shot = new Shot(CurrGame, this, Target, CreepList, MiddlePosition, ShotTextureName, ShotSpeed, Damage);

            shot.Initialize();
            return(shot);
        }
Пример #2
0
        public override void Update(GameTime gameTime)
        {
            if (Target == null || Target.CreepState != CreepState.Running || (Position - Target.Position).Length() > Range)
            {
                SearchTarget();
            }
            else
            {
                if (ShotTimer.ElapsedMilliseconds >= ShotInterval)
                {
                    Shot shot = CreateShotInstance();
                    if (shot != null)
                    {
                        shot.Initialize();
                        ShotList.Add(shot);
                        ShotTimer.Reset();
                        ShotTimer.Start();
                    }
                }
            }

            foreach (Shot shot in ShotList)
            {
                shot.Update(gameTime);
            }

            foreach (Shot shot in ShotDeleteList)
            {
                ShotList.Remove(shot);
            }
            ShotDeleteList.Clear();

            CustomUpdate(gameTime);

            base.Update(gameTime);
        }