Пример #1
0
    // ロード開始
    public void Load(int stage)
    {
        TMXLoader tmx = new TMXLoader();

        // ファイルパスを作成
        string path = string.Format("Levels/{0:D3}", stage);

        tmx.Load(path);

        // 0番目のレイヤーに情報を取得する
        Layer2D layer = tmx.GetLayer(0);

        // タイルの配置
        for (int j = 0; j < layer.Height; j++)
        {
            for (int i = 0; i < layer.Width; i++)
            {
                // 座標を指定してレイヤーの値を取得
                int   v = layer.Get(i, j);
                float x = GetChipX(i);
                float y = GetChipY(j);

                switch (v)
                {
                case CHIP_PLAYER:
                {
                    // プレイヤを移動させる
                    GameObject obj    = GameObject.Find("Player") as GameObject;
                    Player     player = obj.GetComponent <Player>();
                    player.SetPosition(x, y);
                }
                break;

                case CHIP_WALL:
                    // 壁を作成
                    Wall.Add(x, y);
                    break;

                case CHIP_SPIKE:
                    // トゲを生成
                    Spike.Add(x, y);
                    break;

                case CHIP_FLOOR_MOVE:
                    // 移動床を作成
                    FloorMove.Add(x, y);
                    break;

                case CHIP_GOAL:
                {
                    // ゴールを移動させる
                    GameObject obj  = GameObject.Find("Goal") as GameObject;
                    Goal       goal = obj.GetComponent <Goal>();
                    goal.SetPosition(x, y);
                }
                break;
                }
            }
        }
    }
Пример #2
0
    public static FloorMove Add(float x, float y)
    {
        FloorMove floor = parent.Add(x, y);

        floor.Init();
        return(floor);
    }
Пример #3
0
    public void Load(int stage)
    {
        TMXLoader tmx  = new TMXLoader();
        string    path = string.Format("Levels/{0:D3}", stage);

        tmx.Load(path);
        Layer2D layer = tmx.GetLayer(0);

        //Debug.Log ("幅:" + layer.Width);
        //Debug.Log ("高:" + layer.Height);
        for (int j = 0; j < layer.Height; j++)
        {
            for (int i = 0; i < layer.Width; i++)
            {
                int   v = layer.Get(i, j);
                float x = GetChipX(i);
                float y = GetChipY(j);
                switch (v)
                {
                case CHIP_PLAYER:
                {
                    GameObject obj    = GameObject.Find("Player") as GameObject;
                    Player     player = obj.GetComponent <Player> ();
                    player.SetPosition(x, y);
                }
                break;

                case CHIP_WALL:
                    Wall.Add(x, y);
                    break;

                case CHIP_SPIKE:
                    Spike.Add(x, y);
                    break;

                case CHIP_FLOOR_MOVE:
                    FloorMove.Add(x, y);
                    break;

                case CHIP_GOAL:
                {
                    GameObject obj  = GameObject.Find("Goal") as GameObject;
                    Goal       goal = obj.GetComponent <Goal>();
                    goal.SetPosition(x, y);
                }
                break;
                }
            }
        }
    }
