Esempio n. 1
0
    private static List <Vector3> GetPositionListForSingleChild(int playerId, List <Vector3> piecePositions, Transform[] childrenTransform, PositionMapElement[,] playerPositionMapElement, GameObject playerField, GameObject playerForSeeWindow, int mapVerticalStartPosition)
    {
        int mapSingleHorizontalPosition;

        if (ApplicationUtils.IsInMultiPlayerMode())
        {
            mapSingleHorizontalPosition = GameFieldUtils.PositionToMapValue(childrenTransform.First().position.x, playerId, playerField, playerForSeeWindow);
        }
        else
        {
            mapSingleHorizontalPosition = (int)Mathf.Round(childrenTransform.First().position.x - 0.5f);
        }

        for (int j = mapVerticalStartPosition; j >= 0; j--)
        {
            if (playerPositionMapElement[j, mapSingleHorizontalPosition].IsOccupied)
            {
                piecePositions.Add(playerPositionMapElement[j, mapSingleHorizontalPosition].CurrentMapElement.transform.position);
                break;
            }

            if (j == 0)
            {
                piecePositions.Add(new Vector3(GameFieldUtils.MapValueToPosition(mapSingleHorizontalPosition, playerId, playerField, playerForSeeWindow), 0.5f, -0.5f));
            }
        }

        return(piecePositions);
    }
    private void UpdateMapDatasForObject(GameObject parentObject, GameManager gameManagerScript, int playerId)
    {
        Transform[] childrenTransform = parentObject.GetComponentsInChildren <Transform>();

        foreach (Transform childTransform in childrenTransform)
        {
            int linePosition   = (int)Math.Round(childTransform.position.z - 0.5f);
            int columnPosition = 0;

            if (ApplicationUtils.IsInMultiPlayerMode())
            {
                columnPosition = GameFieldUtils.PositionToMapValue(childTransform.position.x, playerId, gameManagerScript.PlayersField[playerId], gameManagerScript.PlayersForeSeeWindow[playerId]);
            }
            else
            {
                columnPosition = (int)Math.Round(childTransform.position.x - 0.5f);
            }

            gameManagerScript.PlayersPositionMap[playerId][linePosition, columnPosition].IsOccupied        = true;
            gameManagerScript.PlayersPositionMap[playerId][linePosition, columnPosition].CurrentMapElement = childTransform.gameObject;
            childTransform.gameObject.layer = LayerMask.NameToLayer(LayerConstants.LAYER_NAME_DESTROYABLE_PIECE);
        }
    }