예제 #1
0
        public Manager(ManagerInput input, IMatch match, Side side)
        {
            if (input == null)
            {
                throw new ApplicationException("Initializes a new manager by null TransferManagerEntity.");
            }
            if (input.Players.Count == 0)
            {
                throw new ApplicationException("The manager has no team members. Manager name:" + input.Name);
            }
            if (input.Players.Count != Defines.Match.MAX_PLAYER_COUNT)
            {
                throw new ApplicationException("The manager's team members count is not 11. Manager name:" + input.Name + ", Team member count:" + input.Players.Count);
            }
            this._input      = input;
            this._match      = match;
            this._side       = side;
            this._status     = new ManagerStatus();
            this._report     = new ManagerReport(input);
            this._playerHash = new Dictionary <Position, List <IPlayer> >(4);
            _playerHash.Add(Position.Goalkeeper, new List <IPlayer>(8));
            _playerHash.Add(Position.Fullback, new List <IPlayer>(8));
            _playerHash.Add(Position.Midfielder, new List <IPlayer>(8));
            _playerHash.Add(Position.Forward, new List <IPlayer>(8));
            int formId   = input.FormId;
            var formCfg  = FormationCache.GetFormation(formId);
            int clientId = (_side == Side.Home) ? 0 : Defines.Match.MAX_PLAYER_COUNT;

            #region ISkill
            this.boostCore   = new BoostCore(match);
            this.buffCore    = new BuffCore(match);
            this.specBuffCoe = new SpecBuffCore();
            this.rootSkill   = new Skill(_match, this, string.Empty);
            #endregion

            PlayerInput pInput = null;
            Player      player = null;
            for (var i = 0; i < input.Players.Count; i++)
            {
                pInput = input.Players[i];
                var pForm = formCfg[i];
                pInput.Position = (byte)pForm.Position;
                player          = new Player(pInput, this, (byte)(i + clientId), pForm.Default, pForm.HalfDefault);
                _players.Add(player);
                _playerHash[pForm.Position].Add(player);
            }
            this.SkillPlayerList = new List <SkillEngine.SkillBase.Xtern.ISkillPlayer>(_players.Count);
            this.SkillPlayerList.AddRange(_players);

            #region Buff
            int last    = _match.RoundPerMinute * 90;
            int point   = 0;
            int percent = 0;
            if (null != input.PropList)
            {
                foreach (var item in input.PropList)
                {
                    if (null == item.BuffId)
                    {
                        continue;
                    }
                    point   = (int)(item.Point * 100);
                    percent = (int)(item.Percent * 10000);
                    this.AddBuff(CreatePropBuff(last, point, percent, item.BuffId));
                }
            }
            if (null != input.BoostList)
            {
                foreach (var item in input.BoostList)
                {
                    if (null == item.BuffId)
                    {
                        continue;
                    }
                    point   = (int)(item.Point * 100);
                    percent = (int)(item.Percent * 10000);
                    this.AddBoost(CreateBoostBuff(item.BoostType, last, point, percent, item.BuffId));
                }
            }
            #endregion
        }
예제 #2
0
 public static void Boot()
 {
     MoveRegionCache.Boot();
     FormationCache.Boot();
     StateInitializer.Initialize();
 }