Пример #1
0
        public void initialize()
        {
            player = new GameObject(true, true);

            shieldBehaviour = new ShieldBehaviour(null);
            player.AddBehaviour("ShieldBehaviour",shieldBehaviour);

            statBehaviour = new StatBehaviour(100, 100, 0);
            player.AddBehaviour("StatBehaviour",statBehaviour);

            hitBehaviour = new HitBehaviour(null);
            player.AddBehaviour("HitBehaviour",hitBehaviour);
        }
Пример #2
0
        private void LoadGameObjects()
        {
            gameObjects = new List<GameObject>();
            var playerTexture = Content.Load<Texture2D>("player/basicperson0");
            var monsterTexture = Content.Load<Texture2D>("Roman");
            var swordTexture = Content.Load<Texture2D>("sword1");
            var shieldTexture = Content.Load<Texture2D>("shield2");
            var helmetTexture = Content.Load<Texture2D>("Head");
            List<Texture2D> monsterHelmets = new List<Texture2D>();
            for (int i = 0; i < 3; i++)
            {
                monsterHelmets.Add(Content.Load<Texture2D>("helmets/helm" + i));
            }
            var boss1Texture = Content.Load<Texture2D>("Boss1");
            var boss2Texture = Content.Load<Texture2D>("Boss2");
            var boss3Texture = Content.Load<Texture2D>("Boss3");
            var boss4Texture = Content.Load<Texture2D>("Boss4");
            var khanTexture = Content.Load<Texture2D>("khan");
            var bossStart = Content.Load<Texture2D>("BossLopen/BossLopen0");
            var swordBoss1Texture = Content.Load<Texture2D>("Sword_Boss1");
            var swordBoss2Texture = Content.Load<Texture2D>("Sword_Boss2");
            var swordBoss3Texture = Content.Load<Texture2D>("Sword_Boss3");
            var swordBoss4Texture = Content.Load<Texture2D>("Sword_Boss4");
            textFont = Content.Load<SpriteFont>("TextFont");

            List<Texture2D> bossAnimations = new List<Texture2D>();
            for (int i = 0; i < 8; i++)
            {
                bossAnimations.Add(Content.Load<Texture2D>("BossLopen/BossLopen" + i));
            }

            List<Texture2D> playerAnimations = new List<Texture2D>();
            for (int i = 0; i < 7; i++)
            {
                playerAnimations.Add(Content.Load<Texture2D>("player/basicperson" + i));
            }

            if (tilemap != null)
                tilemap.Build(Content);

            // Add Game Objects
            somePlayer = new GameObject
            {
                Position = new Vector2(1312, 5088),
                Texture = playerTexture
            };
            mainMenu.PlayerAlive = true;
            somePlayer.AddBehaviour("MovementBehaviour", new MovementBehaviour(playerAnimations));
            somePlayer.AddBehaviour("StatBehaviour", new StatBehaviour(100, 200, 0.5f));
            somePlayer.AddBehaviour("HUDBehaviour", new HUDBehaviour(
                Content.Load<Texture2D>("HealthBar"),
                Content.Load<Texture2D>("TestosBar"),
                Content.Load<SpriteFont>("textFont"),
                somePlayer));
            var someHelmet = new GameObject(true, false)
            {
                Texture = helmetTexture
            };

            someHelmet.AddBehaviour("ChildBehaviour", new ChildBehaviour()
            {
                Parent = somePlayer
            });

            var swordPlayer = new GameObject(false, false)
            {
                Texture = swordTexture
            };
            swordPlayer.AddBehaviour("WeaponBehaviour", new WeaponBehaviour()
            {
                Wielder = somePlayer
            });

            somePlayer.AddBehaviour("AttackBehaviour", new AttackBehaviour(swordPlayer));
            somePlayer.AddBehaviour("HitBehaviour", new HitBehaviour(swordPlayer, swordBoss1Texture));
            somePlayer.AddBehaviour("BondBehaviour", new BondBehaviour(swordPlayer, someHelmet));

            var shieldPlayer = new ShieldBehaviour(shieldTexture);
            somePlayer.AddBehaviour("ShieldBehaviour", shieldPlayer);
            somePlayer.AddBehaviour("TeleportBehaviour", new TeleportBehaviour(currentMapInt));

            portBlocks = new List<GameObject>();
            GameObject teleport = new GameObject();
            teleport.AddBehaviour("TeleportBlockBehaviour", new TeleportBlockBehaviour(new Vector2(40 * 32, 236 * 32)));
            teleport.Position = new Vector2(39 * 32, 73 * 32);
            teleport.Size = new Point(96, 32);
            teleport.IsCollidable = false;
            portBlocks.Add(teleport);

            if(currentMap == tilemap)
                SpawnMonsters(50, somePlayer, playerAnimations, monsterHelmets, swordTexture);
            if(currentMap == bossrooms[0])
                LoadBoss4(somePlayer, boss4Texture, swordBoss4Texture);
            if(currentMap == bossrooms[1])
                LoadBoss1_3(somePlayer, boss1Texture, swordBoss1Texture, 1);
            if(currentMap == bossrooms[2])
                LoadBoss2(somePlayer, boss2Texture, bossAnimations, swordBoss2Texture);
            if(currentMap == bossrooms[3])
            {
                LoadBoss1_3(somePlayer, boss3Texture, swordBoss3Texture, 2);
                SpawnMonsters(5, somePlayer, playerAnimations, monsterHelmets, swordTexture);
            }

            //LoadBoss1_3(somePlayer, boss1Texture, swordBoss1Texture,1);
            //LoadBoss2(somePlayer, boss2Texture, bossAnimations, swordBoss2Texture);
            //LoadBoss1_3(somePlayer, boss3Texture, swordBoss3Texture, 2);    //moeten nog wel monsters omheen worden gemaakt
            //LoadBoss4(somePlayer, boss4Texture, swordBoss4Texture);
            //LoadFinalBoss(somePlayer, khanTexture, bossAnimations, swordBoss1Texture);

            gameObjects.Add(somePlayer);
            gameObjects.Add(someHelmet);
            gameObjects.Add(swordPlayer);
            gameObjects.Add(shieldPlayer.shield);

            // Follow player with camera:
            //  ----> Remove the MonsterMovementBehaviourVB, then uncomment below to get a look at the results
            var followCamera = new FollowCamera();
            followCamera.Offset = new Vector2((float)GraphicsDevice.Viewport.Width / 2, (float)GraphicsDevice.Viewport.Height / 2);
            followCamera.Target = somePlayer;
            camera = followCamera;

            somePlayer.AddBehaviour("InputMovementBehaviour", new InputMovementBehaviour(movementSpeed: 5, camera: camera));
        }