コード例 #1
0
 public static bool ChangeNameScopeIsValid(this StrongPoint strongPoint, string name)
 {
     return(AssertionConcern.IsSatisfiedBy(
                AssertionConcern.AssertArgumentNotNull(name, Errors.InvalidStrongPoint),
                AssertionConcern.AssertArgumentLength(name, 2, 50, Errors.InvalidStrongPoint)
                ));
 }
コード例 #2
0
ファイル: AllianceWar.cs プロジェクト: tuita520/mmorpgserver
 private void CloseTimer(StrongPoint sp)
 {
     if (sp.Timer != null)
     {
         DeleteTimer(sp.Timer);
         sp.Timer = null;
     }
 }
コード例 #3
0
ファイル: AllianceWar.cs プロジェクト: tuita520/mmorpgserver
        private void SetStrongpointState(StrongPoint sp, eStrongpointState state, int camp)
        {
            sp.State = state;
            var now  = DateTime.Now;
            var time = sp.Timer == null ? 0f : (OccupyTime - (float)(sp.Timer.Time - now).TotalSeconds);

            PushActionToAllPlayer(p => { p.Proxy.NotifyStrongpointStateChanged(camp, sp.Index, (int)state, time); });
        }
コード例 #4
0
 public static bool CreateStrongPointScopeIsValid(this StrongPoint strongPoint)
 {
     return(AssertionConcern.IsSatisfiedBy(
                AssertionConcern.AssertArgumentNotNull(strongPoint.Name, Errors.InvalidStrongPoint),
                AssertionConcern.AssertArgumentLength(strongPoint.Name, 2, 50, Errors.InvalidStrongPoint),
                AssertionConcern.AssertArgumentNotNull(strongPoint.ClassStrongPoint, Errors.InvalidClassStrongPoint)
                ));
 }
コード例 #5
0
        public StrongPoint Create(CreateStrongPointCommand command)
        {
            var StrongPoint = new StrongPoint(command.Name, command.Class, command.Description);

            StrongPoint.Validate();
            _repository.Create(StrongPoint);

            if (Commit())
            {
                return(StrongPoint);
            }

            return(null);
        }
コード例 #6
0
ファイル: AllianceWar.cs プロジェクト: tuita520/mmorpgserver
 private void StartTimer(StrongPoint sp, DateTime target, Action act)
 {
     CloseTimer(sp);
     sp.Timer = CreateTimer(target, act);
 }
