123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using Sfs2X.Entities.Data;
- public class BaseRoom : BARoom
- {
- public BaseRoom(BAServer server) : base(server)
- {
- m_MaxUsers = 100;
- isRecord = false;
- }
- protected override void CheckGameStart ()
- {
-
- }
- protected override void CheckAITaker ()
- {
-
- }
- public void InitBaseUsers()
- {
- InviteManager.GetInstance ().ActionUpdate.RemoveListener (OnActionUpdate);
- InviteManager.GetInstance ().StateUpdate.RemoveListener (OnStateUpdate);
- InviteManager.GetInstance ().ActionUpdate.AddListener (OnActionUpdate);
- InviteManager.GetInstance ().StateUpdate.AddListener (OnStateUpdate);
- ISFSArray arr = new SFSArray ();
- List<InviteData> list = InviteManager.GetInstance ().GetDataList ();
- for(int i=0; i<list.Count; i++)
- {
- InviteData inviteData = list [i];
- if (inviteData.state != InviteData.State.Online)
- continue;
- ISFSObject obj = Invite2PlayerData(inviteData);
- arr.AddSFSObject (obj);
- }
- SendPlayerJoin(arr);
- }
- private ISFSObject Invite2PlayerData(InviteData inviteData)
- {
- ISFSObject obj = new SFSObject ();
- obj.PutUtfString (UserSFSObjectLabel.ID, inviteData.id.ToString ());
- obj.PutUtfString (UserSFSObjectLabel.NICK, UserCache.GetNick(inviteData.id));
- obj.PutInt (UserSFSObjectLabel.TEAM_ID, TeamUtil.Team.Blue.GetHashCode ());
- obj.PutInt (UserSFSObjectLabel.PLAYER_ID, inviteData.id);
- return obj;
- }
- private void SendPlayerJoin(ISFSArray arr)
- {
- ISFSObject obj = new SFSObject ();
- obj.PutSFSArray ("a", arr);
- Message message = new Message (Command.PlayerJoin, obj);
- server.RoomHandleResponse (message.GetMessagePackage ());
- }
- private void SendPlayerLeft(int id)
- {
- ISFSObject obj = new SFSObject ();
- obj.PutUtfString ("u", id.ToString());
- Message message = new Message (Command.PlayerLeft, obj);
- server.RoomHandleResponse (message.GetMessagePackage ());
- }
- private void OnActionUpdate(int id)
- {
- }
- private void OnStateUpdate(int id)
- {
- InviteData inviteData = InviteManager.GetInstance ().GetData (id);
- if (inviteData == null)
- return;
- if (inviteData.state == InviteData.State.Online) {
- ISFSObject obj = Invite2PlayerData (inviteData);
- ISFSArray arr = new SFSArray ();
- arr.AddSFSObject(obj);
- SendPlayerJoin (arr);
- }
- }
- public override void Dispose ()
- {
- InviteManager.GetInstance ().ActionUpdate.RemoveListener (OnActionUpdate);
- InviteManager.GetInstance ().StateUpdate.RemoveListener (OnStateUpdate);
- }
- }
|