Exemple #1
0
        // PROPERTIES
        // none yet

        // CONSTRUCTOR
        public EntityManager(Game1 game, InsanityBar insane)
        {
            hitBoxState        = HitBoxState.No;
            objects            = new List <GameObject>();
            objectsInDrawOrder = new List <GameObject>();
            this.game          = game;
            this.insane        = insane;
            p = game.Player;

            for (int i = 0; i < game.TreeTiles.Count; i++)
            {
                objects.Add(game.TreeTiles[i]);
                objectsInDrawOrder.Add(game.TreeTiles[i]);
            }

            for (int i = 0; i < game.EnemyTiles.Count; i++)
            {
                objects.Add(game.EnemyTiles[i]);
                objectsInDrawOrder.Add(game.EnemyTiles[i]);
            }

            for (int i = 0; i < game.BoundaryTiles.Count; i++)
            {
                objects.Add(game.BoundaryTiles[i]);
                objectsInDrawOrder.Add(game.BoundaryTiles[i]);
            }

            //objects.Add(game.Rug);
            //objectsInDrawOrder.Add(game.Rug);

            objects.Add(p);
            objectsInDrawOrder.Add(p);
            rng = new Random();
        }
Exemple #2
0
 private void SetStartPosition()
 {
     state     = HitBoxState.Airborne;
     Speed     = Vector2.Zero;
     Direction = Direction.None;
     Position  = TileMatrix.Instance.StartPosition;
     IdleEffects();
 }
Exemple #3
0
 public void BreakOut()
 {
     if (State != HitBoxState.GameCompleteAnimation) // sanity.
     {
         State = HitBoxState.GameCompleteAnimation;
         Speed = Vector2.Zero;
         GameCompleteEffects();
     }
 }
Exemple #4
0
        // METHODS
        /// <summary>
        /// Method that does all the math for the objects and their stuff
        /// </summary>
        public void Update(GameTime gameTime)
        {
            // TOGGLING HITBOXES FOR ERIN MODE
            kbState = Keyboard.GetState();


            if (kbState.IsKeyDown(Keys.H) && kbState != lastKbState)
            {
                if (hitBoxState == HitBoxState.Yes)
                {
                    hitBoxState = HitBoxState.No;
                }
                else
                {
                    hitBoxState = HitBoxState.Yes;
                    game.Insanity.InsanityNum = 0;
                }
            }

            lastKbState = kbState;
            // loop to update the entities on the map
            for (int i = 0; i < objects.Count; i++)
            {
                if (objects[i] is Enemy)
                {
                    Enemy e = (Enemy)objects[i];

                    e.UpdateAnimation(gameTime);
                    if (e.SearchPlayer())
                    {
                        e.BearDirectionCheck();
                    }

                    insane.RaiseInsanityBar(e.AttackPlayer());
                    insane.ChangeImage();
                    RemoveEnemy(e);
                    e.PrevX = e.X;
                    e.PrevY = e.Y;
                }
                else if (objects[i] is MapObject)
                {
                    MapObject mo = (MapObject)objects[i];
                    for (int j = 0; j < objects.Count; j++)
                    {
                        if (objects[j] is Enemy || objects[j] is Player)
                        {
                            mo.CheckCollision(objects[j]);
                        }
                    }
                }
            }

            objectsInDrawOrder.Sort((x, y) => x.HitBoxY.CompareTo(y.HitBoxY));
        }
Exemple #5
0
 public void Die()
 {
     if (State != HitBoxState.Dead) // sanity.
     {
         State = HitBoxState.Dead;
         DeathEffects();
     }
 }
Exemple #6
0
 private void SetStartPosition()
 {
     state = HitBoxState.Airborne;
     Speed = Vector2.Zero;
     Direction = Direction.None;
     Position = TileMatrix.Instance.StartPosition;
     IdleEffects();
 }
Exemple #7
0
 private void CompleteLevel()
 {
     if (State != HitBoxState.LevelCompleteAnimation) // sanity.
     {
         State = HitBoxState.LevelCompleteAnimation;
         LevelCompleteEffects();
     }
 }