Exemple #1
0
        public override void Update(List <BaseEntity> entities)
        {
            BaseEntity player = Scene.GetPlayer();

            if (player.X > 1800)
            {
                Scene.Camera = new Point(-40, 180);
                player.X     = 0;

                var doubleJump = GetDoubleJump();

                Scene.AddEntityToScene(doubleJump);
            }

            List <BaseEntity> obstacles = Scene.GetObstacles();
            List <BaseEntity> platforms = Scene.GetPlatforms();

            bool hitPlatform = DetectPlatformCollisions(player, platforms);
            bool hitObstacle = DetectObstacleCollisions(player, obstacles);

            if (!(hitPlatform || hitObstacle))
            {
                FreeFall();
            }

            player.PreviousY = player.Y;
        }
Exemple #2
0
        void StartTest()
        {
            GameObject sceneRoot = new GameObject("SceneRoot");
            scene = sceneRoot.AddComponent<Scene>();
            scene.Init();
            scene.Load("Settings/test.map");
            scene.StartScene();

            SceneManager.Init();
            SceneManager.Instance.SwitchTo(scene);

            float mapWidth = scene.Map.Width;
            float mapHeight = scene.Map.Height;
            for (int i = 0; i < 100; ++i)
            {
                MonsterEntity monsterEntity = scene.CreateMonsterEntity(0);
                scene.AddEntityToScene(monsterEntity, new Vector3(Random.value * mapWidth, Random.value * mapHeight, 0));
            }

            tower = scene.CreateTowerEntity(0);
            tower.ShowDebugDraw = true;
            scene.AddEntityToScene(tower, new Vector3(mapWidth / 2, mapHeight / 2, 0));

            towerAtk = tower.AttrComp.AtkBase;
            towerAtkSpeed = tower.AttrComp.AtkSpeedBase;
            towerAtkRange = tower.AttrComp.AtkRangeBase;
        }
        public void LoadEntities()
        {
            for (var i = -6; i < 100; i++)
            {
                var platformEntity  = new BaseEntity(SceneManager, "Platform" + i.ToString(), i * 32, 480);
                var platformRender  = new RenderComponent(platformEntity, "Platform", 32, 32);
                var platformPhysics = new PhysicsComponent(platformEntity, 32, 32);

                Scene.AddEntityToScene(platformEntity);
            }



            var obstacle1        = new BaseEntity(SceneManager, "Obstacle1", 1080, 480 - 32);
            var obstacle1render  = new RenderComponent(obstacle1, "atpButtHash", 32, 32);
            var obstacle1physics = new PhysicsComponent(obstacle1, 32, 32);

            Scene.AddEntityToScene(obstacle1);

            var obstacle2        = new BaseEntity(SceneManager, "Obstacle2", 1080, 480 - 64);
            var obstacle2render  = new RenderComponent(obstacle2, "atpButtHash", 32, 32);
            var obstacle2physics = new PhysicsComponent(obstacle2, 32, 32);

            Scene.AddEntityToScene(obstacle2);

            var autoJump1        = new BaseEntity(SceneManager, "AutoJump1", 1032, 480 - 32);
            var autoJump1physics = new PhysicsComponent(autoJump1, 32, 32);

            Scene.AddEntityToScene(autoJump1);

            for (var i = 0; i < 6; i++)
            {
                var obstacle        = new BaseEntity(SceneManager, "Obstacle" + (i + 3).ToString(), 1700, 480 - 32 * i);
                var obstacleRender  = new RenderComponent(obstacle, "atpButtHash", 32, 32);
                var obstaclePhysics = new PhysicsComponent(obstacle, 32, 32);

                Scene.AddEntityToScene(obstacle);
            }

            var autoJump2 = new BaseEntity(SceneManager, "AutoJump2", 1604, 480 - 32);
            //var autoJump2render = new RenderComponent(autoJump2, "atpGood", 32, 32);
            var autoJump2physics = new PhysicsComponent(autoJump2, 32, 32);

            Scene.AddEntityToScene(autoJump2);

            var autoJump3 = new BaseEntity(SceneManager, "AutoJump3", 1670, 480 - 115);
            //var autoJump3render = new RenderComponent(autoJump3, "atpGood", 32, 32);
            var autoJump3physics = new PhysicsComponent(autoJump3, 32, 32);

            Scene.AddEntityToScene(autoJump3);

            var doubleJump1        = new BaseEntity(SceneManager, "DoubleJump1", 1660, 480 - 80 - 64);
            var doubleJump1render  = new RenderComponent(doubleJump1, "atpSolid", 32, 32);
            var doubleJump1physics = new PhysicsComponent(doubleJump1, 32, 32);

            Scene.AddEntityToScene(doubleJump1);
        }
        protected override void Initialize()
        {
            var player = BuildPlayer(PLAYERSTARTX, PLAYERSTARTY);

            Scene.AddEntityToScene(player);

            LoadEntities();

            base.Initialize();
        }
