예제 #1
0
        /**
         * <summary>
         * 3 or 4 players, in corners
         * </summary>
         */

        private static PopulateInitialPosition GetPositionFor3Or4(int playerNum, int width, int height, int castleWidth, int castleHeight)
        {
            PopulateInitialPosition res = new PopulateInitialPosition();

            if (playerNum == 0 || playerNum == 2)
            {
                res.x = 0;
            }
            else
            {
                res.x = width - castleWidth;
            }

            if (playerNum == 0 || playerNum == 3)
            {
                res.y = 0;
            }
            else
            {
                res.y = height - castleHeight;
            }
            res.castleReversed = false;

            return(res);
        }
예제 #2
0
        /**
         * <summary>
         * Sets the camera according to the initial position of the player
         * </summary>
         */
        public void SetCameraPosition(int number, int max, NetworkedScene ns)
        {
            PopulateInitialPosition init = PopulateInitialPosition.GetPlayerPosition(number, max, width, height, castleWidth, castleHeight);
            LayerTile tile = Map.map.GetTileByMapCoordinates(init.x + castleWidth / 2, init.y + castleHeight / 2);

            if (tile != null)
            {
                Vector2 pos = tile.LocalPosition + WorldObjectData.center;
                ns.RenderManager.ActiveCamera2D.Transform.Position = pos;
            }
        }
예제 #3
0
        /**
         * <summary>
         * 2 players, one in front of the other
         * </summary>
         */
        private static PopulateInitialPosition GetPositionFor2(int playerNum, int width, int height,
                                                               int castleWidth, int castleHeight)
        {
            PopulateInitialPosition res = new PopulateInitialPosition();

            res.x = (width - castleWidth) / 2;
            res.y = 0;
            if (playerNum == 1)
            {
                res.y = height - castleHeight;
            }
            res.castleReversed = false;
            return(res);
        }
예제 #4
0
        public void SetPlayer(Player p, int playerNum, int maxPlayers)
        {
            PopulateInitialPosition initial = PopulateInitialPosition.GetPlayerPosition(playerNum, maxPlayers,
                                                                                        width, height, castleWidth, castleHeight);
            int x = initial.x;
            int y = initial.y;

            UIBehavior.ui.CreateCastleToTile(p, x, y, castleWidth, castleHeight);

            //create person
            for (int i = 0; i < personNum; i++)
            {
                UIBehavior.ui.CreateToTile("Person", x + i, y, p);
            }
        }
예제 #5
0
        public static PopulateInitialPosition GetPlayerPosition(int playerNum, int maxPlayers, int width, int height, int castleWidth, int castleHeight)
        {
            PopulateInitialPosition initial = null;

            switch (maxPlayers)
            {
            case 2:
                initial = GetPositionFor2(playerNum, width, height, castleWidth, castleHeight);
                break;

            case 3:
            case 4:
                initial = GetPositionFor3Or4(playerNum, width, height, castleWidth, castleHeight);
                break;

            default:
                break;
            }
            return(initial);
        }
예제 #6
0
        public void SetPlayer(ServerDispatcher disp, Player p, int playerNum, int maxPlayers)
        {
            SendData data = new SendData();

            data.clientId = p.Owner.Name.Substring(6);
            PopulateInitialPosition initial = PopulateInitialPosition.GetPlayerPosition(playerNum, maxPlayers,
                                                                                        width, height, castleWidth, castleHeight);
            int x = initial.x;
            int y = initial.y;


            data.position = Map.map.GetTileByMapCoordinates(x, y).LocalPosition;
            data.creating = "Castle";
            disp.CreateAndSync(data);

            //create person
            data.creating = "Person";
            for (int i = 0; i < personNum; i++)
            {
                data.position = Map.map.GetTileByMapCoordinates(x + i, y).LocalPosition;
                disp.CreateAndSync(data);
            }
        }