コード例 #7
0
ファイル: AllianceWar.cs プロジェクト: tuita520/mmorpgserver
        public override void OnCreate()
        {
            base.OnCreate();

            var param = Param.Param;

            if (param.Count < 5)
            {
                Logger.Error("In OnCreate(). Param count < 5");
                return;
            }

            var hour = param[0];
            var min  = param[1];

            for (var i = 0; i < 3; i++)
            {
                var allianceId = param[i + 2];
                AllianceIds.Add(allianceId);
                var c = Camps[DefenderCampId + i];
                c.AllianceId = allianceId;
                if (allianceId != -1)
                {
                    GetAllianceName(c);
                }
            }

            //初始化守城方的旗子
            var ids = FlagIds[0];

            for (int i = 0, imax = Flags.Length; i < imax; ++i)
            {
                Flags[i] = CreateSceneNpc(ids[i]);
            }

            //设置副本开启和结束时间
            var now = DateTime.Now;

            startTime =
                new DateTime(now.Year, now.Month, now.Day, hour, min, 0, DateTimeKind.Local).AddMinutes(
                    mFubenRecord.OpenLastMinutes);
            StartTimer(eDungeonTimerType.WaitStart, startTime, TimeOverStart);
            var extraTime = startTime.AddMinutes(mFubenRecord.TimeLimitMinutes - ExtraTimeMin);

            StartTimer(eDungeonTimerType.WaitExtraTimeStart, extraTime, EnterExtraTime);
            var endTime = extraTime.AddMinutes(ExtraTimeMin);

            StartTimer(eDungeonTimerType.WaitEnd, endTime, TimeOverEnd);

            //副本提示 正式开始前,攻城战每1分钟提示一次
            for (var i = mFubenRecord.OpenLastMinutes; i > 0; --i)
            {
                var time = startTime.AddMinutes(-i);
                if (now <= time)
                {
                    var content = Utils.WrapDictionaryId(300922, new List <string> {
                        i.ToString()
                    });
                    CreateTimer(time,
                                () =>
                    {
                        PushActionToAllPlayer(player =>
                        {
                            player.Proxy.NotifyBattleReminder(14, content, 1);
                        });
                    });
                }
            }

            //副本提示 距离结束提示
            int[] timeNoticeList = { 10, 5, 1 }; // 距离副本结束多长时间提示 (300928)
            for (var i = 0; i < timeNoticeList.Length; ++i)
            {
                var timeNotice = timeNoticeList[i];
                var time       = extraTime.AddMinutes(-timeNotice);
                if (time < startTime)
                {
                    continue;
                }

                var dictId = 300927;
                if (i == timeNoticeList.Length) // 最后一次提示特殊处理
                {
                    dictId = 300928;
                }
                var content = Utils.WrapDictionaryId(dictId, new List <string> {
                    timeNotice.ToString()
                });
                CreateTimer(time,
                            () => { PushActionToAllPlayer(player => { player.Proxy.NotifyBattleReminder(14, content, 1); }); });
            }

            //副本提示 加时距离结束提示
            int[] extraTimeNoticeList = { 5, 3, 1 }; // 距离副本结束多长时间提示 (300935)
            for (var i = 0; i < extraTimeNoticeList.Length; ++i)
            {
                var extraTimeNotice = extraTimeNoticeList[i];
                var time            = endTime.AddMinutes(-extraTimeNotice);
                if (time < extraTime)
                {
                    continue;
                }
                var dictId = 300934;
                if (i == extraTimeNoticeList.Length) // 最后一次提示特殊处理
                {
                    dictId = 300935;
                }
                var content = Utils.WrapDictionaryId(dictId, new List <string> {
                    extraTimeNotice.ToString()
                });
                CreateTimer(time,
                            () => { PushActionToAllPlayer(player => { player.Proxy.NotifyBattleReminder(14, content, 1); }); });
            }

            //初始化StrongPoints
            for (int i = 0, imax = 5; i < imax; i++)
            {
                StrongPoints[i] = new StrongPoint(i);
            }

            //初始化出生点
            var camp = Camps[DefenderCampId];

            camp.AppearPos = new Vector2((float)TableSceneData.Entry_x, (float)TableSceneData.Entry_z);
            camp.RelivePos = new Vector2((float)TableSceneData.Safe_x, (float)TableSceneData.Safe_z);

            camp = Camps[Offensiver1CampId];
            var tbPos = Table.GetRandomCoordinate(401);

            camp.AppearPos = new Vector2(tbPos.PosX, tbPos.PosY);
            tbPos          = Table.GetRandomCoordinate(402);
            camp.RelivePos = new Vector2(tbPos.PosX, tbPos.PosY);

            camp           = Camps[Offensiver2CampId];
            tbPos          = Table.GetRandomCoordinate(404);
            camp.AppearPos = new Vector2(tbPos.PosX, tbPos.PosY);
            tbPos          = Table.GetRandomCoordinate(405);
            camp.RelivePos = new Vector2(tbPos.PosX, tbPos.PosY);

            //初始化副本信息
            mFubenInfoMsg.Units[0].Params[0] = AllianceIds[0];
            mFubenInfoMsg.Units[0].Params[1] = 5;
            mFubenInfoMsg.Units[1].Params[0] = AllianceIds[1];
            mFubenInfoMsg.Units[2].Params[0] = AllianceIds[2];
            mFubenInfoMsg.Units[3].Params[0] = (int)eAllianceWarState.WaitStart;
            mIsFubenInfoDirty = true;

            //每3秒广播一次位置
            CreateTimer(now.AddSeconds(3), ScenePlayerInfos, 3000);

            CreateDynamicNpc();
        }
