コード例 #1
0
ファイル: WeaponTest.cs プロジェクト: dat-genius/Game0815
        public void TestPlayerSwing()
        {
            GameObject Player = new GameObject();
            GameObject PlayerSword = new GameObject(false, false);
            PlayerSword.AddBehaviour("WeaponBehaviour", new WeaponBehaviour()
            {
                Wielder = Player
            });
            bool Clicked = true;
            Player.AddBehaviour("InputMovementBehaviour",new InputMovementBehaviour(5f, new FollowCamera()));
            Player.AddBehaviour("MovementBehaviour", new MovementBehaviour());
            Player.AddBehaviour("AttackBehaviour", new AttackBehaviour(PlayerSword));
            Player.AddBehaviour("StatBehaviour", new StatBehaviour(100, 100, 0.1f));
            var inputBehaviour = Player.GetBehaviourOfType("InputMovementBehaviour");
            var weaponBehaviour = PlayerSword.GetBehaviourOfType("WeaponBehaviour");
            var attackBehaviour = Player.GetBehaviourOfType("AttackBehaviour");

            if (Clicked)
            {
                (inputBehaviour as InputMovementBehaviour).SwingSword();
            }
            Assert.IsTrue((attackBehaviour as AttackBehaviour).Attack);

            Player.OnUpdate(new GameTime());

            Assert.AreEqual(TimeSpan.FromMilliseconds(700), (attackBehaviour as AttackBehaviour).Cooldown);
            Assert.IsTrue((weaponBehaviour as WeaponBehaviour).SwingSword);
        }
コード例 #2
0
ファイル: WeaponTest.cs プロジェクト: dat-genius/Game0815
        public void TestMonsterAttack()
        {
            GameObject Player = new GameObject();
            GameObject Monster = new GameObject();
            GameObject MonsterSword = new GameObject(false, false);
            GameTime gameTime = new GameTime();
            MonsterSword.AddBehaviour("WeaponBehaviour",new WeaponBehaviour()
            {
                Wielder = Monster
            });
            Monster.AddBehaviour("MonsterAttack", new MonsterAttack(Player));
            Monster.AddBehaviour("AttackBehaviour" ,new AttackBehaviour(MonsterSword));
            Monster.AddBehaviour("StatBehaviour",new StatBehaviour(100, 100, 0.1f));
            Monster.Position = new Vector2(100, 100);
            Monster.Rotation = MathHelper.ToRadians(180);
            Player.Position = new Vector2(100, 130);

            Monster.OnUpdate(gameTime);

            var attackBehaviour = Monster.GetBehaviourOfType("AttackBehaviour");
            var monsterAttackBehaviour = Monster.GetBehaviourOfType("MonsterAttack");
            var weaponBehaviour = MonsterSword.GetBehaviourOfType("WeaponBehaviour");

            Assert.IsTrue((monsterAttackBehaviour as MonsterAttack).CheckRange());
            Assert.AreEqual(TimeSpan.FromMilliseconds(1050), (attackBehaviour as AttackBehaviour).Cooldown);
            Assert.IsTrue((weaponBehaviour as WeaponBehaviour).SwingSword);

            Player.Position = new Vector2(300, 300);

            Monster.OnUpdate(gameTime);
            MonsterSword.OnUpdate(gameTime);

            Assert.IsFalse((monsterAttackBehaviour as MonsterAttack).CheckRange());
            Assert.IsFalse((weaponBehaviour as WeaponBehaviour).SwingSword);
        }
コード例 #3
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);
        }
コード例 #4
0
        public void initialize()
        {
            player = new GameObject();
            player.AddBehaviour("StatBehaviour",new StatBehaviour(100, 100, 1));

            Stats = player.GetBehaviourOfType("StatBehaviour") as StatBehaviour;
        }
コード例 #5
0
 public void TestEdgeFindFalse()
 {
     GameObject testObject = new GameObject();
     FOVBehavior testFOV = new FOVBehavior(gameObjects);
     testObject.AddBehaviour("FOVBehaviour", testFOV);
     testObject.Rotation = 0;
     testObject.Position = new Vector2(100, 100);
     testFOV.ViewDistance = 100;
     GameObject testPlayerObject = new GameObject();
     testPlayerObject.AddBehaviour("InputMovementBehaviour",new InputMovementBehaviour(5, new FollowCamera()));
     testPlayerObject.Position = new Vector2(50, 50);
     gameObjects.Add(testObject);
     gameObjects.Add(testPlayerObject);
     Assert.IsFalse(testFOV.DetectPlayer());
     testPlayerObject.Position = new Vector2(100, 100);
     Assert.IsFalse(testFOV.DetectPlayer());
     testPlayerObject.Position = new Vector2(150, 50);
     Assert.IsFalse(testFOV.DetectPlayer());
     testPlayerObject.Position = new Vector2(100, 0);
 }
コード例 #6
0
ファイル: Game1.cs プロジェクト: dat-genius/Game0815
        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));
        }
