Beispiel #1
0
 private new void Enter(UserToken token)
 {
     if (IsEntered(token)) return;
     base.Enter(token);
     //所有人准备了 发送房间信息
     if(ReduIndex==0)
     {
         FightRoomModel room = new FightRoomModel();
         room.teamOne = teamOnes.Values.ToArray();
         room.teamTwo = teamTwos.Values.ToArray();
         Brocast(FightProtocol.START_BRO,room);
     }
 }
Beispiel #2
0
        private void StartFight(FightRoomModel model)
        {
            room = model;

            //判断队伍
            int myTeam = -1;
            foreach (AbsFightModel item in model.teamOne)
            {
                if(item.Id == GameData.user.ID)
                {
                    myTeam = item.Team;
                }
            }
            if(myTeam == -1)
            {
                foreach (AbsFightModel item in model.teamTwo)
                {
                    if (item.Id == GameData.user.ID)
                    {
                        myTeam = item.Team;
                    }
                }
            }

            string path = null;
            foreach (AbsFightModel item in model.teamOne)
            {
                PlayerCtr ctrl = null;
                if (item.Type == ModelType.HUMAN)
                {
                    path = "Player/" + item.Code;
                    ctrl = Load(path, start1);
                    ctrl.Init((FightPlayerModel)item,myTeam);
                    this.models.Add(item.Id, ctrl);
                }
                else
                {
                    path = "Build/1_" + item.Code;
                    this.models.Add(item.Id, Load(path, position1[item.Code - 1]));
                }
                if(item.Id == GameData.user.ID)
                {
                    FightScene.Instance.InitView((FightPlayerModel)item, ctrl.gameObject);
                    FightScene.Instance.LookAt();
                }
            }

            foreach (AbsFightModel item in model.teamTwo)
            {
                PlayerCtr ctrl = null;
                if (item.Type == ModelType.HUMAN)
                {
                    path = "Player/" + item.Code;
                    ctrl = Load(path, start2);
                    ctrl.Init((FightPlayerModel)item,myTeam);
                    this.models.Add(item.Id, ctrl);
                }
                else
                {
                    path = "Build/2_" + item.Code;
                    this.models.Add(item.Id, Load(path, position2[item.Code - 1]));
                }
                if (item.Id == GameData.user.ID)
                {
                    FightScene.Instance.InitView((FightPlayerModel)item, ctrl.gameObject);
                    FightScene.Instance.LookAt();
                }
            }
        }