コード例 #1
0
ファイル: Trigger.cs プロジェクト: skakri09/GameOfThreetards
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="game">Insatnce of base game</param>
 /// <param name="triggerPosition">this objects position</param>
 /// <param name="tilePostion">the destroyable tile's position</param>
 /// <param name="triggerTileType">path to this object's image file</param>
 /// <param name="destroyableTileType">path to the destroyable tile image file</param>
 public Trigger(Game game, Camera cam, Point triggerPosition, Point tilePostion, string triggerTileType, string destroyableTileType)
     : base(game, new Point(triggerPosition.X, triggerPosition.Y))
 {
     this.cam = cam;
     collisionManager.RegisterObject(this);
     this.triggerTileType = triggerTileType;
     LoadContent();
     destroyableTile = new DestroyableTile(game, tilePostion, destroyableTileType);
 }
コード例 #2
0
        protected GameObject CreateGameObject(DestroyableTileInfo trigger, DestroyableTileInfo destroyable, Game game, Camera cam)
        {
            Trigger newTrigger = new Trigger(game,
                                            cam,
                                            trigger.Position,
                                            destroyable.Position,
                                            trigger.TileName,
                                            destroyable.TileName);

            return newTrigger;
        }
コード例 #3
0
        public Level(int i,Camera c, Model m, Model m2,Model e)
        {
            level = i;
            camera = c;
            model = m;
            model2 = m2;

            for (int j = 0; j < enemy.Length; j++)
            {

                Vector3 vec = new Vector3(4*j, -3.7f, 4*j+50);
                enemy[j] = new Enemy(e, vec);
                enemy[j].setLevel(this);
            }
        }
コード例 #4
0
        private void Initialize()
        {
            camera = new Camera(ScreenManager.GraphicsDevice.Viewport);
            //camera.AttachMap(map);

            GameManager.TheGameManager.Content = content;
            GameManager.TheGameManager.AttachGraphicsDevice(ScreenManager.GraphicsDevice);

            gameInterface = new GameInterface();
            GameManager.TheGameManager.AttachGameInterface(gameInterface);

            GameManager.TheGameManager.AttachCamera(camera);
            GameManager.TheGameManager.LoadGlobalAssets();
            GameManager.TheGameManager.LoadScenario(MAPNAME);
            GameManager.TheGameManager.PostInitialize();
        }
コード例 #5
0
        public List<GameObject> GetGameObjects(Game game, xTile.Map map, Camera cam)
        {
            List<GameObject> returnObjects = new List<GameObject>();

            Layer triggerLayer = map.GetLayer("detonators");
            Layer destroyableTiles50X50 = map.GetLayer("destroyableTiles50x50");
            Layer destroyableTile100X100 = map.GetLayer("destroyableTiles100x100");

            List<DestroyableTileInfo> destroyables = new List<DestroyableTileInfo>();
            List<DestroyableTileInfo> triggers = new List<DestroyableTileInfo>();
            if(triggerLayer != null)
            {
                triggers.AddRange(ExtractGameObjectPositions(triggerLayer, "detonator"));

                if(destroyableTiles50X50 != null)
                {
                    destroyables.AddRange(ExtractGameObjectPositions(destroyableTiles50X50, "destroyable_tile_small"));
                }
                if(destroyableTile100X100 != null)
                {
                    destroyables.AddRange(ExtractGameObjectPositions(destroyableTile100X100, "destroyable_tile"));
                }

                if(triggers.Count == destroyables.Count)
                {
                    for (int i = 0; i < triggers.Count; i++)
                    {
                        for(int y = 0; y < destroyables.Count; y++)
                        {
                            if(triggers[i].ID == destroyables[y].ID)
                            {
                                returnObjects.Add(CreateGameObject(triggers[i], destroyables[y], game, cam));
                                continue;
                            }
                        }
                    }
                }
                else
                {
                    Debug.WriteLine("Amount of triggers does not match the amount of destroyables");
                }
            }

            return returnObjects;
        }
