Exemplo n.º 1
0
        /// <summary>
        /// 开启定时任务,30秒刷一波小兵
        /// </summary>
        private void spwanDog()
        {
            this.StartSchedule(DateTime.UtcNow.AddSeconds(30), delegate
            {
                List <DogModel> dogs   = new List <DogModel>();
                DogDataModel dataModel = DogData.GetDogData(1);

                for (int i = 0; i < 1; i++)
                {
                    //产生小兵

                    DogModel dog  = new DogModel(DogId, dataModel.TypeId, 1, dataModel.MaxHp, dataModel.Attack, dataModel.Defense, dataModel.AttackDistance, dataModel.Name);
                    dog.ModelType = ModelType.DOG;
                    team1DogModel.Add(dog.Id, dog);
                    dogs.Add(dog);

                    dog           = new DogModel(DogId, dataModel.TypeId, 2, dataModel.MaxHp, dataModel.Attack, dataModel.Defense, dataModel.AttackDistance, dataModel.Name);
                    dog.ModelType = ModelType.DOG;
                    dog.Team      = 2;

                    team2DogModel.Add(dog.Id, dog);
                    dogs.Add(dog);
                }
                //给客户端发送现在出兵了dogs
                Brocast(OpCode.FightCode, OpFight.Dog, 0, "双方产生小兵", null, JsonMapper.ToJson(dogs.ToArray()));

                //无限递归
                spwanDog();
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取小兵数据
        /// </summary>
        /// <param name="id"></param>
        /// <param name="typeId"></param>
        /// <param name="team"></param>
        /// <returns></returns>
        private DogModel getDogModel(int id, int typeId, int team)
        {
            //获取配置表里面的数据
            DogDataModel data  = DogData.GetDogData(typeId);
            DogModel     model = new DogModel(id, typeId, team, data.Hp, data.Attack, data.Defense, data.AttackDistance,
                                              data.Name);

            model.ModelType = ModelType.DOG;
            return(model);
        }