Пример #4
0
            private void UnArchiveSpecials(World world)
            {
                var thinkers = world.Thinkers;
                var sa       = world.SectorAction;

                // Read in saved thinkers.
                while (true)
                {
                    var tclass = (SpecialClass)this.reader.ReadByte();

                    switch (tclass)
                    {
                    case SpecialClass.EndSpecials:
                        // End of list.
                        return;

                    case SpecialClass.Ceiling:
                        this.PadPointer();
                        var ceiling = new CeilingMove(world);
                        this.reader.BaseStream.Position += 8;
                        ceiling.ThinkerState             = LoadGame.GetThinkerState(this.reader.ReadInt32());
                        ceiling.Type               = (CeilingMoveType)this.reader.ReadInt32();
                        ceiling.Sector             = world.Map.Sectors[this.reader.ReadInt32()];
                        ceiling.Sector.SpecialData = ceiling;
                        ceiling.BottomHeight       = new Fixed(this.reader.ReadInt32());
                        ceiling.TopHeight          = new Fixed(this.reader.ReadInt32());
                        ceiling.Speed              = new Fixed(this.reader.ReadInt32());
                        ceiling.Crush              = this.reader.ReadInt32() != 0;
                        ceiling.Direction          = this.reader.ReadInt32();
                        ceiling.Tag          = this.reader.ReadInt32();
                        ceiling.OldDirection = this.reader.ReadInt32();

                        thinkers.Add(ceiling);
                        sa.AddActiveCeiling(ceiling);

                        break;

                    case SpecialClass.Door:
                        this.PadPointer();
                        var door = new VerticalDoor(world);
                        this.reader.BaseStream.Position += 8;
                        door.ThinkerState       = LoadGame.GetThinkerState(this.reader.ReadInt32());
                        door.Type               = (VerticalDoorType)this.reader.ReadInt32();
                        door.Sector             = world.Map.Sectors[this.reader.ReadInt32()];
                        door.Sector.SpecialData = door;
                        door.TopHeight          = new Fixed(this.reader.ReadInt32());
                        door.Speed              = new Fixed(this.reader.ReadInt32());
                        door.Direction          = this.reader.ReadInt32();
                        door.TopWait            = this.reader.ReadInt32();
                        door.TopCountDown       = this.reader.ReadInt32();

                        thinkers.Add(door);

                        break;

                    case SpecialClass.Floor:
                        this.PadPointer();
                        var floor = new FloorMove(world);
                        this.reader.BaseStream.Position += 8;
                        floor.ThinkerState       = LoadGame.GetThinkerState(this.reader.ReadInt32());
                        floor.Type               = (FloorMoveType)this.reader.ReadInt32();
                        floor.Crush              = this.reader.ReadInt32() != 0;
                        floor.Sector             = world.Map.Sectors[this.reader.ReadInt32()];
                        floor.Sector.SpecialData = floor;
                        floor.Direction          = this.reader.ReadInt32();
                        floor.NewSpecial         = (SectorSpecial)this.reader.ReadInt32();
                        floor.Texture            = this.reader.ReadInt32();
                        floor.FloorDestHeight    = new Fixed(this.reader.ReadInt32());
                        floor.Speed              = new Fixed(this.reader.ReadInt32());

                        thinkers.Add(floor);

                        break;

                    case SpecialClass.Plat:
                        this.PadPointer();
                        var plat = new Platform(world);
                        this.reader.BaseStream.Position += 8;
                        plat.ThinkerState       = LoadGame.GetThinkerState(this.reader.ReadInt32());
                        plat.Sector             = world.Map.Sectors[this.reader.ReadInt32()];
                        plat.Sector.SpecialData = plat;
                        plat.Speed     = new Fixed(this.reader.ReadInt32());
                        plat.Low       = new Fixed(this.reader.ReadInt32());
                        plat.High      = new Fixed(this.reader.ReadInt32());
                        plat.Wait      = this.reader.ReadInt32();
                        plat.Count     = this.reader.ReadInt32();
                        plat.Status    = (PlatformState)this.reader.ReadInt32();
                        plat.OldStatus = (PlatformState)this.reader.ReadInt32();
                        plat.Crush     = this.reader.ReadInt32() != 0;
                        plat.Tag       = this.reader.ReadInt32();
                        plat.Type      = (PlatformType)this.reader.ReadInt32();

                        thinkers.Add(plat);
                        sa.AddActivePlatform(plat);

                        break;

                    case SpecialClass.Flash:
                        this.PadPointer();
                        var flash = new LightFlash(world);
                        this.reader.BaseStream.Position += 8;
                        flash.ThinkerState = LoadGame.GetThinkerState(this.reader.ReadInt32());
                        flash.Sector       = world.Map.Sectors[this.reader.ReadInt32()];
                        flash.Count        = this.reader.ReadInt32();
                        flash.MaxLight     = this.reader.ReadInt32();
                        flash.MinLight     = this.reader.ReadInt32();
                        flash.MaxTime      = this.reader.ReadInt32();
                        flash.MinTime      = this.reader.ReadInt32();

                        thinkers.Add(flash);

                        break;

                    case SpecialClass.Strobe:
                        this.PadPointer();
                        var strobe = new StrobeFlash(world);
                        this.reader.BaseStream.Position += 8;
                        strobe.ThinkerState              = LoadGame.GetThinkerState(this.reader.ReadInt32());
                        strobe.Sector     = world.Map.Sectors[this.reader.ReadInt32()];
                        strobe.Count      = this.reader.ReadInt32();
                        strobe.MinLight   = this.reader.ReadInt32();
                        strobe.MaxLight   = this.reader.ReadInt32();
                        strobe.DarkTime   = this.reader.ReadInt32();
                        strobe.BrightTime = this.reader.ReadInt32();

                        thinkers.Add(strobe);

                        break;

                    case SpecialClass.Glow:
                        this.PadPointer();
                        var glow = new GlowingLight(world);
                        this.reader.BaseStream.Position += 8;
                        glow.ThinkerState = LoadGame.GetThinkerState(this.reader.ReadInt32());
                        glow.Sector       = world.Map.Sectors[this.reader.ReadInt32()];
                        glow.MinLight     = this.reader.ReadInt32();
                        glow.MaxLight     = this.reader.ReadInt32();
                        glow.Direction    = this.reader.ReadInt32();

                        thinkers.Add(glow);

                        break;

                    default:
                        throw new Exception("Unknown special in savegame!");
                    }
                }
            }