Beispiel #1
0
        public AggroFlag(World _world, Level _level)
        {
            world = _world;
            level = _level;
            position = level.GetSpawnPoint();
            currentColor = Color.Green;
            previousColor = Color.Blue;
            colorTimer = TimeSpan.Zero;

            size = new Vector2(50f / PPM, 50f / PPM);
            body = BodyFactory.CreateRectangle(world, size.X, size.Y, 10f);
            body.UserData = this;
            body.Position = position / PPM;
            body.BodyType = BodyType.Dynamic;
            body.Restitution = 0.2f;
            body.Friction = 0.2f;
            body.SleepingAllowed = false;
            body.FixedRotation = true;
            body.CollisionCategories = Category.Cat5;
            body.CollidesWith = Category.Cat1 | Category.Cat2;
            body.OnCollision += body_OnCollision;
        }
Beispiel #2
0
        protected override void _load()
        {
            MainFrame.backgroundColor = Color.Black * 0.0f;

            Label lblAdd = new Label(MainFrame, "titleLbl", "Time Limit:", (graphics.PreferredBackBufferWidth / 2) - (graphics.PreferredBackBufferWidth / 8), 20, Color.White);
            lblAdd.width = graphics.PreferredBackBufferWidth/8;
            lblAdd.height = 40;
            lblAdd.fontSize = FontSizes.Medium;
            lblAdd.backgroundColor = Color.White * 0.50f;
            lblAdd.horizAlignment = HorizAlignments.AlignRight;
            MainFrame.AddChild(lblAdd);

            lblAdd = new Label(MainFrame, "timerLbl", "0:00", (graphics.PreferredBackBufferWidth / 2), 20, Color.White);
            lblAdd.width = graphics.PreferredBackBufferWidth / 16;
            lblAdd.height = 40;
            lblAdd.fontSize = FontSizes.Medium;
            lblAdd.backgroundColor = Color.White * 0.50f;
            MainFrame.AddChild(lblAdd);

            //Create the phyics engine for this scene.
            world = new World(Vector2.UnitY * 10);

            level = new TheGrinder(world);
            Level.ActiveLevel = level;

            HAL = new AI(world);
            Player newPlayer = new GenericBrawler(world, 1, level.GetInitialSpawn());
            newPlayer.isAI = true;
            players.Add(newPlayer);

            newPlayer = new GenericBrawler(world, 2, level.GetInitialSpawn());
            newPlayer.isAI = true;
            players.Add(newPlayer);

            newPlayer = new GenericBrawler(world, 3, level.GetInitialSpawn());
            newPlayer.isAI = true;
            players.Add(newPlayer);

            newPlayer = new GenericBrawler(world, 4, level.GetInitialSpawn());
            newPlayer.isAI = true;
            players.Add(newPlayer);

            camera = new Camera2D();
            camera.targetPosition = new Vector2(800, 450);

            //Load UI based on number of players
            for (int i = 0; i < players.Count; i++)
            {
                lblAdd = new Label(MainFrame, "name" + i + "Lbl", players[i].name, i * (graphics.PreferredBackBufferWidth / 4) + 100, graphics.PreferredBackBufferHeight - 50, Color.White);
                lblAdd.width = 200;
                lblAdd.height = 20;
                lblAdd.backgroundColor = players[i].color * 0.75f;
                MainFrame.AddChild(lblAdd);

                lblAdd = new Label(MainFrame, "damage" + i + "Lbl", "0%", i * (graphics.PreferredBackBufferWidth / 4) + 100, graphics.PreferredBackBufferHeight - 100, Color.White);
                lblAdd.width = 100;
                lblAdd.height = 50;
                lblAdd.fontSize = FontSizes.Medium;
                lblAdd.backgroundColor = players[i].color * 0.75f;
                MainFrame.AddChild(lblAdd);

                lblAdd = new Label(MainFrame, "score" + i + "Lbl", "0", i * (graphics.PreferredBackBufferWidth / 4) + 200, graphics.PreferredBackBufferHeight - 100, Color.White);
                lblAdd.width = 150;
                lblAdd.height = 50;
                lblAdd.fontSize = FontSizes.Medium;
                lblAdd.backgroundColor = players[i].color * 0.75f;
                MainFrame.AddChild(lblAdd);
            }

            flag = new AggroFlag(world, level);

            timer = TIME_LIMIT;
            //Sound.PlayBGMusic();
        }