Beispiel #1
0
    // 開頭故事結束,遊戲準備開始.
    public void GameReadyStart()
    {
        ShowTalkBox("按Enter建開始");
        Maze.GameStatus.ready = true;

        // 劇本.
        storyManager = new Story.StoryManager();
        Story.StoryInit.Init1(storyManager);
    }
    // Use this for initialization.
    void Start()
    {
        // [遊戲素材設定]
        GlobalAsset.controller = this;

        // 物件造型.
        Maze.Animal.SetShape(new Maze.Shape(animalShapes));
        Maze.Stone.SetSprite(stoneSprite);
        Maze.Creater.SetSprite(createrSprite);
        Maze.Food.SetSprite(foodSprite);
        Maze.Wall.SetSprite(wallSprite);

        // 技能音效.
        Maze.SkillManager.attack        = punchAudio;
        Maze.SkillManager.specialAttack = otherSkillAudio;
        Maze.SkillManager.build         = buildAudio;

        // 技能造型.
        GlobalAsset.gridSprites = gridSprites;
        GlobalAsset.attack      = attack;
        GlobalAsset.straight    = straight;
        GlobalAsset.horizon     = horizon;
        GlobalAsset.create      = create;

        // 小地圖標示.
        GlobalAsset.playerMark  = playerMark;
        GlobalAsset.createrMark = createrMark;

        // UI提示框.
        GlobalAsset.positionHint = positionHint;
        GlobalAsset.hintBox      = hintBox;
        GlobalAsset.talkBox      = talkBox;


        // [遊戲地圖設定]
        // 放幾個gridSprite就生成幾層世界.
        gameMap  = new Maze.Map3D(GlobalAsset.mapSize, GlobalAsset.mapSize, gridSprites.Length);
        sceneMap = new Maze.Map2D(gameMap);
        Maze.MazeObject.SetMaze(gameMap);

        // [劇情]
        storyManager = new Story.StoryManager();


        // 在每個平面執行動作.
        for (int layer = 0; layer < Maze.MazeObject.World.Layers; ++layer)
        {
            // 創造6個不同顏色的村莊.
            for (int i = 0; i < 6; ++i)
            {
                Maze.Point3D position = gameMap.GetRandomPointOn(layer);
                Maze.Creater creater  = new Maze.Creater(position, GlobalAsset.colors[i]);

                if (gameMap.GetAt(position).InsertObj(creater))
                {
                    GlobalAsset.creaters.Add(creater);
                    creater.FullEnergy();
                    // 在每個村莊生成3隻村民.
                    creater.createAnimals(3);
                }

                else // 這個位置已經有東西了.
                {
                    --i;
                }
            }
        }

        // clock 歸零.
        timer = 0;
    }
Beispiel #3
0
        static public void Init1(StoryManager manager)
        {
            var ready          = new State();
            var start          = new State();
            var gaming         = new State();
            var waitForRestart = new State();
            var waitForEnd     = new State();
            var end            = new State();

            ready.AddEvent(new Event(
                               () => GameStatus.ready,
                               start,
                               new StoryPlayer().AddMessage("按Enter開始遊戲")
                               ));

            start.AddEvent(new Event(
                               () => TalkBox.end,
                               gaming,
                               new ActionPlayer(
                                   () => {
                GameStatus.pause = false;
                GlobalAsset.controller.GameStart();
            }
                                   )
                               ));

            gaming
            .AddEvent(new Event(
                          () => teachMode,
                          TeachMode(gaming),
                          new ActionPlayer(
                              () => { }
                              )
                          ))
            .AddEvent(new Event(
                          () => GlobalAsset.player.IsDead && GlobalAsset.LastestAnimalOnLayerColor(Player.position.Z.value, Player.Color) == null,
                          waitForEnd,
                          new StoryPlayer().AddMessageWithAction(
                              "物種滅絕...你輸了\n按Enter鍵回主選單",
                              () => {
                GameStatus.pause = true;
                GameStatus.lose  = true;
            }
                              )
                          ))
            .AddEvent(new Event(
                          () => GlobalAsset.player.IsDead && !GameStatus.lose,
                          waitForRestart,
                          new ActionPlayer(() => {
                TalkBox.Show("你已經死了\n按Enter鍵轉生");
            }
                                           )
                          ))
            .AddEvent(new Event(
                          () => GlobalAsset.RateOfColorOn(Player.Color, Player.position.Z.value) == 1f,
                          waitForEnd,
                          new StoryPlayer().AddMessageWithAction(
                              "我方勝利\n按Enter鍵回主選單",
                              () => {
                GameStatus.pause = true;
                GameStatus.win   = true;
            }
                              )
                          ));

            waitForRestart.AddEvent(new Event(
                                        () => TalkBox.end,
                                        gaming,
                                        new ActionPlayer(
                                            () => {
                GameStatus.pause = false;
                GlobalAsset.controller.GameRestart();
            }
                                            )));

            waitForEnd.AddEvent(new Event(
                                    () => TalkBox.end,
                                    end,
                                    new ActionPlayer(
                                        () => GlobalAsset.controller.GotoStartScene()
                                        )));


            manager.currentState = ready;
        }