コード例 #1
0
    // Use this for initialization
    void Start()
    {
        pfc = FindObjectOfType <PlayfieldController>();

        activePlayer = 0;
        gameState    = GameState.PlayerStart;
    }
コード例 #2
0
    public void WallKick(int sign)
    {
        Rotate(sign, basicOffsets);

        if (!PlayfieldController.ValidPosition(this))
        {
            Rotate(-sign, basicOffsets);

            foreach (OffsetList ol in offsetsList)
            {
                Rotate(sign, ol.offsets);

                if (PlayfieldController.ValidPosition(this))
                {
                    break;
                }

                Rotate(-sign, ol.offsets);
            }
        }

        SetGhostPosition(matrixPosition);

        CancelLock();
    }
コード例 #3
0
    IEnumerator IEPlay()
    {
        LoadingController.LoadScene(1);
        yield return(new WaitUntil(() => !LoadingController.isLoading));

        PlayfieldController.Setup(startLevel);
        PlayfieldController.StartSpawn();
    }
コード例 #4
0
    IEnumerator LockDelay()
    {
        yield return(new WaitForSeconds(.5f));

        if (PlayfieldController.ValidPosition(this))
        {
            blocks.ForEach(block => block.Lock());
            PlayfieldController.ClearRows();
            PlayfieldController.SpawnTetromino();
            PlayfieldController.canHold = true;
            Destroy(gameObject);
        }
        else
        {
            PlayfieldController.GameOver();
        }
    }
コード例 #5
0
    public bool Move(Vector2Int position)
    {
        Vector2Int lastPosition = matrixPosition;

        SetPosition(matrixPosition + position);

        CancelLock();

        if (!PlayfieldController.ValidPosition(this))
        {
            SetPosition(lastPosition);
            return(false);
        }

        SetGhostPosition(matrixPosition);

        return(true);
    }
コード例 #6
0
    void SetGhostPosition(Vector2Int position)
    {
        ghost.gameObject.SetActive(false);

        int y = position.y - 1;

        do
        {
            SetPosition(new Vector2Int(matrixPosition.x, y--));
        } while(PlayfieldController.ValidPosition(this));

        Vector2Int ghostPosition = matrixPosition + Vector2Int.up;

        SetPosition(position);

        ghost.position = (Vector2)ghostPosition;
        ghost.gameObject.SetActive(true);
    }
コード例 #7
0
    // Start is called before the first frame update
    void Start()
    {
        if (mother == null || father == null)
        {
            genome = new EnemyGenome();
        }
        else
        {
            genome = new EnemyGenome(father, mother);
        }

        pfc = GameObject.FindWithTag("GameController").GetComponent <PlayfieldController>();
        nav = GetComponent <UnityEngine.AI.NavMeshAgent>();

        nav.speed = genome.speed;

        StartCoroutine("makeUpMind");
    }
コード例 #8
0
    public void Drop()
    {
        if (isLanded)
        {
            return;
        }

        bool fall = Move(Vector2Int.down);

        Vector2Int lastPosition = matrixPosition;

        SetPosition(matrixPosition + Vector2Int.down);

        if (!PlayfieldController.ValidPosition(this))
        {
            landed = StartCoroutine(LockDelay());
            if (fall)
            {
                SoundController.PlaySfx(GameData.GetAudioClip("Land"));
            }
        }

        SetPosition(lastPosition);
    }
コード例 #9
0
 void Start()
 {
     pfc   = GameObject.FindWithTag("GameController").GetComponent <PlayfieldController>();
     start = Time.time;
 }