Esempio n. 1
0
    public void AddGameObj(GameTrace gameTrace)
    {
        Vector2Int boardPos = new Vector2Int(gameTrace.x, gameTrace.y);

        if (_gameObjects.ContainsKey(boardPos))
        {
            // already have a step on this position
            Debug.Log("in AddGameObj: already have this key");
            return;
        }
        Vector3    worldPos = new Vector3(CursorController.CalcPosition(gameTrace.x), 1, CursorController.CalcPosition(gameTrace.y));
        GameObject newStone = null;

        if (gameTrace.player == "black")
        {
            newStone = Instantiate(_blackStonePrefab, worldPos, Quaternion.LookRotation(Vector3.up));
        }
        else if (gameTrace.player == "white")
        {
            newStone = Instantiate(_whiteStonePrefab, worldPos, Quaternion.LookRotation(Vector3.up));
        }
        if (newStone != null)
        {
            _gameObjects.Add(new Vector2Int(gameTrace.x, gameTrace.y), newStone);
            newStone.transform.localScale = new Vector3(2, 2, 2);
        }
    }