Пример #1
0
    private void ProcessStageData()
    {
        currTime += Time.deltaTime;

        if (state == WAVESTATE.NORMAL)
        {
            float ratio = currTime / (normalWaveTime + bigWaveTime);
            stageTimeBar.SetTimeBar(ratio);

            if (currTime >= normalWaveTime && stageData.spawnDatasInNormal.Count <= currSpawnIdx)
            {
                state        = WAVESTATE.BIG;
                currTime     = 0f;
                currSpawnIdx = 0;
                return;
            }
            else if (currSpawnIdx < stageData.spawnDatasInNormal.Count && stageData.spawnDatasInNormal[currSpawnIdx].spawnTime <= currTime)
            {
                string code     = stageData.spawnDatasInNormal[currSpawnIdx].spawnPieceCode;
                int    pieceIdx = GenericDataMgr.genericData_SO.GetPieceIdxByCode(code);
                Instantiate(
                    GenericDataMgr.genericData_SO.ChessPieces[pieceIdx].prefab,
                    spawnPositions[stageData.spawnDatasInNormal[currSpawnIdx].spawnLineIdx].position,
                    Quaternion.identity);
                currSpawnIdx++;
            }
        }
        else
        {
            float ratio = (normalWaveTime + currTime) / (normalWaveTime + bigWaveTime);
            stageTimeBar.SetTimeBar(ratio);

            if (currTime >= bigWaveTime && stageData.bigPattern.Count <= currSpawnIdx)
            {
                state        = WAVESTATE.NORMAL;
                currTime     = 0f;
                currSpawnIdx = 0;
                return;
            }
            else if (currSpawnIdx < stageData.bigPattern.Count && stageData.bigPattern[currSpawnIdx].spawnTime <= currTime)
            {
                string code     = stageData.bigPattern[currSpawnIdx].spawnPieceCode;
                int    pieceIdx = GenericDataMgr.genericData_SO.GetPieceIdxByCode(code);

                Instantiate(
                    GenericDataMgr.genericData_SO.ChessPieces[pieceIdx].prefab,
                    spawnPositions[stageData.bigPattern[currSpawnIdx].spawnLineIdx].position,
                    Quaternion.identity);
                currSpawnIdx++;
            }
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        for (int i = 0; i < parts.Length; i++)
        {
            parts[i].gameObject.GetComponent <SpriteRenderer>().color = c;
        }

        //--WAVE STATE

        int switchCounter = 0;

        if (Input.GetKey(KeyCode.Alpha1))
        {
            //red
            switchCounter += 1;
        }

        if (Input.GetKey(KeyCode.Alpha3))
        {
            //blue
            switchCounter += 2;
        }

        if (Input.GetKey(KeyCode.Alpha2))
        {
            //yellow
            switchCounter += 4;
        }

        switch (switchCounter)
        {
        case 0:
            currentWaveState = WAVESTATE.NONE;
            c               = Color.white;
            audioLow.mute   = true;
            audioNorm.mute  = true;
            audioHigh.mute  = true;
            audioCombo.mute = true;
            Debug.Log("NO STATE");
            break;

        case 1:
            currentWaveState = WAVESTATE.RED;
            c               = Color.red;
            audioLow.mute   = false;
            audioNorm.mute  = true;
            audioHigh.mute  = true;
            audioCombo.mute = true;
            Debug.Log(currentWaveState);
            break;

        case 2:
            currentWaveState = WAVESTATE.BLUE;
            c               = Color.blue;
            audioLow.mute   = true;
            audioNorm.mute  = true;
            audioHigh.mute  = false;
            audioCombo.mute = true;
            Debug.Log(currentWaveState);
            break;

        case 3:
            currentWaveState = WAVESTATE.PURPLE;
            c               = Color.magenta;
            audioLow.mute   = true;
            audioNorm.mute  = true;
            audioHigh.mute  = true;
            audioCombo.mute = false;
            Debug.Log(currentWaveState);
            break;

        case 4:
            currentWaveState = WAVESTATE.YELLOW;
            c               = Color.yellow;
            audioLow.mute   = true;
            audioNorm.mute  = false;
            audioHigh.mute  = true;
            audioCombo.mute = true;
            Debug.Log(currentWaveState);
            break;

        case 5:
            currentWaveState = WAVESTATE.ORANGE;
            c               = new Color(255, 165, 0);
            audioLow.mute   = true;
            audioNorm.mute  = true;
            audioHigh.mute  = true;
            audioCombo.mute = false;
            Debug.Log(currentWaveState);
            break;

        case 6:
            currentWaveState = WAVESTATE.GREEN;
            c               = Color.green;
            audioLow.mute   = true;
            audioNorm.mute  = true;
            audioHigh.mute  = true;
            audioCombo.mute = false;
            Debug.Log(currentWaveState);
            break;

        default:
            break;
        }
    }