Exemple #5
0
        protected override void Initialize()
        {
            var player = BuildPlayer(PLAYERSTARTX, PLAYERSTARTY);

            Scene.AddEntityToScene(player);

            //var obstacles = BuildObstacles();

            TiledData level = Parse(LevelName);

            var objectLayer = level.layers.FirstOrDefault(n => n.name == "Object Layer 1");
            var objects     = objectLayer.objects;

            var obstacles = objects.Where(n => n.gid == 15);
            var platforms = objects.Where(n => n.gid == 5);
            //var platforms = new List<TiledObject>();
            var doubleJumps = objects.Where(n => n.gid == 9);

            var i = 0;

            foreach (var obstacle in obstacles)
            {
                var obstacleEntity = new BaseEntity(SceneManager, "Obstacle" + i.ToString(), obstacle.x, obstacle.y);

                var renderComponent  = new RenderComponent(obstacleEntity, "atpButtHash", obstacle.width, obstacle.height);
                var physicsComponent = new PhysicsComponent(obstacleEntity, obstacle.width, obstacle.height);

                Scene.AddEntityToScene(obstacleEntity);

                i++;
            }

            i = 0;
            foreach (var platform in platforms)
            {
                var platformEntity = new BaseEntity(SceneManager, "Platform" + i.ToString(), platform.x, platform.y);

                var groundRender  = new RenderComponent(platformEntity, "Platform", platform.width, platform.height);
                var groundPhysics = new PhysicsComponent(platformEntity, platform.width, platform.height);

                Scene.AddEntityToScene(platformEntity);

                i++;
            }

            i = 0;
            foreach (var doubleJump in doubleJumps)
            {
                var doubleJumpEntity = new BaseEntity(SceneManager, "DoubleJump" + i.ToString(),
                                                      doubleJump.x, doubleJump.y);

                var renderComponent  = new RenderComponent(doubleJumpEntity, "atpSolid", doubleJump.width, doubleJump.height);
                var physicsComponent = new PhysicsComponent(doubleJumpEntity, doubleJump.width, doubleJump.height);

                Scene.AddEntityToScene(doubleJumpEntity);

                i++;
            }

            var physics = LoadPhysics();

            Scene.Physics = physics;

            base.Initialize();
        }
        void StartTest()
        {
            GameObject sceneRoot = new GameObject("SceneRoot");
            scene = sceneRoot.AddComponent<Scene>();
            scene.Init();
            //SceneSetting sceneSetting = new SceneSetting(true);
            //sceneSetting.Map.CellCountX = 10;
            //sceneSetting.Map.CellCountY = 10;
            //scene.Load(sceneSetting);
            scene.Load("Settings/test.map");

            float mapWidth = scene.Map.Width;
            float mapHeight = scene.Map.Height;
            position = new Vector3(mapWidth / 2, mapHeight / 2, 0);
            for (int i = 0; i < 100; ++i)
            {
                MonsterEntity monsterEntity = scene.CreateMonsterEntity(0);
                scene.AddEntityToScene(monsterEntity, new Vector3(Random.value * mapWidth, Random.value * mapHeight, 0));
            }
        }