Пример #1
0
        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);
        }
Пример #2
0
 public AttackBehaviour(GameObject sword)
 {
     Sword = sword;
     timeUntilUsage = TimeSpan.FromMilliseconds(0);
     if (Sword.HasBehaviourOfType("WeaponBehaviour"))
         BehaviourSword = Sword.GetBehaviourOfType("WeaponBehaviour");
 }
Пример #3
0
        public void initialize()
        {
            player = new GameObject();
            player.AddBehaviour("StatBehaviour",new StatBehaviour(100, 100, 1));

            Stats = player.GetBehaviourOfType("StatBehaviour") as StatBehaviour;
        }
Пример #4
0
        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);
        }
Пример #5
0
 public ChaseBehaviour(float radius, GameObject target, Vector2 spawn , bool _boss = false)
 {
     Radius = radius;
     Target = target;
     SpawnPoint = spawn;
     boss = _boss;
 }
Пример #6
0
 public bool CheckForPLayers(List<GameObject> visibleObjects)
 {
     foreach (GameObject objectInList in visibleObjects)
     {
         if (objectInList.HasBehaviourOfType("InputMovementBehaviour"))
         {
             player = objectInList;
             return true;
         }
     }
     return false;
 }
Пример #7
0
        public HUDBehaviour(Texture2D textureHealth, Texture2D textureTestos, SpriteFont text, GameObject gameObject)
        {
            TextureHealth = textureHealth;
            TextureTestos = textureTestos;
            Text = text;

            GameObject = gameObject;
            Stats = gameObject.GetBehaviourOfType("StatBehaviour") as StatBehaviour;

            PositionHealth = new Vector2(5, 5);
            PositionTestos = new Vector2(5, 30);
        }
Пример #8
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);
        }
Пример #9
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);
 }
Пример #10
0
        /// <summary>
        /// Takes a moving object and determines the new position for it based on
        /// potential collisions in the world with other objects.
        /// </summary>
        /// <param name="gameObject">The game object</param>
        /// <param name="displacement">The movement</param>
        /// <returns>The new position</returns>
        public static bool HasObjectCollision(GameObject gameObject, Vector2 displacement)
        {
            var oldPosition = new Vector2(gameObject.Position.X, gameObject.Position.Y);
            var newPosition = oldPosition + displacement;
            var thisRectangle = new Rectangle((int)newPosition.X, (int)newPosition.Y, gameObject.Size.X, gameObject.Size.Y);

            var isColliding = false;
            foreach (var otherObject in gameObjects)
            {
                if (!otherObject.IsCollidable || otherObject == gameObject)
                    continue;

                var otherRectangle = new Rectangle((int)otherObject.Position.X, (int)otherObject.Position.Y,
                        otherObject.Size.X, otherObject.Size.Y);

                if (thisRectangle.Intersects(otherRectangle))
                {
                    return true;
                }
            }
            return false;
        }
Пример #11
0
 public BondBehaviour(GameObject sword)
 {
     Sword = sword;
     HasHelmet = false;
 }
Пример #12
0
 public BondBehaviour(GameObject sword, GameObject helmet)
 {
     Sword = sword;
     Helmet = helmet;
     HasHelmet = true;
 }
Пример #13
0
 public DropItem(GameObject player)
 {
     GameObject = player;
     behaviourStat = GameObject.GetBehaviourOfType("StatBehaviour") as StatBehaviour;
 }
Пример #14
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));
        }
Пример #15
0
 private bool CollisionFree(GameObject botsing)
 {
     //if (HasMapCollision(botsing, new Vector2(0, 0)))
     //{
     //    return false;
     //}
     if (HasObjectCollision(botsing, new Vector2(0, 0)))
     {
         return false;
     }
     return true;
 }
Пример #16
0
 public ShieldBehaviour(Texture2D _shield)
 {
     shield = new GameObject(false, false);
     shield.Texture = _shield;
 }
Пример #17
0
 private void CheckForBossAttack(GameObject sword)
 {
     if (player)
     {
         if (sword.Texture == Boss1Swordtexture)
         {
             behaviourStats = GameObject.GetBehaviourOfType("StatBehaviour");
             (behaviourStats as StatBehaviour).TestosDown(1);
         }
     }
 }
Пример #18
0
 public HitBehaviour(GameObject sword, Texture2D boss1SwordTexture)
 {
     OwnSword = sword;
     Boss1Swordtexture = boss1SwordTexture;
     player = true;
 }
Пример #19
0
        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);
        }
Пример #20
0
        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);
        }
Пример #21
0
        /// <summary>
        /// Takes a moving object and determines the new position for it based on
        /// potential collisions in the world with the map.
        /// </summary>
        /// <param name="gameObject">The game object</param>
        /// <param name="displacement">The movement</param>
        /// <returns>The new position</returns>
        /*public static bool HasMapCollision(GameObject gameObject, Vector2 displacement)
        {
            var oldPosition = new Vector2(gameObject.Position.X, gameObject.Position.Y);
            var newPosition = oldPosition + displacement;
            var thisRectangle = new Rectangle((int)newPosition.X, (int)newPosition.Y, gameObject.Size.X, gameObject.Size.Y);

            var isColliding = false;
            foreach (var objectGroup in tilemap.ObjectGroups)
            {
                foreach (var otherObject in objectGroup.Objects)
                {
                    var otherRectangle = new Rectangle(
                            otherObject.X,
                            otherObject.Y,
                            otherObject.Width,
                            otherObject.Height);

                    if (thisRectangle.Intersects(otherRectangle))
                    {
                        return true;
                    }
                }
            }
            return false;
        }*/
        public static Vector2 ResolveWorldCollision(GameObject gameObject, Vector2 displacement)
        {
            if (!HasObjectCollision(gameObject, displacement) /*&& !HasMapCollision(gameObject, displacement)*/)
            {
                return gameObject.Position + displacement;
            }
            return gameObject.Position;
        }
Пример #22
0
 public MonsterAttack(GameObject target, bool boss = false)
 {
     Target = target;
     isBoss = boss;
     CalculateRange();
 }
Пример #23
0
        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);
        }
Пример #24
0
 public void initialize()
 {
     time = new GameTime();
     gameObjects = new List<GameObject>();
     testObject = new GameObject();
 }
Пример #25
0
 private void hit(GameObject other)
 {
     if (!defend)
     {
         (behaviourStats as StatBehaviour).HealthDown(10);
         CheckForBossAttack(other);
         hitCount++;
     }
 }
Пример #26
0
        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);
        }
Пример #27
0
 public HitBehaviour(GameObject sword, bool teleport = false)
 {
     OwnSword = sword;
     player = false;
     canTeleport = teleport;
 }
Пример #28
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);
                }
            }
        }
Пример #29
0
 private void CheckTeleport()
 {
     GameObject player = new GameObject();
     foreach (GameObject potentialPlayer in gameObjects)
     {
         if (potentialPlayer.HasBehaviourOfType("InputMovementBehaviour"))
         {
             player = potentialPlayer;
             break;
         }
     }
     Rectangle playerRect = new Rectangle((int)player.Position.X, (int)player.Position.Y, player.Size.X, player.Size.Y);
     foreach (GameObject teleportblock in portBlocks)
     {
         Rectangle portblockRect = new Rectangle((int)teleportblock.Position.X, (int)teleportblock.Position.Y, teleportblock.Size.X, teleportblock.Size.Y);
         if (playerRect.Intersects(portblockRect))
         {
             teleportblock.OnMessage(new CollisionEnterMessage(player));
             break;
         }
     }
 }
Пример #30
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());
        }