Exemple #1
0
        public static bool CheckCollision(Entity a, MysteryBox b)
        {
            if (a.myModel != null && b.myModel != null)
            {
                for (int i = 0; i < a.myModel.Meshes.Count; i++)
                {
                    BoundingSphere HeroSphere = a.myModel.Meshes[i].BoundingSphere;
                    HeroSphere.Center += a.getPOSITION();

                    for (int j = 0; j < b.myModel.Meshes.Count; j++)
                    {
                        BoundingSphere EnemySphere = b.myModel.Meshes[j].BoundingSphere.Transform(Matrix.CreateScale(0.2f));
                        EnemySphere.Center += b.getPOSITION();

                        if (HeroSphere.Intersects(EnemySphere))
                        {
                            //collision!
                            return true;
                        }
                    }
                }
            }
            return false;
        }
Exemple #2
0
        /// <summary>
        /// This function generates the mystery box for the arena
        /// </summary>
        private void generateMysteryBox()
        {
            Tile tile;
            MysteryBox box;

            do
            {
                tile = tiles[r.Next(height), r.Next(width)];
            }
            while (tile == startTile || tile == endTile || tile.getNumConnections() != 1);

            // Create the potion
            Vector3 pos = tile.getModelPos();
            pos.Y += 40;

            box = new MysteryBox(pos, tile);
            box.LoadModel(Content);

            tile.addEntity(box);
        }