Example #1
0
 //Queues a GameObject for removal from the Objects dictionary
 public static void RemoveGameObject(GameObject obj)
 {
     if (obj != null)
     {
         ObjectsToRemove.Add(obj);
     }
 }
Example #2
0
        public override void Initialize()
        {
            base.Initialize();
            GameObject Background;
            Game.LifeCounter.Visible = false;  // clearing background
            Game.DiskCounter.Visible = false;  // clearing background

            if(Won) // if you win: prompt the win screen and input name for highscore
            {
                Background = new GameObject("Win", "Win.png", 1366, 768);
                Game.RoomMessage.Text = "You had a time of " + (float)(Time / 1000) + " seconds\nEnter your name!";
                Game.NameEnter.Visible = true; // allow name entry

                string playerName = "";

                if (Player1.IsBPressed && CanPressB)  // save the name when B is clicked
                {
                    playerName = Game.NameEnter.Text;
                }

                HighScores.AddEntry(Time, playerName); // add the name and score to the high scores
            }
            else  // if loss: prompt the loss screen
            {
                Game.RoomMessage.Text = "You had a time of " + (float)(Time / 1000) + " seconds";
                Background = new GameObject("Loss", "Loss.png", 1366, 768);
            }
            ObjectManager.AddGameObject(Background);
        }
Example #3
0
        static List<GameObject> ObjectsToRemove = new List<GameObject>(); //The objects to remove at the beginning of the next frame

        #endregion Fields

        #region Methods

        //Queues a GameObject for adding into the Objects dictionary
        public static void AddGameObject(GameObject obj)
        {
            if (obj != null)
            {
                ObjectsToAdd.Add(obj);
            }
        }
Example #4
0
        public override void Initialize()
        {
            base.Initialize();
            Buttons = new Button[4];

            GameObject Background = new GameObject("Background", "TitleScreen.png", 1366, 768);
            Background.ZOrder = -10;
            ObjectManager.AddGameObject(Background);

            Buttons[0] = new Button("PlayButton", "PlayText1.png", "PlayText2.png", 154, 39);
            Buttons[0].Position = new PointF(0, 0);

            Buttons[1] = new Button("TutorialButton", "TutorialText1.png", "TutorialText2.png", 154, 39);
            Buttons[1].Position = new PointF(0, -60);

            Buttons[2] = new Button("CreditsButton", "CreditsText1.png", "CreditsText2.png", 157, 39);
            Buttons[2].Position = new PointF(0, -120);

            Buttons[3] = new Button("QuitButton", "QuitText1.png", "QuitText2.png", 156, 39);
            Buttons[3].Position = new PointF(0, -180);

            GameObject Credits = new GameObject("Credits", "Credits.jpg", 1366, 768);
            ObjectManager.AddGameObject(Credits);
            Credits.ZOrder = 10;
            Credits.IsVisible = false;

            GameObject Tutorial = new GameObject("Tutorial", "Tutorial.png", 1366, 768);
            ObjectManager.AddGameObject(Tutorial);
            Tutorial.ZOrder = 10;
            Tutorial.IsVisible = false;

            Game.NameEnter.Visible = false;

            foreach (Button obj in Buttons)
                ObjectManager.AddGameObject(obj);

            InCredits = false;
            InTutorial = false;
        }
        public override void Initialize()
        {
            base.Initialize();

            GameObject Background = new GameObject("Background", "TitleScreen.png", 1366, 768);
            Background.ZOrder = -10;
            ObjectManager.AddGameObject(Background);

            Buttons = new Button[3];

            Buttons[0] = new Button("EasyButton", "EasyText1.png", "EasyText2.png", 132 , 33);
            Buttons[0].Position = new PointF(0, 0);

            Buttons[1] = new Button("MediumButton", "MediumText1.png", "MediumText2.png", 132, 33);
            Buttons[1].Position = new PointF(0, -60);

            Buttons[2] = new Button("HardButton", "HardText1.png", "HardText2.png", 130, 33);
            Buttons[2].Position = new PointF(0, -120);

            foreach (Button b in Buttons)
                ObjectManager.AddGameObject(b);
        }
Example #6
0
 public TriviaLevel(TheLevel l, Arm a, GameObject[] Objects)
 {
     LevelToReturnTo = l;
     ToAddTo = a;
     ToReadd = Objects;
 }
