예제 #1
0
 public void UpdateWith(UpdateUserBattleStatus u)
 {
     if (u != null)
     {
         if (u.Name != Name)
         {
             throw new Exception(string.Format("Applying update of {0} to user {1}", u.Name, Name));
         }
         if (u.AllyNumber.HasValue)
         {
             AllyNumber = u.AllyNumber.Value;
         }
         if (u.IsSpectator.HasValue)
         {
             IsSpectator = u.IsSpectator.Value;
         }
         if (u.Sync.HasValue)
         {
             SyncStatus = u.Sync.Value;
         }
         if (u.JoinTime.HasValue)
         {
             JoinTime = u.JoinTime.Value;
         }
     }
 }
	    public void UpdateWith(UpdateUserBattleStatus u)
	    {
	        if (u != null) {
                if (u.Name != Name) throw new Exception(string.Format("Applying update of {0} to user {1}", u.Name, Name));
                if (u.AllyNumber.HasValue) AllyNumber = u.AllyNumber.Value;
                if (u.IsSpectator.HasValue) IsSpectator = u.IsSpectator.Value;
                if (u.Sync.HasValue) SyncStatus = u.Sync.Value;
	        }
	    }
예제 #3
0
 public void SetFrom(int status, int color)
 {
     IsReady     = (status & 2) > 0;
     TeamNumber  = (status >> 2) & 15;
     AllyNumber  = (status >> 6) & 15;
     IsSpectator = (status & 1024) == 0;
     SyncStatus  = (SyncStatuses)(int)((status >> 22) & 3);
     Side        = (status >> 24) & 15;
     TeamColor   = color;
 }
		public void SetFrom(int status, int color)
		{
			IsReady = (status & 2) > 0;
			TeamNumber = (status >> 2) & 15;
			AllyNumber = (status >> 6) & 15;
			IsSpectator = (status & 1024) == 0;
			SyncStatus = (SyncStatuses) ((status >> 22) & 3);
			Side = (status >> 24) & 15;
			TeamColor = color;
		}
예제 #5
0
 public UserBattleStatus(string name)
 {
     this.name        = name;
     this.IsReady     = false;
     this.TeamNumber  = 0;
     this.AllyNumber  = 0;
     this.IsSpectator = false;
     this.SyncStatus  = SyncStatuses.Unknown;
     this.Side        = 0;
     this.TeamColor   = 0;
 }
 public UserBattleStatus(string name)
 {
   this.name = name;
   this.IsReady = false;
   this.TeamNumber = 0;
   this.AllyNumber = 0;
   this.IsSpectator = false;
   this.SyncStatus = SyncStatuses.Unknown;
   this.Side = 0;
   this.TeamColor = 0;
   this.ip = IPAddress.None;
 }
예제 #7
0
 public UserBattleStatus(string name)
 {
     this.name   = name;
     IsReady     = false;
     TeamNumber  = 0;
     AllyNumber  = 0;
     IsSpectator = false;
     SyncStatus  = SyncStatuses.Unknown;
     Side        = 0;
     TeamColor   = 0;
     port        = 0;
     ip          = IPAddress.None;
 }
 public UserBattleStatus(string name)
 {
   this.name = name;
   IsReady = false;
   TeamNumber = 0;
   AllyNumber = 0;
   IsSpectator = false;
   SyncStatus = SyncStatuses.Unknown;
   Side = 0;
   TeamColor = 0;
   port = 0;
   ip = IPAddress.None;
 }
        public int GetSyncChangedBattleStatus(SyncStatuses syncStatus)
        {
            var status = 0;

            if (IsReady)
            {
                status |= 2;
            }
            status += (TeamNumber & 15) << 2;
            status += (AllyNumber & 15) << 6;
            if (!IsSpectator)
            {
                status |= 1024;
            }
            status += ((int)syncStatus & 3) << 22;
            status += (Side & 15) << 24;
            return(status);
        }
예제 #10
0
 public void ChangeMyBattleStatus(bool? spectate = null,
                                  bool? ready = null,
                                  SyncStatuses? syncStatus = null,
                                  int? side = null,
                                  int? ally = null,
                                  int? team = null)
 {
     var ubs = MyBattleStatus;
     if (ubs != null)
     {
         var clone = (UserBattleStatus)ubs.Clone();
         clone.SetFrom(lastUserBattleStatus, ubs.TeamColor);
         if (spectate.HasValue) clone.IsSpectator = spectate.Value;
         if (ready.HasValue) clone.IsReady = ready.Value;
         if (syncStatus.HasValue) clone.SyncStatus = syncStatus.Value;
         if (side.HasValue) clone.Side = side.Value;
         if (ally.HasValue) clone.AllyNumber = ally.Value;
         if (team.HasValue) clone.TeamNumber = team.Value;
         if (clone.ToInt() != lastUserBattleStatus)
         {
             SendMyBattleStatus(clone.ToInt(), clone.TeamColor);
             lastUserBattleStatus = clone.ToInt();
         }
     }
 }
		public int GetSyncChangedBattleStatus(SyncStatuses syncStatus)
		{
			var status = 0;
			if (IsReady) status |= 2;
			status += (TeamNumber & 15) << 2;
			status += (AllyNumber & 15) << 6;
			if (!IsSpectator) status |= 1024;
			status += ((int)syncStatus & 3) << 22;
			status += (Side & 15) << 24;
			return status;
		}