コード例 #7
0
ファイル: Game1.cs プロジェクト: dat-genius/Game0815
        public void SpawnMonsters(uint i, GameObject target, List<Texture2D> monstertexture, List<Texture2D> helmet, Texture2D swordTexture)
        {
            List<GameObject> spawnlist = new List<GameObject>();
            Random r = new Random();
            while (spawnlist.Count <= i)
            {
                GameObject monster = new GameObject();
                monster.Position = new Vector2(r.Next(0, currentMap.Width * currentMap.TileWidth), r.Next(0, currentMap.Height * currentMap.TileHeight));
                monster.Texture = monstertexture[0];
                if (CollisionFree(monster))
                {
                    var swordMonster = new GameObject(false, false)
                    {
                        Texture = swordTexture
                    };

                    swordMonster.AddBehaviour("WeaponBehaviour", new WeaponBehaviour()
                    {
                        Wielder = monster
                    });

                    FOVBehavior FOV = new FOVBehavior(gameObjects);
                    monster.AddBehaviour("FOVBehavior", FOV);
                    monster.AddBehaviour("MovementBehaviour", new MovementBehaviour());
                    monster.AddBehaviour("MonsterAttack", new MonsterAttack(target));
                    monster.AddBehaviour("AttackBehaviour", new AttackBehaviour(swordMonster));
                    monster.AddBehaviour("StatBehaviour", new StatBehaviour(50, 100, 0.1f));
                    monster.AddBehaviour("ChaseBehaviour", new ChaseBehaviour(300, target, monster.Position));
                    monster.AddBehaviour("HitBehaviour", new HitBehaviour(swordMonster));
                    monster.AddBehaviour("DropItem", new DropItem(target));

                    GameObject Helmet = new GameObject();
                    Helmet.Texture = helmet[r.Next(0, helmet.Count)];
                    ChildBehaviour helmetbehaviour = new ChildBehaviour();
                    helmetbehaviour.Parent = monster;
                    Helmet.AddBehaviour("ChildBehaviour", helmetbehaviour);
                    spawnlist.Add(monster);
                    monster.AddBehaviour("BondBehaviour", new BondBehaviour(swordMonster, Helmet));

                    gameObjects.Add(monster);
                    gameObjects.Add(Helmet);
                    gameObjects.Add(swordMonster);
                }
            }
        }
コード例 #8
0
ファイル: Game1.cs プロジェクト: dat-genius/Game0815
        public void LoadFinalBoss(GameObject target, Texture2D bosstexture, List<Texture2D> movementList, Texture2D swordtexture)
        {
            GameObject FinalBoss = new GameObject()
            {
                Position = new Vector2(272, 464),
                Texture = movementList[0]
            };
            var helmet = new GameObject(true, false)
            {
                Texture = bosstexture
            };
            helmet.AddBehaviour("ChildBehaviour", new ChildBehaviour()
            {
                Parent = FinalBoss
            });
            var bossSword = new GameObject(false, false)
            {
                Texture = swordtexture
            };
            bossSword.AddBehaviour("WeaponBehaviour", new WeaponBehaviour()
            {
                Wielder = FinalBoss
            });

            FinalBoss.AddBehaviour("MovementBehaviour", new MovementBehaviour(movementList));
            FinalBoss.AddBehaviour("ChaseBehaviour", new ChaseBehaviour(300, target, FinalBoss.Position, true));
            FinalBoss.AddBehaviour("MonsterAttack", new MonsterAttack(target, true));
            FinalBoss.AddBehaviour("AttackBehaviour", new AttackBehaviour(bossSword));
            FinalBoss.AddBehaviour("StatBehaviour", new StatBehaviour(250, 100, 0.1f)
            {
                HealthRegenSword = true
            });
            FinalBoss.AddBehaviour("FOVBehavior", new FOVBehavior(gameObjects));
            FinalBoss.AddBehaviour("BondBehaviour", new BondBehaviour(bossSword, helmet));
            FinalBoss.AddBehaviour("HitBehaviour", new HitBehaviour(bossSword, true));

            gameObjects.Add(FinalBoss);
            gameObjects.Add(helmet);
            gameObjects.Add(bossSword);
        }
コード例 #9
0
ファイル: Game1.cs プロジェクト: dat-genius/Game0815
        public void LoadBoss4(GameObject target, Texture2D bosstexture, Texture2D swordtexture)
        {
            GameObject Boss = new GameObject()
            {
                Position = new Vector2(272, 464),
                Texture = bosstexture
            };
            var bossSword = new GameObject(false, false)
            {
                Texture = swordtexture
            };
            bossSword.AddBehaviour("WeaponBehaviour", new WeaponBehaviour()
            {
                Wielder = Boss
            });

            Boss.AddBehaviour("MovementBehaviour", new MovementBehaviour());
            Boss.AddBehaviour("ChaseBehaviour", new ChaseBehaviour(300, target, Boss.Position, true));
            Boss.AddBehaviour("MonsterAttack", new MonsterAttack(target, true));
            Boss.AddBehaviour("AttackBehaviour", new AttackBehaviour(bossSword));
            Boss.AddBehaviour("FOVBehavior", new FOVBehavior(gameObjects));
            Boss.AddBehaviour("StatBehaviour", new StatBehaviour(200, 100, 0.1f));
            Boss.AddBehaviour("BondBehaviour", new BondBehaviour(bossSword));
            Boss.AddBehaviour("HitBehaviour", new HitBehaviour(bossSword, true));

            gameObjects.Add(Boss);
            gameObjects.Add(bossSword);
        }