コード例 #8
0
ファイル: AllianceWar.cs プロジェクト: tuita520/mmorpgserver
        private void SetStrongpointCamp(StrongPoint sp, int campId)
        {
            if (sp.OccupiedCamp == campId)
            {
                return;
            }

            var oldCampId = sp.OccupiedCamp;

            sp.OccupiedCamp = campId;
            if (oldCampId != -1)
            {
                var camp  = Camps[oldCampId];
                var count = --camp.SpCount;
                if (count == 2)
                {
//不足3个据点
                    if (camp.Timer != null)
                    {
                        DeleteTimer(camp.Timer);
                        camp.Timer = null;
                    }
                }
                //删除旗子
                var flag = Flags[sp.Index];
                Flags[sp.Index] = null;
                LeaveScene(flag);
                //修改副本信息
                mIsFubenInfoDirty = true;
                var infoIdx = oldCampId - DefenderCampId;
                var unit    = mFubenInfoMsg.Units[infoIdx];
                unit.Params[1] = count;
            }
            if (campId != -1)
            {
                var infoIdx = campId - DefenderCampId;
                var unit    = mFubenInfoMsg.Units[infoIdx];

                var camp  = Camps[campId];
                var count = ++camp.SpCount;
                if (count >= 3)
                {
                    if (count == 3)
                    {
//达到三个据点
                        if (IsExtraTime)
                        {
                            BattleOver(campId);
                        }
                        else if (campId != DefenderCampId)
                        {
                            var dueTime = DateTime.Now.AddSeconds(StaticVariable.VictoryTime);
                            camp.Timer     = CreateTimer(dueTime, () => { BattleOver(campId); });
                            unit.Params[2] = dueTime.Hour * 10000 + dueTime.Minute * 100 + dueTime.Second;
                        }
                    }

                    if (!IsExtraTime && campId != DefenderCampId)
                    {
                        var sec = 0;
                        if (camp.Timer != null && camp.Timer.T != null)
                        {
                            sec = (int)(camp.Timer.Time - DateTime.Now).TotalSeconds;
                        }
                        var args = new List <string>();
                        args.Add(camp.AllianceName);
                        args.Add(count.ToString());
                        args.Add(sec.ToString());
                        var content = Utils.WrapDictionaryId(300936, args);
                        PushActionToAllPlayer(p => { p.Proxy.NotifyBattleReminder(14, content, 1); });
                    }
                }
                //创建旗子
                Flags[sp.Index] = CreateSceneNpc(FlagIds[campId - DefenderCampId][sp.Index]);
                //修改副本信息
                mFubenInfoMsg.Units[campId - DefenderCampId].Params[1] = count;
                mIsFubenInfoDirty = true;
            }

            //发据点变化提示
            {
                var dictId = -1;
                var args   = new List <string>();
                if (oldCampId == -1 || Camps[oldCampId].AllianceName == null)
                {
                    if (campId != -1)
                    {
                        dictId = 300937;
                        args.Add(Camps[campId].AllianceName);
                    }
                }
                else
                {
                    if (campId == -1)
                    {
                        dictId = 300939;
                        for (var i = DefenderCampId; i <= Offensiver2CampId; i++)
                        {
                            if (i != oldCampId)
                            {
                                args.Add(Camps[i].AllianceName);
                            }
                        }
                    }
                    else
                    {
                        dictId = 300938;
                        args.Add(Camps[campId].AllianceName);
                        args.Add(Camps[oldCampId].AllianceName);
                    }
                }
                if (dictId != -1)
                {
                    var content = Utils.WrapDictionaryId(dictId, args);
                    PushActionToAllPlayer(p => { p.Proxy.NotifyBattleReminder(14, content, 1); });
                }
            }
        }
コード例 #9
0
 public static bool ChangeClassScopeIsValid(this StrongPoint strongPoint, EClassStrongPoint classStrongPoint)
 {
     return(AssertionConcern.IsSatisfiedBy(
                AssertionConcern.AssertArgumentNotNull(classStrongPoint, Errors.InvalidClassStrongPoint)
                ));
 }
コード例 #10
0
 public void Update(StrongPoint strongPoint)
 {
     _context.Entry <StrongPoint>(strongPoint).State = System.Data.Entity.EntityState.Modified;
 }
コード例 #11
0
 public void Delete(StrongPoint strongPoint)
 {
     _context.StrongPoint.Remove(strongPoint);
 }
コード例 #12
0
 public void Create(StrongPoint StrongPoint)
 {
     _context.StrongPoint.Add(StrongPoint);
 }