Esempio n. 1
0
    private void Update()
    {
        if (IsGameOver)
        {
            return;
        }

        if (_isInitiating)
        {
            if (middleSpawnPoint.position.y < 12)
            {
                if (_timeLeft <= 0)
                {
                    Spawn();

                    if (currentConnector == null)
                    {
                        currentConnector = ConnectorList.FirstOrDefault(x => x.Col == 0);
                    }

                    foreach (var spawnPoint in SpawnPoints)
                    {
                        spawnPoint.transform.position += Vector3.up * 3;
                    }

                    _timeLeft = Speed;
                }
                else
                {
                    _timeLeft -= Time.deltaTime;
                }
            }
            else
            {
                _isInitiating = false;
            }
        }
        else
        {
            if (_timeLeft <= 0)
            {
                Spawn();
                Move();

                Speed = Mathf.Clamp(Speed - 0.01f, 0.1f, 1f);

                _timeLeft = Speed;
            }
            else
            {
                _timeLeft -= Time.deltaTime;
            }
        }
    }
Esempio n. 2
0
    private void Player_OnPlayerTryMove(Vector3 newPosition)
    {
        if (IsGameOver)
        {
            return;
        }

        int newCol = Mathf.RoundToInt(newPosition.x);
        int newRow = Mathf.RoundToInt(newPosition.y);

        var connector = ConnectorList.FirstOrDefault(x => x.Col == newCol && x.Row == newRow);

        if (connector != null)
        {
            Connect(connector);
        }
    }