Пример #1
0
        private BaseNexoTile CreateBaseNexoTile(Player player)
        {
            BaseNexoTile baseNexoTile = null;
            Vector2      position     = board2DManager.GetPlayerNexusWorldPosition(player);

            switch (player.OwnerPlayerID)
            {
            case 0:
                baseNexoTile = new BaseNexoTile(position, 0, 0, player);
                board2DManager.AddModifyOccupierPosition(player, new Position(0, 0));
                board2DManagerUI.CreateBaseNexoTile(baseNexoTile, true);
                break;

            case 1:
                baseNexoTile = new BaseNexoTile(position, 9, 0, player);
                board2DManager.AddModifyOccupierPosition(player, new Position(9, 0));
                board2DManagerUI.CreateBaseNexoTile(baseNexoTile, false);
                break;

            default:
                break;
            }

            return(baseNexoTile);
        }
        public Vector3 GetTilePosition(Tile TileObject, bool isPlayerOne)
        {
            switch (TileObject.tileType)
            {
            case TILETYPE.BASENEXO:
                // HARDCODE
                if (TileObject.GetRealWorldLocation().x < 0)
                {
                    return(board2D.GetPlayerNexusWorldPosition(true));
                }
                return(board2D.GetPlayerNexusWorldPosition(false));

            case TILETYPE.SPAWN:
            case TILETYPE.BATTLEFILED:
                return(TileObject.GetRealWorldLocation());

            default:
                return(Vector3.zero);
            }
        }
        public Motion CreateNewBoardMotion(Board2DManager board2D, Action OnBoardLoadComplete)
        {
            GameObject[,] tiles = new GameObject[board2D.columnsWidht, board2D.rowsHeight];
            int        index      = 1;
            GameObject tileParent = new GameObject("TileParent");

            List <Motion> motionsCreateBoard = new List <Motion>();

            for (int x = 0; x < board2D.columnsWidht; x++)
            {
                for (int y = 0; y < board2D.rowsHeight; y++)
                {
                    if (x == 0 || x == 1)
                    {
                        tiles[x, y] = board2D.GridArray[x, y].goAnimContainer.GetTransform().gameObject;
                        tiles[x, y].transform.SetParent(tileParent.transform);
                        continue;
                    }
                    if (x == 9 || x == 10)
                    {
                        tiles[x, y] = board2D.GridArray[x, y].goAnimContainer.GetTransform().gameObject;
                        tiles[x, y].transform.SetParent(tileParent.transform);
                        continue;
                    }

                    Vector3 thisTileFinalPosition = board2D.GetGridObject(x, y).GetRealWorldLocation();

                    tiles[x, y] = board2D.GridArray[x, y].goAnimContainer.GetTransform().gameObject;
                    tiles[x, y].transform.position = new Vector3(thisTileFinalPosition.x, Helper.GetCameraTopBorderYWorldPostion().y, 0);
                    tiles[x, y].transform.SetParent(tileParent.transform);

                    // TWEEN DE LA CRANE A LA POSICION DE SPAWNEO
                    Motion motionTweenMove = new MoveTweenMotion(this, tiles[x, y].transform, index, thisTileFinalPosition, 1);
                    motionsCreateBoard.Add(motionTweenMove);
                }
                index++;
            }

            // para las spawn tiles
            Vector2 yOffset = new Vector2(0, 10);
            Vector3 pOneNexusFinalPosition = board2D.GetPlayerNexusWorldPosition(true);

            tiles[0, 0].transform.position = new Vector3(pOneNexusFinalPosition.x, Helper.GetCameraTopBorderYWorldPostion().y + yOffset.y, 0);
            Motion motionTweenNexusP1Move = new MoveTweenMotion(this, tiles[0, 0].transform, index, pOneNexusFinalPosition, 1);

            motionsCreateBoard.Add(motionTweenNexusP1Move);

            Vector3 pTwoNexusFinalPosition = board2D.GetPlayerNexusWorldPosition(false);

            tiles[9, 0].transform.position = new Vector3(pTwoNexusFinalPosition.x, Helper.GetCameraTopBorderYWorldPostion().y + yOffset.y, 0);
            Motion motionTweenNexusP2Move = new MoveTweenMotion(this, tiles[9, 0].transform, index, pTwoNexusFinalPosition, 1);

            motionsCreateBoard.Add(motionTweenNexusP2Move);

            index++;

            List <Configurable>          configurables = new List <Configurable>();
            EventInvokerGenericContainer evenToInvoke  = new EventInvokerGenericContainer(OnBoardLoadComplete);
            InvokeEventConfigureAnimotion <EventInvokerGenericContainer, Transform> onBoardCompleteInvokeEvent =
                new InvokeEventConfigureAnimotion <EventInvokerGenericContainer, Transform>(evenToInvoke, index);

            configurables.Add(onBoardCompleteInvokeEvent);

            CombineMotion combinMoveMotion = new CombineMotion(this, 1, motionsCreateBoard, configurables);

            return(combinMoveMotion);
        }