Example #7
0
        //Checks if this GameObject is collided with another one.
        public bool IsCollidedWithGameObject(GameObject Obj)
        {
            if (Collision == CollisionTypes.None || Obj.Collision == CollisionTypes.None) //If Collision is off, they're not colliding
            {
                return false;
            }
            else if (Collision == CollisionTypes.Circular)
            {
                if (Obj.Collision == CollisionTypes.Circular) //In the case that they both have circular collision
                {
                    if (Distance(Position, Obj.Position) < CollisionRadius || Distance(Position, Obj.Position) < Obj.CollisionRadius)
                        return true;
                    else
                        return false;
                }
                if (Obj.Collision == CollisionTypes.Rectangular) //If this has circular, but the other one has Rectangular
                {
                    switch (RelativeQuadrant(this.Position, Obj.Position))
                    {
                        case 1:
                            if (Distance(this.Position, ((PointFHelp.PointF)Obj.Position - (PointFHelp.PointF)Obj.CollisionBox / 2)) < this.CollisionRadius)
                                return true;
                            else
                                return false;
                        case 2:
                            if (Distance(this.Position, new PointF((Obj.Position.X + Obj.CollisionBox.X / 2), (Obj.Position.Y - Obj.CollisionBox.Y / 2))) < this.CollisionRadius)
                                return true;
                            else
                                return false;
                        case 3:
                            if (Distance(this.Position, ((PointFHelp.PointF)Obj.Position + (PointFHelp.PointF)Obj.CollisionBox / 2)) < this.CollisionRadius)
                                return true;
                            else
                                return false;
                        case 4:
                            if (Distance(this.Position, new PointF((Obj.Position.X - Obj.CollisionBox.X / 2), (Obj.Position.Y + Obj.CollisionBox.Y / 2))) < this.CollisionRadius)
                                return true;
                            else
                                return false;
                        case 5:
                            if (this.Position.X + CollisionRadius < Obj.Position.X - CollisionBox.X / 2)
                                return false;
                            else
                                return true;
                        case 6:
                            if (this.Position.Y + CollisionRadius < Obj.Position.Y - CollisionBox.Y / 2)
                                return false;
                            else
                                return true;
                        case 7:
                            if (this.Position.X - CollisionRadius > Obj.Position.X + CollisionBox.X / 2)
                                return false;
                            else
                                return true;
                        case 8:
                            if (this.Position.Y - CollisionRadius > Obj.Position.Y - CollisionBox.Y / 2)
                                return false;
                            else
                                return true;
                        case -1:
                            return true;
                        default:
                            return false;
                    }
                }
                return false;
            }
            else //If it goes in here, it must always be Rectangular
            {
                if (Obj.Collision == CollisionTypes.Circular) //If we are rectangular and they are circular, just call the same code as above, except with the positions reversed
                    return Obj.IsCollidedWithGameObject(this);
                else //If we are both rectangular
                    switch (RelativeQuadrant(Position, Obj.Position))
                    {
                        case 1:
                            if (this.Position.X + this.CollisionBox.X / 2 >= Obj.Position.X - Obj.CollisionBox.X / 2)
                            {
                                if (this.Position.Y + this.CollisionBox.Y / 2 >= Obj.Position.Y - Obj.CollisionBox.Y / 2)
                                {
                                    return true;
                                }
                            }
                            return false;
                        case 2:
                            if (this.Position.X - this.CollisionBox.X / 2 <= Obj.Position.X + Obj.CollisionBox.X / 2)
                            {
                                if (this.Position.Y + this.CollisionBox.Y / 2 >= Obj.Position.Y - Obj.CollisionBox.Y / 2)
                                {
                                    return true;
                                }
                            }
                            return false;
                        case 3:
                            if (this.Position.X - this.CollisionBox.X / 2 <= Obj.Position.X + Obj.CollisionBox.X / 2)
                            {
                                if (this.Position.Y - this.CollisionBox.Y / 2 <= Obj.Position.Y + Obj.CollisionBox.Y / 2)
                                {
                                    return true;
                                }
                            }
                            return false;
                        case 4:
                            if (this.Position.X + this.CollisionBox.X / 2 >= Obj.Position.X - Obj.CollisionBox.X / 2)
                            {
                                if (this.Position.Y - this.CollisionBox.Y / 2 <= Obj.Position.Y + Obj.CollisionBox.Y / 2)
                                {
                                    return true;
                                }
                            }
                            return false;
                        case 5:
                            if (this.Position.X + this.CollisionBox.X / 2 >= Obj.Position.X - Obj.CollisionBox.X / 2)
                                return true;
                            return false;
                        case 6:
                            if (this.Position.Y + this.CollisionBox.Y / 2 >= Obj.Position.Y - Obj.CollisionBox.Y / 2)
                                return true;
                            return false;
                        case 7:
                            if (this.Position.X - this.CollisionBox.X / 2 <= Obj.Position.X + Obj.CollisionBox.X / 2)
                                return true;
                            return false;
                        case 8:
                            if (this.Position.Y - this.CollisionBox.Y / 2 <= Obj.Position.Y + Obj.CollisionBox.Y / 2)
                                return true;
                            return false;
                        case -1:
                            return true;
                        default:
                            return false;
                    }

            }
        }
