コード例 #1
0
        public Unit(PlayerState owner, int id, UnitConfiguration configuration, Server server)
        {
            Owner                = owner;
            Id                   = id;
            Faction              = server.GetFaction(configuration.FactionId);
            Type                 = Faction.GetUnitType(configuration.UnitTypeId);
            Upgrades             = new List <UnitUpgrade>();
            _Points              = Type.Points;
            UpgradeSlotsOccupied = new HashSet <int>();
            foreach (var upgradeId in configuration.UpgradeIds)
            {
                AddUpgrade(GetUpgrade(upgradeId));
            }

            Hex      = null;
            Strength = GameConstants.FullUnitStrength;

            Entrenched = false;

            AttritionDuration = 0;

            UpdateStats();
            ResetUnitForNewTurn();

            // Only air units are automatically "deployed" since they don't need to be placed on the map
            Deployed = Stats.Flags.Contains(UnitFlag.Air);
        }
コード例 #2
0
ファイル: Unit.cs プロジェクト: epicvrvs/PanzerKontrol
        public Unit(PlayerState owner, int id, UnitConfiguration configuration, Server server)
        {
            Owner = owner;
            Id = id;
            Faction = server.GetFaction(configuration.FactionId);
            Type = Faction.GetUnitType(configuration.UnitTypeId);
            Upgrades = new List<UnitUpgrade>();
            _Points = Type.Points;
            UpgradeSlotsOccupied = new HashSet<int>();
            foreach (var upgradeId in configuration.UpgradeIds)
                AddUpgrade(GetUpgrade(upgradeId));

            Hex = null;
            Strength = GameConstants.FullUnitStrength;

            Entrenched = false;

            AttritionDuration = 0;

            UpdateStats();
            ResetUnitForNewTurn();

            // Only air units are automatically "deployed" since they don't need to be placed on the map
            Deployed = Stats.Flags.Contains(UnitFlag.Air);
        }
コード例 #3
0
ファイル: ServerClient.cs プロジェクト: jascou/PanzerKontrol
        void OnCreateGameRequest(ClientToServerMessage message)
        {
            CreateGameRequest request = message.CreateGameRequest;

            if (request == null)
            {
                throw new ServerClientException("Invalid game creation request");
            }
            // Defaults to false so lazy/afk players lose the first turn privilege
            _RequestedFirstTurn = false;
            InitialiseArmy(request.Army);
            Faction         faction = Server.GetFaction(request.Army.FactionId);
            CreateGameReply reply   = Server.OnCreateGameRequest(this, request, out _Game);

            QueueMessage(new ServerToClientMessage(reply));
            _PlayerState = new PanzerKontrol.PlayerState(Game, faction, PlayerIdentifier.Player1);
            WaitingForOpponentState();
        }