Example #1
0
    public void InstantiateObjects(int step, Action <bool> onTouch)
    {
        _state = State.StartStep;
        _shuffleElapsedTime = 0.0f;
        _hideElapsedTime    = 0.0f;

        // 現在のステップの正解id.
        MasterItemStep stepMaster = MasterStepHolder.Instance().GetOneOrFail(LevelManager.Instance.Level, step);
        int            answerId   = stepMaster.AnswerId;

        // タッチ時コールバック
        Action <Fukidashi> onTouchCallBack = (fukidashi) => {
            if (fukidashi.HasTouched)
            {
                return;
            }

            // 正否を判定.
            bool isSuccess = (fukidashi.AnswerId == answerId);

            // 正否に応じた吹き出しアニメーションetcを実行.
            if (isSuccess)
            {
                fukidashi.Success();
            }
            else
            {
                fukidashi.Fail();
            }

            // 現在のステップの吹き出しは削除.
            ClearObjects(fukidashi);

            // 呼び出し先のコールバックを実行.
            onTouch(isSuccess);
        };

        // 吹き出しを生成.
        List <MasterItemFukidashi> masterList = MasterFukidashiHolder.Instance().GetList(
            (item) => { return(item.Stage == LevelManager.Instance.Level && item.Step == step); }
            );

        foreach (var master in masterList)
        {
            Fukidashi fukidashi = InstantiateObject(master, onTouchCallBack);
            _fukidashiList.Add(fukidashi);
        }

        // 吹き出しの座標を、ランダム生成版で上書く.
        if (_useRandomPoint)
        {
            foreach (var fukidashi in _fukidashiList)
            {
                fukidashi.GetComponent <RectTransform>().anchoredPosition = _randomPointsGenerator.PickPointRandomly();
            }
            _randomPointsGenerator.Reset();
        }
    }
Example #2
0
    public void Awake()
    {
        Debug.Assert(_fukidashisController != null);
        Debug.Assert(_animCharaController != null);
        Debug.Assert(_gameResultPanel != null);
        Debug.Assert(_textStepTitle != null);
        Debug.Assert(_timerWidget != null);
        Debug.Assert(_currentStepText != null);
        Debug.Assert(_stageLabelList.Count == LevelManager.Instance.MaxLevel);

        _masterStepHolder = MasterStepHolder.Instance();

        _stageLevel  = LevelManager.Instance.Level;
        _currentStep = 1;
        _maxStep     = _masterStepHolder.GetMaxStep(_stageLevel);
    }
Example #3
0
    // TODO: 抽象クラスにまとめるために、ジェネリックな型を指定できるようにする.
    public static MasterStepHolder Instance()
    {
        if (_instance != null)
        {
            return(_instance);
        }

        var gameObject = new GameObject("MasterStepHolder");

        _instance = gameObject.AddComponent <MasterStepHolder>();
        _instance.ReadMasterDataFromFile();

        DontDestroyOnLoad(_instance);

        return(_instance);
    }