コード例 #10
0
ファイル: Game1.cs プロジェクト: dat-genius/Game0815
        public void LoadBoss2(GameObject target, Texture2D bosstexture, List<Texture2D> movementList, Texture2D swordtexture)
        {
            GameObject Boss2 = new GameObject()
            {
                Position = new Vector2(352, 288),
                Texture = movementList[0]
            };
            var bossSword2 = new GameObject(false, false)
            {
                Texture = swordtexture
            };
            bossSword2.AddBehaviour("WeaponBehaviour", new WeaponBehaviour()
            {
                Wielder = Boss2
            });
            var bossHelmet = new GameObject(true, false)
            {
                Texture = bosstexture
            };
            bossHelmet.AddBehaviour("ChildBehaviour", new ChildBehaviour()
            {
                Parent = Boss2
            });

            Boss2.AddBehaviour("MovementBehaviour", new MovementBehaviour());
            Boss2.AddBehaviour("ChaseBehaviour", new ChaseBehaviour(300, target, Boss2.Position, true));
            Boss2.AddBehaviour("MonsterAttack", new MonsterAttack(target, true));
            Boss2.AddBehaviour("AttackBehaviour", new AttackBehaviour(bossSword2));
            Boss2.AddBehaviour("FOVBehavior", new FOVBehavior(gameObjects));
            Boss2.AddBehaviour("StatBehaviour", new StatBehaviour(120, 100, 0.1f)
            {
                HealthRegenSword = true
            });
            Boss2.AddBehaviour("BondBehaviour", new BondBehaviour(bossSword2));
            Boss2.AddBehaviour("HitBehaviour", new HitBehaviour(bossSword2));

            gameObjects.Add(Boss2);
            gameObjects.Add(bossSword2);
            gameObjects.Add(bossHelmet);
        }
コード例 #11
0
ファイル: Game1.cs プロジェクト: dat-genius/Game0815
        public void LoadBoss1_3(GameObject target, Texture2D bosstexture, Texture2D swordtexture, int bossnmmr)
        {
            GameObject Boss = new GameObject()
            {
                Position = SetPosition(bossnmmr),
                Texture = bosstexture
            };
            var bossSword = new GameObject(false, false)
            {
                Texture = swordtexture
            };
            bossSword.AddBehaviour("WeaponBehaviour", new WeaponBehaviour()
            {
                Wielder = Boss
            });

            Boss.AddBehaviour("MovementBehaviour", new MovementBehaviour());
            Boss.AddBehaviour("ChaseBehaviour", new ChaseBehaviour(300, target, Boss.Position, true));
            Boss.AddBehaviour("MonsterAttack", new MonsterAttack(target, true));
            Boss.AddBehaviour("AttackBehaviour", new AttackBehaviour(bossSword));
            Boss.AddBehaviour("StatBehaviour", new StatBehaviour(50 + 50 * bossnmmr, 100, 0.1f));
            Boss.AddBehaviour("BondBehaviour", new BondBehaviour(bossSword));
            Boss.AddBehaviour("HitBehaviour", new HitBehaviour(bossSword));

            gameObjects.Add(Boss);
            gameObjects.Add(bossSword);
        }
コード例 #12
0
        public void TestFindTrue()
        {
            GameObject testObject = new GameObject();
            FOVBehavior testFOV = new FOVBehavior(gameObjects);
            testFOV.ViewDistance = 300;
            testObject.AddBehaviour("FOVBehaviour", testFOV);
            testObject.Rotation = 0;
            testObject.Position = new Vector2(100, 100);
            GameObject testPlayerObject = new GameObject();
            testPlayerObject.AddBehaviour("InputMovementBehaviour",new InputMovementBehaviour(5, new FollowCamera()));
            testPlayerObject.Position = new Vector2(100, 0);

            gameObjects.Add(testObject);
            gameObjects.Add(testPlayerObject);
            testObject.CollidingGameObjects = gameObjects;
            testObject.OnUpdate(time);
            Assert.IsTrue(testFOV.DetectPlayer());
        }
コード例 #13
0
 public void TestFindNoPlayer()
 {
     GameObject testObject = new GameObject();
     FOVBehavior testFOV = new FOVBehavior(gameObjects);
     testObject.AddBehaviour("FOVBehaviour", testFOV);
     testObject.Rotation = 0;
     testObject.Position = new Vector2(100, 100);
     gameObjects.Add(testObject);
     testObject.CollidingGameObjects = gameObjects;
     testObject.OnUpdate(time);
     Assert.IsFalse(testFOV.DetectPlayer());
 }