Beispiel #1
0
    public void OnPlayTime(int remainTime) //몬스터 리스폰을 위하여
    {
        if (remainTime <= 0)
        {
            if (gameState.Value == SGE_GameState.STAGE_START)
            {
                gameState.Value = SGE_GameState.GAME_FAIL;
            }
            return;
        }

        int startTime = stageTime - remainTime;

        if (SGGameData.Instance.inifinityMode)
        {
            startTime = int.MaxValue - remainTime;
        }

        JsonData waveInfo = SGUtils.GetJsonArrayForKey(stageJson["waveInfo"], "wave", currentWaveNum);

        if (waveInfo == null)
        {
            return;
        }

        if (float.Parse(waveInfo["starttime"].ToString()) <= startTime)
        {
            GameObject monsterPrefab = monsterPrefabs.Where(_ => _.name == waveInfo["prefab"].ToString()).FirstOrDefault();
            int        mCount        = int.Parse(waveInfo["Count"].ToString());
            float      duration      = float.Parse(waveInfo["duration"].ToString());


            spawnDis = Observable.Timer(System.TimeSpan.FromSeconds(0f), System.TimeSpan.FromSeconds(duration))
                       .Take(mCount).Subscribe(_ => {
                GameObject mon = Instantiate <GameObject>(monsterPrefab, CurrentMonsterStartPoint.position, Quaternion.identity, MonsterSpawn);
            }).AddTo(this);

            currentWaveNum += 1;
        }
    }
Beispiel #2
0
    void StageIntro()
    {
        GameStartPanel.SetActive(true);
        hero.SetMoveable(false);
        stageJson = SGUtils.GetJsonArrayForKey(JsonMapper.ToObject(stageJsonAsset.text), "stage", SceneManager.GetActiveScene().name);
        stageTime = int.Parse(stageJson["playtime"].ToString());

        if (!SGGameData.Instance.inifinityMode)
        {
            timerSlider.SetTimerText(stageTime);
        }

        for (int s = 0; s < stageJson["waveInfo"].Count; s++)
        {
            monsterCount.Value += int.Parse(stageJson["waveInfo"][s]["Count"].ToString());
        }

        monsterCount.Where(_ => _ <= 0).Subscribe(_ => {
            if (gameState.Value == SGE_GameState.STAGE_START)
            {
                gameState.Value = SGE_GameState.STAGE_CLEAR;
            }
        });
    }