Пример #1
0
        public void Update(ref Character _Main, int height, GameTime gt, Rectangle _Bound)
        {
            Random r = new Random();
            UpdateRectangle();
            Vector2 vel = Vector2.Zero;
            if (_Status == EnemyStatus.Spawning)
                vel = new Vector2(0, -1);

            if (height > (int)_Position.Y + (int)_Texture.Height-20)
                _Status = EnemyStatus.Alive;

            timer += (float)gt.ElapsedGameTime.TotalSeconds;
            if (_Status == EnemyStatus.Alive)
            {
                if (timer > reset)
                {
                    Shoot(ref _Main, _Bound);
                    timer -= reset;
                    reset = r.Next(2);
                    reset += 0.5f;
                }
            /*                if (_Position.X > _Main._Position.X)
                    vel.X = -1.5f;
                else if (_Position.X < _Main._Position.X)
                    vel.X = 1.5f;
                else
                    vel.X = 0;

                if (_Position.Y > _Main._Position.Y)
                    vel.Y = -1.5f;
                else if (_Position.Y < _Main._Position.Y)
                    vel.Y = 1.5f;
                else
                    vel.Y = 0;
             */
            }
            _Position += vel;
            AnimateFood();
        }
Пример #2
0
        private void Shoot(ref Character _Main, Rectangle _Bound)
        {
            Random r = new Random();
            _Food = new ThrownFood(_FoodList[r.Next(3)].EnemyClone(), _Bound, 6.5f);

            if ((_Rectangle.Top < _Main._Rec.Top && _Main._Rec.Top < _Rectangle.Bottom)
                || (_Rectangle.Top < _Main._Rec.Bottom && _Main._Rec.Bottom < _Rectangle.Bottom))
            {
                if (_Rectangle.Right < _Main._Rec.Left)
                    _Food.SetDirection(Direction.East);
                else
                    _Food.SetDirection(Direction.West);
            }
            else if ((_Rectangle.Left < _Main._Rec.Left && _Main._Rec.Left < _Rectangle.Right)
                || (_Rectangle.Left < _Main._Rec.Right && _Main._Rec.Right < _Rectangle.Right))
            {
                if (_Rectangle.Top < _Main._Rec.Bottom)
                    _Food.SetDirection(Direction.South);
                else
                    _Food.SetDirection(Direction.North);
            }
            else if (_Rectangle.Bottom < _Main._Rec.Top && _Rectangle.Right < _Main._Rec.Left)
                _Food.SetDirection(Direction.SouthEast);
            else if (_Rectangle.Top > _Main._Rec.Bottom && _Rectangle.Right < _Main._Rec.Left)
                _Food.SetDirection(Direction.NorthEast);
            else if (_Rectangle.Bottom < _Main._Rec.Top && _Rectangle.Left > _Main._Rec.Right)
                _Food.SetDirection(Direction.SouthWest);
            else if (_Rectangle.Top > _Main._Rec.Bottom && _Rectangle.Left > _Main._Rec.Right)
                _Food.SetDirection(Direction.NorthWest);

            _Food.SetPosition(_Position);
            _FoodThrown.Add(_Food);
        }
Пример #3
0
        protected override void Initialize()
        {
            base.Initialize();

            #region UI
            _UI = new UI();
            _UI.Initialize(Content, graphics, 96, 90);
            #endregion

            #region Kathy
            _kathy = new Character(Content.Load<Texture2D>("Images/Character/Kathy"), _UI._Bounds, 5, 200);
            #endregion

            #region Holes
            _holeList = new List<Hole>();
            #endregion

            #region Food
            _foodList = new List<Food>();
            #endregion

            #region Audio
            _Audio = new Audio();
            _Audio.Initialize();
            #endregion

            #region Text
            _TextList = new List<Text>();
            #endregion

            #region HealthBar
            _HealthBar = new HealthBar();
            _HealthBar.Initialize(Content.Load<Texture2D>("Images/HealthBar/HealthBar"), new Vector2(graphics.PreferredBackBufferWidth - 55, 0) ,_kathy.GetHealth(), _UI.BoxHeight);
            #endregion

            #region Ice Cream
            _IceCreamCone = new Food();
            #endregion
        }