示例#1
0
 private void Start()
 {
     timer = 60f;
     sm    = SpawnManager.Instance;
     ui    = UIInGameManager.instance;
     ui.OnChangeMaxHeightViewer(100);
     ui.OnChangeHeightViewer(0, 100);
     AudioManager.instance.PlayInGame();
 }
示例#2
0
    private void Update()
    {
        if (gameover)
        {
            return;
        }

        if (timer == 60f && blockPlaceMode)
        {
            NextBlock();
        }

        if (timer > 0f)
        {
            timer -= Time.deltaTime;
        }
        else if (timer <= 0f && blockPlaceMode)
        {
            StartPlayerMode();
        }
        else if (timer <= 0f && !blockPlaceMode)
        {
            ui.OnResult();
            UIResultManager.instance.SetResult(blockCount, (int)height, 100);
            gameover = true;
        }

        int    timerMin = (int)timer / 60;
        int    timerSec = (int)timer % 60;
        string timerStr = string.Format("{0:D2}", timerMin) + "  " + string.Format("{0:D2}", timerSec);

        ui.OnChangeTimer(timerStr);
        ui.OnChangeHeightViewer((int)height, 100);
        ui.OnChangeBlockInfo(sm.queue.Peek().gameObject.GetComponent <Energy>().energyName, sm.queue.Peek().icon);


        if (Input.GetKeyDown(KeyCode.Space) && blockPlaceMode)
        {
            currentBlock.StopBlock();
            NextBlock();
        }

        if (blockPlaceMode && currentBlock != null)
        {
            float h = Input.GetAxis("Horizontal");

            if (h != 0)
            {
                Vector3 pos = currentBlock.transform.position;
                pos += currentBlock.transform.right * -h * Time.deltaTime;
                currentBlock.transform.position = pos;
            }
            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                currentBlock.block.transform.Rotate(0f, 0f, 90f);
                currentBlock.RotateCubes(-90f);
            }
            else if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                currentBlock.block.transform.Rotate(0f, 0f, -90f);
                currentBlock.RotateCubes(90f);
            }
        }
        if (!blockPlaceMode)
        {
            CalculateHeight();
        }

        Vector3 minPos = minHeightCube.position;

        minPos.y = height - 1.5f;
        minHeightCube.position = minPos;
    }