コード例 #1
0
ファイル: FightHandler.cs プロジェクト: dafei2015/LOLClient
        /// <summary>
        /// 房间创建 需要知道选择模型里的数据
        /// </summary>
        public void Create(SelectModel[] teamOne,SelectModel[] teamTwo)
        {
            FightRoom room;
            if(!cacheRooms.TryPop(out room))
            {
                room = new FightRoom();
                //添加唯一ID
                room.SetArea(AddIndex);
            }
            //房间数据初始化
            room.Init(teamOne,teamTwo);
            foreach (SelectModel item in teamOne)
            {
                userRoom.TryAdd(item.UserID, room.GetArea());
            }
            foreach (SelectModel item in teamTwo)
            {
                userRoom.TryAdd(item.UserID, room.GetArea());
            }

            roomMap.TryAdd(room.GetArea(), room);
        }
コード例 #2
0
ファイル: FightRoom.cs プロジェクト: dafei2015/LOLClient
        private FightPlayerModel Create(SelectModel model,int team)
        {
            FightPlayerModel player = new FightPlayerModel();
            player.Id = model.UserID;
            player.Code = model.Hero;
            player.Name = GetUser(model.UserID).Name;
            player.Exp = 0;
            player.Level = 1;
            player.FreePoint = 1;
            player.Mongy = 0;
            player.Type = ModelType.HUMAN; 
            //从配置表里取出对应的英雄数据,然后计算
            HeroDataModel data = HeroData.heroMap[model.Hero];
            player.Hp = data.HpBase;
            player.HpMax = data.HpBase;
            player.Atk = data.AtkBase;
            player.Def = data.DefBase;
            player.MoveSpeed = data.MoveSpeed;
            player.AtkSpeed = data.AtkSpeed;
            player.AtkRange = data.AtkRange;
            player.EyeRange = data.EyeRange;
            player.Skills = InitSkill(data.Skills);
            player.Team = team;

            player.Equs = new int[3];


            return player;
        }
コード例 #3
0
ファイル: SelectRoom.cs プロジェクト: dafei2015/LOLClient
        /// <summary>
        /// 房间初始化
        /// </summary>
        /// <param name="teamOne"></param>
        /// <param name="teamTwo"></param>
        public void Init(List<int> teamOne, List<int> teamTwo)
        {
            this.teamOnes.Clear();
            this.teamTwos.Clear();
            foreach (int item in teamOne)
            {
                SelectModel select = new SelectModel();
                select.UserID = item;
                select.Name = GetUser(item).Name;
                select.Hero = -1;
                select.IsEnter = false;
                select.IsReady = false;
                this.teamOnes.TryAdd(item,select);
            }
            foreach (int item in teamTwo)
            {
                SelectModel select = new SelectModel();
                select.UserID = item;
                select.Name = GetUser(item).Name;
                select.Hero = -1;
                select.IsEnter = false;
                select.IsReady = false;
                this.teamTwos.TryAdd(item,select);
            }

            //初始化完毕,开始定时任务,设定30秒后没有进入选择界面的时候,直接解散此次匹配,使用Timer会新开一个线程影响性能
            missionID = ScheduleUtil.Instance.Schedule(delegate
            {
                //30秒后判断进入情况 如果不是全员进入则解散成员
                if (enterCount<teamOne.Count+teamTwo.Count)
                {
                    DestroyRoom();
                }
                else
                {
                    //选择英雄的时间 再次启动定时任务
                    missionID = ScheduleUtil.Instance.Schedule(delegate
                    {
                        bool selectAll = true;
                        foreach (SelectModel item in this.teamOnes.Values)
                        {
                            if (item.Hero == -1)
                            {
                                selectAll = false;
                                break;
                            }
                        }
                        if (selectAll)
                        {
                            foreach (SelectModel item in this.teamTwos.Values)
                            {
                                if (item.Hero == -1)
                                {
                                    selectAll = false;
                                    break;
                                }
                            }
                        }

                        if (selectAll)
                        {
                            //全部选了,只是没有人点准备按钮,开始战斗
                            StartFight();
                        }
                        else
                        {
                            DestroyRoom();
                        }
                    }, 30*1000);
                }
            }, 30*1000);
        }
コード例 #4
0
ファイル: FightRoom.cs プロジェクト: dafei2015/LOLClient
        internal void Init(SelectModel[] teamOne, SelectModel[] teamTwo)
        {
            offLine.Clear();
            this.enterCount = teamOne.Length + teamTwo.Length;
            //初始化英雄数据
            for (int i = 0; i < teamOne.Length; i++)
            {
                this.teamOnes.Add(teamOne[i].UserID, Create(teamOne[i],1));
            }

            for (int i = 0; i < teamTwo.Length; i++)
            {
                this.teamTwos.Add(teamTwo[i].UserID, Create(teamTwo[i],2));
            }

            //添加建筑
            // 预留ID段 -1 到- 10 为队伍一的建筑,-11 到- 20 为队伍2 建筑
            for (int i = -1; i >= -3; i--)
            {
                this.teamOnes.Add(i, CreateBuild(i, Math.Abs(i),1));
            }

            for (int i = -11; i >= -13; i--)
            {
                this.teamTwos.Add(i, CreateBuild(i, Math.Abs(i) - 10,2));
            }

        }