Exemplo n.º 1
0
    IEnumerator Loading(AsyncOperation progress, LoadingScreenBehaviour ls)
    {
        ls.Begin();
        LoadingState state = ls.state;

        while (!progress.isDone)
        {
            state.Callback("LoadingScene", progress.progress);
            yield return(null);
        }

        List <Action> doneListeners = new List <Action>();

        var initializer = GetInitializer();

        if (initializer != null)
        {
            state.Callback("InitializingScene", 0);
            yield return(null);

            AsyncProcessor processor = new AsyncProcessor(this);
            yield return(initializer.Initialize(processor, doneListeners.Add, state));

            yield return(new WaitUntil(processor.allDone));
        }

        ls.End();
        Done();
        foreach (var dl in doneListeners)
        {
            dl.Invoke();
        }
    }
Exemplo n.º 2
0
    protected override IEnumerator Initialize(AsyncProcessor asyncProcessor, LoadingState state)
    {
        AP = asyncProcessor;

        state.Callback("PreparingBattle", 0);
        yield return(null);

        config = (BattleConfig)GameState.sharedData["BattleConfig"];

        playerCamera.GetComponentInChildren <Camera>(true).farClipPlane = 10000000;

        teams = new ShipTeam[] {
            new ShipTeam(0, new IBattleGoal[0], GoalReached),
            new ShipTeam(1, new IBattleGoal[0], GoalReached),
        };

        switch (config.type)
        {
        case BattleType.DeathMatch:
            GenerateDeathMatch();
            break;

        case BattleType.BattleForTheStar:
            GenerateBatlleForTheSun();
            break;

        case BattleType.Escort:
            GenerateEscort();
            break;
        }

        _updaters.Add(new MyMonoBehaviourUpdater(otherObjects));
        _updaters.Add(new LastUpdateShipUpdater());

        base.SetBattle(
            center,
            ships,
            teams,
            _updaters
            );

        base.navigation = navigation;

        AP = null;
        state.Callback("EndLoading", 1f);
    }