コード例 #6
0
        public GameObjectLayersManager(Game game, Map map, Camera cam)
        {
            BoxLayer100x100 boxes100x100 = new BoxLayer100x100();
            _gameObjects.AddRange(boxes100x100.GetGameObjects(game, map));

            BoxLayer50x50 boxes50x50 = new BoxLayer50x50();
            _gameObjects.AddRange(boxes50x50.GetGameObjects(game, map));

            GoalLayer goal = new GoalLayer();
            _gameObjects.AddRange(goal.GetGameObjects(game, map));

            DetonatorLayer detonatorStuff = new DetonatorLayer();
            _gameObjects.AddRange(detonatorStuff.GetGameObjects(game, map, cam));

            KeyLayer keyLayer = new KeyLayer();
            _gameObjects.AddRange(keyLayer.GetGameObjects(game, map));

            DoorLayer doorLayer = new DoorLayer();
            _gameObjects.AddRange(doorLayer.GetGameObjects(game, map));
        }
コード例 #7
0
        public void init()
        {
            this.player = new Player();
            this.camera = new Camera(player);
            this.level = new Level(0,camera,model,model2,model_zombie);
            player.setLevel(level);
            level.SetUpBoundingBoxes();

            hud2 = new HUD2(player, gameFont, heart,ScreenManager.SpriteBatch);
        }
コード例 #8
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");
            spriteBatch = ScreenManager.SpriteBatch;
            gameFont = content.Load<SpriteFont>("gamefont");

            world = new World(ScreenManager.Game);
            world.LoadContent();

            moveLeftBtn = new ClickableRectangle(ScreenManager.Game, new Rectangle(0, 320, 160, 160), buttonType.MOVE_LEFT);
            moveRightBtn = new ClickableRectangle(ScreenManager.Game, new Rectangle(640, 320, 160, 160), buttonType.MOVE_RIGHT);
            jumpBtn = new ClickableRectangle(ScreenManager.Game, new Rectangle(0, 159, 160, 160), buttonType.JUMP);
            abilityBtn = new ClickableRectangle(ScreenManager.Game, new Rectangle(640, 159, 160, 160), buttonType.SPECIAL_ATTACK);
            buttons.Add(moveLeftBtn);
            buttons.Add(moveRightBtn);
            buttons.Add(jumpBtn);
            buttons.Add(abilityBtn);

            p1s = new PlayerInControlBtn(ScreenManager.Game, new Point(200, 0), PlayerSelection.P1);
            p2s = new PlayerInControlBtn(ScreenManager.Game, new Point(400, 0), PlayerSelection.P2);
            p3s = new PlayerInControlBtn(ScreenManager.Game, new Point(600, 0), PlayerSelection.P3);
            buttons.Add(p1s);
            buttons.Add(p2s);
            buttons.Add(p3s);

            PlayerGreen p1 = new PlayerGreen(ScreenManager.Game, new Point(100, 100), gravity);
            PlayerBlue p2 = new PlayerBlue(ScreenManager.Game, new Point(100, 200), gravity);
            PlayerRed p3 = new PlayerRed(ScreenManager.Game, new Point(100, 300), gravity);
            currentPlayerIndex = 0;
            players.Add(p1);
            players.Add(p2);
            players.Add(p3);
            gameObjects.Add(p1);
            gameObjects.Add(p2);
            gameObjects.Add(p3);

            cam = new Camera(ScreenManager.GraphicsDevice.Viewport);
            cam.activePlayer = players[currentPlayerIndex];

            foreach (GameObject gameObject in gameObjects)
            {
                gameObject.LoadContent();
            }

            foreach (GameObject button in buttons)
            {
                button.LoadContent();
            }
            // A real game would probably have more content than this sample, so
            // it would take longer to load. We simulate that by delaying for a
            // while, giving you a chance to admire the beautiful loading screen.
            //Thread.Sleep(1000);

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();
        }
