Example #1
0
        //this currently can only collide with adjacent tiles, should be more dynamic if we wanted bigger things
        //this is also using interactable as collidable, may or may not want to keep it this way
        public static List<Doodad> GetCollidableDoodads(GameObject go)
        {
            List<Doodad> collidableDoodads = new List<Doodad>();

            int xTile = (int)go.Position.X / Data.TileSize;
            int yTile = (int)go.Position.Y / Data.TileSize;

            for (int x = (xTile-1); x < (xTile + 2); x++)
            {
                for (int y = (yTile-1); y < (yTile + 2); y++)
                {
                    if (GetTile(x, y) != null)
                    {
                        foreach (Doodad doodad in GetTile(x, y).GetDoodads())
                        {
                            if (doodad.IsInteractable)
                            {
                                collidableDoodads.Add(doodad);
                            }
                        }
                    }
                }
            }

            return collidableDoodads;
        }
Example #2
0
 public void InsertGameObject(GameObject go)
 {
     if(gameObjects.ContainsKey(go.GetId()))
     {
         return;
     }
     gameObjects.Add(go.GetId(), go);
 }
Example #3
0
 public void RemoveObject(GameObject gameObject)
 {
     gameObjects.Remove(gameObject.GetId());
 }
Example #4
0
        protected override void Interact(GameObject gameObject)
        {
            if (DateTime.Now.CompareTo(interactionOffCooldown) < 0)
            {
                return;
            }

            goalPosition = position;

            //bad, change it to be more dynamic!
            if (gameObject is Toon)
            {
                InteractWithObject((Toon)gameObject);
            }
        }
Example #5
0
File: Hero.cs Project: norniel/Game
 public bool AddToBag(GameObject gameObject)
 {
     return _bag.Add(gameObject);
 }
Example #6
0
File: Hero.cs Project: norniel/Game
 public void RemoveFromContainer(GameObject gObject)
 {
     _bag.GameObjects.Remove(gObject);
 }
 public MoveToGameObjectMobState(GameObject gameObject, Mob mob)
 {
     this.gameObject = gameObject;
     this.mob = mob;
 }
Example #8
0
 public bool IsGameObjectInsideRange(GameObject gameObject, int range)
 {
     return (gameObject.Position - Position).Length() < range;
 }
Example #9
0
 protected virtual void Interact(GameObject gameObject)
 {
 }
Example #10
0
 public void ReceiveEvent(MoveToGameObjectEvent leEvent)
 {
     goalGameObject = Map.GetGameObject(leEvent.GoalGameObject);
 }
Example #11
0
 public void ReceiveEvent(MoveToPositionEvent leEvent)
 {
     goalPosition = leEvent.Position;
     goalGameObject = null;
 }
Example #12
0
        public static void RemoveGameObject(GameObject gameObject)
        {
            GetTile((int)gameObject.Position.X / Data.TileSize, (int)gameObject.Position.Y / Data.TileSize).RemoveObject(gameObject);
            allGameObjects.Remove(gameObject.GetId());
            if (gameObject is Mob)
            {
                allMobs.Remove(gameObject.GetId());
            }

            if (gameObject is Toon)
            {
                allToons.Remove(gameObject.GetId());
            }
        }
Example #13
0
        //use the given GameObjects position to manage what tile to go into
        public static void InsertGameObject(GameObject go)
        {
            //BAD BAD IF STATEMENT, BE GONE, DAMN ARRAYS
            if (go.Position.X < 0 || go.Position.X > tiles.GetLength(0) * Data.TileSize || go.Position.Y < 0 || go.Position.Y > tiles.GetLength(1) * Data.TileSize)
            {
                go.Position = new Vector2(100, 100); //looks and feels horrible
            }
            tiles[(int)(go.Position.X / Data.TileSize), (int)(go.Position.Y / Data.TileSize)].InsertGameObject(go);
            if (!allGameObjects.ContainsKey(go.GetId()))
            {
                allGameObjects.Add(go.GetId(), go);
            }

            if (go is Mob)
            {
                if (!allMobs.ContainsKey(go.GetId()))
                {
                    allMobs.Add(go.GetId(), (Mob)go);
                }
            }

            if (go is Toon)
            {
                if (!allToons.ContainsKey(go.GetId()))
                {
                    allToons.Add(go.GetId(), (Toon)go);
                }
            }
        }
Example #14
0
        protected override void Interact(GameObject gameObject)
        {
            if (DateTime.Now.CompareTo(interactionOffCooldown) == -1)
            {
                return;
            }

            base.Interact(gameObject);

            goalGameObject = null; //<-- this  is to stop you from interacting every frame, this may be removed once a cooldown has been introduced
            goalPosition = position;

            //bad ifs, change it to be more dynamic
            if (gameObject is Tree)
            {
                InteractWithObject((Tree)gameObject);
            }
            else if (gameObject is PalmTree)
            {
                InteractWithObject((PalmTree)gameObject);
            }
            else if (gameObject is Loot)
            {
                InteractWithObject((Loot)gameObject);

            }
            else if (gameObject is Mob)
            {
                InteractWithObject((Mob)gameObject);
            }
        }