예제 #1
0
    NSpace CreateSpace(GameObject obj, Vector3 pos, Quaternion rotation, float scale)
    {
        // create the object
        GameObject placeObj = Instantiate(obj, pos, rotation);

        placeObj.transform.SetParent(_board.transform);
        placeObj.transform.localScale = new Vector3(scale, scale, 1);

        NSpace space = placeObj.GetComponent <NSpace>();

        return(space);
    }
예제 #2
0
    public IEnumerator Move(int steps)
    {
        _isMoving = true;
        int oldPos = _currentPosition;

        for (int i = 0; i < steps; i++)
        {
            Vector3 translate = allSpaces[(_currentPosition + 1) % numSpaces].transform.position - allSpaces[_currentPosition].transform.position;
            transform.Translate(translate);
            _currentPosition = (_currentPosition + 1) % numSpaces;
            yield return(new WaitForSeconds(0.2f));
        }
        // Pass GO
        if (_currentPosition == oldPos + steps - numSpaces)
        {
            NPlayerController.instance.PassGo(this);
        }

        NSpace space = allSpaces[_currentPosition];

        space.StepOn(this);

        _isMoving = false;
    }