Example #8
0
        public override void Initialize()
        {
            base.Initialize();

            MusicTimer = RegularMusicDuration * (int)FrameRateController.FrameRate;
            RegularMusic.Play();
            Music = false;

            Game.RoomMessage.Visible = true;
            Game.LifeCounter.Visible = true;
            Game.DiskCounter.Visible = true;

            GameObject Background = new GameObject("Background", "GameBackground2.jpg", 1366, 768);
            Background.AddFrame("PitBackground.jpg", 0);
            Background.ZOrder = -10;
            ObjectManager.AddGameObject(Background);

            GameObject LifeIcon = new GameObject("LifeIcon", "LifeIcon.png", 64, 64);
            LifeIcon.Position = new PointFHelp.PointF(-619, 320);
            LifeIcon.ZOrder = 10;
            ObjectManager.AddGameObject(LifeIcon);

            GameObject DiskIcon = new GameObject("DiskIcon", "DiskIcon.png", 64, 64);
            DiskIcon.Position = new PointFHelp.PointF(-619, 256);
            DiskIcon.ZOrder = 10;
            ObjectManager.AddGameObject(DiskIcon);

            ThePlayer = new Player();
            ObjectManager.AddGameObject(ThePlayer); //Create the player
            ObjectManager.AddGameObject(new Arm(ThePlayer, 0)); //Add the arm that follows the player

            //Create the walls
            NWalls = new Wall[4];
            NEWalls = new Wall[3];
            SEWalls = new Wall[3];
            SWalls = new Wall[4];
            SWWalls = new Wall[3];
            NWWalls = new Wall[3];

            for (int i = 0; i < NWalls.Length; i++)
            {
                NWalls[i] = new Wall("NWall" + i);
                ObjectManager.AddGameObject(NWalls[i]);
                NWalls[i].Position.Y = 320;
                NWalls[i].Position.X = (128 * i) - 256;
                NWalls[i].Collidable = true;
            }
            for (int i = 0; i < NEWalls.Length; i++)
            {
                NEWalls[i] = new Wall("NEWall" + i);
                ObjectManager.AddGameObject(NEWalls[i]);
                NEWalls[i].Position.Y = 320 - (i * 128);
                NEWalls[i].Position.X = (128 * i) + 256;
                NEWalls[i].Collidable = true;
            }
            for (int i = 0; i < SEWalls.Length; i++)
            {
                SEWalls[i] = new Wall("SEWall" + i);
                ObjectManager.AddGameObject(SEWalls[i]);
                SEWalls[i].Position.Y = -320 + (i * 128);
                SEWalls[i].Position.X = (128 * i) + 256;
                SEWalls[i].Collidable = true;
            }
            for (int i = 0; i < SWalls.Length; i++)
            {
                SWalls[i] = new Wall("SWall" + i);
                ObjectManager.AddGameObject(SWalls[i]);
                SWalls[i].Position.Y = -320;
                SWalls[i].Position.X = (128 * i) - 256;
                SWalls[i].Collidable = true;
            }
            for (int i = 0; i < SWWalls.Length; i++)
            {
                SWWalls[i] = new Wall("SWWall" + i);
                ObjectManager.AddGameObject(SWWalls[i]);
                SWWalls[i].Position.Y = -320 + (i * 128);
                SWWalls[i].Position.X = (-128 * i) - 256;
                SWWalls[i].Collidable = true;
            }
            for (int i = 0; i < NWWalls.Length; i++)
            {
                NWWalls[i] = new Wall("NWWall" + i);
                ObjectManager.AddGameObject(NWWalls[i]);
                NWWalls[i].Position.Y = 320 - (i * 128);
                NWWalls[i].Position.X = (-128 * i) - 256;
                NWWalls[i].Collidable = true;
            }

            EdgeWalls = new Wall[4];
            for (int i = 0; i < EdgeWalls.Length; i++)
            {
                EdgeWalls[i] = new Wall("EdgeWall" + i);
                EdgeWalls[i].Collidable = true;
                EdgeWalls[i].CollisionBox = new PointF(128, 128);
                ObjectManager.AddGameObject(EdgeWalls[i]);
            }
            EdgeWalls[0].Position = new PointF(619, 64);
            EdgeWalls[1].Position = new PointF(619, -64);
            EdgeWalls[2].Position = new PointF(-619, 64);
            EdgeWalls[3].Position = new PointF(-619, -64);

            ThePlayer.NWalls = NWalls;
            ThePlayer.NEWalls = NEWalls;
            ThePlayer.SEWalls = SEWalls;
            ThePlayer.SWalls = SWalls;
            ThePlayer.SWWalls = SWWalls;
            ThePlayer.NWWalls = NWWalls;
            ThePlayer.EdgeWalls = EdgeWalls;
        }