예제 #1
0
파일: Client.cs 프로젝트: adamrezich/arena
        public void ReceiveNewPlayerUnit(int unitIndex, int playerIndex, float x, float y, double direction)
        {
            Game.Cmd.Console.WriteLine("Recieving new player unit for " + Players[playerIndex].Name + " at (" + x + ", " + y + ")");
            Player player = Players[playerIndex];
            Unit u = new Unit(player, Role.List[player.Role].Health, Role.List[player.Role].Energy);
            u.Owner = player;
            u.Team = player.Team;
            u.JumpTo(new Vector2(x, y));
            Role.SetUpUnit(ref u, player.Role);
            player.PlayerUnit = u;

            VGame.Shape shape = Role.MakeShape(player.Role);
            u.Actor = new Actor(u, shape);
            u.Actor.Unit = u;

            Actors.Add(u.Actor);
            Units.Add(unitIndex, u);
            player.ControlledUnits.Add(u);
            if (player.ControlledUnits.Count == 0) {
                player.PlayerUnit = u;
                player.CurrentUnit = u;
            }
        }
예제 #2
0
파일: Server.cs 프로젝트: adamrezich/arena
        public Unit MakePlayerUnit(Player player, Vector2 position)
        {
            Console.WriteLine("[S] Making new player unit for " + player.Name + " at (" + position.X + ", " + position.Y + ")");
            Unit u = new Unit(player, Role.List[player.Role].Health, Role.List[player.Role].Energy);
            u.Owner = player;
            u.Team = player.Team;
            u.JumpTo(position);
            Role.SetUpUnit(ref u, player.Role);
            player.ControlledUnits.Add(u);
            player.PlayerUnit = u;

            Units.Add(++unitIndex, u);
            foreach (RemoteClient r in AllClients())
                r.SendNewPlayerUnit(unitIndex, GetPlayerID(player));
            return u;
        }