コード例 #9
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
            {
                content = new ContentManager(ScreenManager.Game.Services, "Content");
            }
            //Add game cam
            cam = new Camera(ScreenManager.GraphicsDevice.Viewport);
            ScreenManager.Game.Services.AddService(typeof(Camera), cam);

            //ScreenManager.DeserializeState();
            collisionMananger = new CollisionManager(ScreenManager.Game);

            // Adds collision manager to Game.Service, This Service unloads when UnloadContent is called.
            ScreenManager.Game.Services.AddService(typeof(ICollisionService), collisionMananger);

            spriteBatch = ScreenManager.SpriteBatch;
            mapDisaplayDevice = new XnaDisplayDevice(this.content, ScreenManager.GraphicsDevice);
            map = content.Load<Map>(_mapLevelName);
            map.LoadTileSheets(mapDisaplayDevice);

            _collisionLayers = new CollisionLayers(ScreenManager.Game, map);

            _gameObjectLayerManager = new GameObjectLayersManager(ScreenManager.Game, map, cam);
            gameObjects.AddRange(_gameObjectLayerManager.GameObjects);

            soundManager = new Sound(ScreenManager.Game);
            ScreenManager.Game.Services.AddService(typeof(ISound), soundManager);
            soundManager.LoadContent();
            soundManager.PlayMusic("main");

            //Adds GUI buttons
            gamePlayButtons = new GamePlayButtons(ScreenManager.Game);

            //Add players
            playerManager = new PlayerManager(ScreenManager.Game, map, gravity);
            gameObjects.AddRange(playerManager.players);

            cam.activePlayer = playerManager.currentPlayer;

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();

            foreach (GameObject obj in gameObjects)
            {
                if (obj is TargetTile)
                {
                    cam.center = obj.position;
                    cam.MoveCameraToGameObject(obj, 4.0f, 800.0f);
                    break;
                }
            }
            GC.Collect(); //Requesting garbage collect
        }
コード例 #10
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");

            world = new World(new Vector2(0f, 9.8f));
            mapDisaplayDevice = new XnaDisplayDevice(this.content, ScreenManager.GraphicsDevice);

            map = content.Load<Map>("Maps\\lvl1");
            map.LoadTileSheets(mapDisaplayDevice);

               collisionLayers = new CollisionLayers(ScreenManager.Game, world, map);

            gamePlayButtons = new GamePlayButtons(ScreenManager.Game, world);
            gamePlayButtons.LoadContent();

            playerManager = new PlayerManager(ScreenManager.Game, world, map);
            gameObjects.AddRange(playerManager.players);

            GameObjectLayersManager xTileGameObjects = new GameObjectLayersManager(ScreenManager.Game, world, map);
            gameObjects.AddRange(xTileGameObjects.GameObjects);

            //add game cam
            cam = new Camera(ScreenManager.GraphicsDevice.Viewport);
            cam.activePlayer = playerManager.currentPlayer;

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();
        }
コード例 #11
0
        public void Initialize()
        {
            Lists.Effects = new List<CustomEffect>();
            Lists.StatusTexts = new List<StatusText>();
            Lists.GarbageCollectorList = new List<object>();
            Lists.AddOnNextFrameList = new List<object>();
            Lists.ActiveItems = new List<ActiveItem>();
            Lists.Actors = new List<Actor>();
            Lists.ParticleGenerators = new List<ParticleGenerator>();

            this.GameObjects = new List<GameObject>();

            GameInterface = new GameInterface();
            Camera = new Camera();
        }
コード例 #12
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
            {
                content = new ContentManager(ScreenManager.Game.Services, "Content");
            }

            collisionMananger = new CollisionManager(ScreenManager.Game);

            // Adds collision manager to Game.Service, This Service unloads when UnloadContent is called.
            ScreenManager.Game.Services.AddService(typeof(ICollisionService), collisionMananger);

            spriteBatch = ScreenManager.SpriteBatch;
            gameFont = content.Load<SpriteFont>("gamefont");

            //Add game world
            world = new World(ScreenManager.Game);
            world.LoadContent();
            gameObjects.AddRange(world.tiles);

            //Add Trigger objects
            gameObjects.AddRange(world.triggerTile);

            //Add Destroyable Tile objects
            foreach (Trigger triggerObj in world.triggerTile)
            {
                 gameObjects.Add(triggerObj.GetDestroyableTile());
            }

            soundManager = new Sound(ScreenManager.Game);
            soundManager.LoadContent();
            soundManager.PlayMusic("main");

            //Adds GUI buttons
            gamePlayButtons = new GamePlayButtons(ScreenManager.Game);

            //Add players
            playerManager = new PlayerManager(ScreenManager.Game, gravity);
            playerManager.LoadContent();
            gameObjects.AddRange(playerManager.players);
            endPicture = content.Load<Texture2D>("endpicture");
            //Add game cam
            cam = new Camera(ScreenManager.GraphicsDevice.Viewport);
            cam.activePlayer = playerManager.currentPlayer;

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();

            GC.Collect(); //Requesting garbage collect
        }