Exemple #1
0
        private void OnDoorOpen(Door p_door)
        {
            World.s_saveState.AddDoorToRoom(p_door.name, World.mapName);
            if (p_door.doorSide == 0)
            {
                Layer __layer = RootObjectUtil.GetLayerByName(_rootObject, "TileMap");
                __layer.data[p_door.tileToOpen] = 417;
                __layer = RootObjectUtil.GetLayerByName(_rootObject, "CollisionMask");
                __layer.data[p_door.tileToOpen] = 0;
                _collider.ChangeAABBMaskType(p_door.tileToOpen, CollisionMask.NONE);
            }
            else if (p_door.doorSide == 1)
            {
                Layer __layer = RootObjectUtil.GetLayerByName(_rootObject, "TileMap");
                __layer.data[p_door.tileToOpen]     = 397;
                __layer.data[p_door.tileToOpen + 1] = 398;
                __layer = RootObjectUtil.GetLayerByName(_rootObject, "CollisionMask");
                __layer.data[p_door.tileToOpen]     = 8;
                __layer.data[p_door.tileToOpen + 1] = 9;
                _collider.ChangeAABBMaskType(p_door.tileToOpen, CollisionMask.HALF_LEFT);
                _collider.ChangeAABBMaskType(p_door.tileToOpen + 1, CollisionMask.HALF_RIGHT);
            }
            else if (p_door.doorSide == 2)
            {
                Layer __layer = RootObjectUtil.GetLayerByName(_rootObject, "TileMap");
                __layer.data[p_door.tileToOpen] = 387;
                __layer = RootObjectUtil.GetLayerByName(_rootObject, "CollisionMask");
                __layer.data[p_door.tileToOpen] = 0;
                _collider.ChangeAABBMaskType(p_door.tileToOpen, CollisionMask.NONE);
            }

            SoundManager.instance.Play(SoundType.PLAYER_HITTED);
        }
Exemple #2
0
        public Scene(RootObject p_rootObject, Player p_player, params Entity[] p_entities)
        {
            tag         = "Scene";
            player      = p_player;
            _rootObject = p_rootObject;
            _collider   = new Collider(p_rootObject);

            entities         = new List <Entity>(p_entities);
            entitiesToRemove = new List <Entity>();

            _playerWeaponManager = new PlayerWeaponManager(p_player);
            _playerWeaponManager.OnLinkSwordDie += _playerWeaponManager_OnLinkSwordDie;
            _enemyWeaponManager = new EnemyWeaponManager();

            SetPortals(RootObjectUtil.GetLayerByName(p_rootObject, "Portals"));
            SetItems(RootObjectUtil.GetLayerByName(p_rootObject, "Items"));
            SetEnemies(RootObjectUtil.GetLayerByName(p_rootObject, "Enemies"));
            SetDoors(RootObjectUtil.GetLayerByName(p_rootObject, "Doors"));
            entities.Add(player);

            portals.ForEach(p_portal => entities.Add(p_portal));
            _enemies.ForEach(p_enemy => entities.Add(p_enemy));

            if (_enemies.Count == 0)
            {
                AllEnemiesDead();
            }

            _worldTileSet  = Main.s_game.Content.Load <Texture2D>("TileSet_World");
            _collisionMask = Main.s_game.Content.Load <Texture2D>("TileSet_CollisionMask");

            SoundManager.instance.Play(World.IsOpenWorld() ? SoundType.OVERWORLD : SoundType.DUNGEON, true);
            SoundManager.instance.StopAndDispose(World.IsOpenWorld() ? SoundType.DUNGEON : SoundType.OVERWORLD);
        }
Exemple #3
0
        public Collider(RootObject p_rootObject)
        {
            _collisionMasks = RootObjectUtil.GetLayerByName(p_rootObject, "CollisionMask");

            _collisions = new List <AABB>();

            var __x = 0;
            var __y = 0;

            for (var i = 0; i < _collisionMasks.data.Count; i++)
            {
                var __mask     = (CollisionMask)_collisionMasks.data[i];
                var __position = new Vector2(__x, __y);
                var __aabb     = new AABB(__position, __position + new Vector2(16), __mask);

                _collisions.Add(__aabb);

                __x += 16;

                if (__x == 256)
                {
                    __x  = 0;
                    __y += 16;
                }
            }
        }
Exemple #4
0
        public override void Draw(SpriteBatch p_spriteBatch)
        {
            DrawTileMap(RootObjectUtil.GetLayerByName(_rootObject, "TileMap"), p_spriteBatch, _worldTileSet, 1f);

            foreach (var __e in entities)
            {
                if (__e.state != State.DISABLED)
                {
                    __e.Draw(p_spriteBatch);
                }
            }

            _playerWeaponManager.Draw(p_spriteBatch);
            _enemyWeaponManager.Draw(p_spriteBatch);
            base.Draw(p_spriteBatch);
        }
Exemple #5
0
        public override void DebugDraw(SpriteBatch p_spriteBatch)
        {
            DrawTileMap(RootObjectUtil.GetLayerByName(_rootObject, "CollisionMask"), p_spriteBatch, _collisionMask, 0.35f);
            DrawCollisionMap(p_spriteBatch);

            foreach (Entity __e in entities)
            {
                if (__e.state != State.DISABLED)
                {
                    __e.DebugDraw(p_spriteBatch);
                }
            }

            _playerWeaponManager.DebugDraw(p_spriteBatch);
            _enemyWeaponManager.DebugDraw(p_spriteBatch);

            base.DebugDraw(p_spriteBatch);
        }
Exemple #6
0
 public void DrawForeground(SpriteBatch p_spriteBatch)
 {
     DrawTileMap(RootObjectUtil.GetLayerByName(_rootObject, "TileMapForeground"), p_spriteBatch, _worldTileSet, 1f);
 }