Example #1
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);
 }
Example #2
0
        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);
                }
            }
        }
Example #3
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());
        }
Example #4
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());
 }