private IEnumerator StartCreateAgents() { AJPHelper.Operation oper = UnitTable.Operation; while (!oper.IsDone) { yield return(null); } int i = 0; int count = UnitTable.Count; UnitRow unitData = null; UserInfoRow user = null; while (i < count) { unitData = UnitTable.ReadOnlyRows[i]; user = Users.GetUserById(unitData.ID_User); Create(unitData, user); i++; yield return(null); } yield break; }
public void S_DEPLOY() { isStartRecord = false; if (positions.Count == 0) { return; } else { UserInfoRow user = SyncData.MainUser; BaseInfoRow baseInfo = SyncData.CurrentMainBase; Dictionary <string, string> data = new Dictionary <string, string>() { { "Server_ID", user.Server_ID }, { "ID_User", user.ID_User.ToString() }, { "ID_Unit", ((int)type).ToString() }, { "Quality", "6" }, { "BaseNumber", baseInfo.BaseNumber.ToString() } }; JSONObject packet = new JSONObject(data); Debugger.Log(packet); Singleton.Instance <EventListenersController>().Emit("S_DEPLOY", packet); //return packet; } }
public static void ToRow(UserInfo bean, UserInfoRow row) { if (bean == null) { return; } row.UserId = bean.UserId; row.Unit = (int)bean.Unit; row.Height = bean.Height; row.Weight = bean.Weight; row.Sex = (int)bean.Sex; row.ZipCode = bean.ZipCode; row.CountryId = bean.CountryId; if (string.IsNullOrWhiteSpace(bean.TimeZoneName)) { if (string.IsNullOrWhiteSpace(row.TimeZoneName)) // only update if not present { row.TimeZoneName = TimeZoneMapper.GetOlsonTimeZoneName(TimeZoneInfo.Local.Id); } } else { row.TimeZoneName = bean.TimeZoneName; } }
internal static UserInfo ToBean(UserInfoRow row) { if (row == null) { return(null); } var bean = new UserInfo(); bean.UserId = row.UserId; bean.Unit = (TUnitType)row.Unit; bean.Height = row.Height; bean.Weight = row.Weight; bean.Sex = (TSexType)row.Sex; bean.ZipCode = row.ZipCode; bean.CountryId = row.CountryId; if (string.IsNullOrWhiteSpace(row.TimeZoneName)) { bean.TimeZoneName = TimeZoneMapper.GetOlsonTimeZoneName(TimeZoneInfo.Local.Id); } else { bean.TimeZoneName = row.TimeZoneName; } return(bean); }
public void LoadUserInfo(JSONObject serMsg) { serMsg[0].GetField(ref User_ID, "ID_User"); UserInfos.LoadTable(serMsg); MainUser = UserInfos.GetUserById(User_ID); }
public override void Load(params object[] input) { JSONTable_Friends friends = SyncData.FriendTable; JSONTable_UserInfo users = SyncData.UserInfos; UserInfoRow user = null; for (int i = 0; i < friends.Count; i++) { FriendRow friendInfo = friends.ReadOnlyRows[i]; if (IsAlreadyFriend(friendInfo)) { user = users.GetUserById(friendInfo.ID_Player); FriendTag tag = GetFriendTag(friendInfo); tag.UserName.text = user.NameInGame; tag.RemoveButton.OnClickEvents += delegate { OnUnfriendButton(friendInfo); ReleaseTag(tag); }; tag.gameObject.SetActive(true); } } }
/// <summary> /// Create data in database /// </summary> /// <param name="userInfo">UserInfo</param> /// <returns>insert data</returns> public UserInfo Create(UserInfo userInfo) { if (userInfo == null || string.IsNullOrWhiteSpace(userInfo.UserId)) { return(null); } var row = new UserInfoRow(); UserInfoTransformer.ToRow(userInfo, row); _dbContext.Insert(row); return(UserInfoTransformer.ToBean(row)); }
public void SetInfo(UnitRow info, UserInfoRow user, bool isOwner) { agentInfo = info; userInfo = user; SetMaxHP(agentInfo.Health); SetHp(agentInfo.Hea_cur); SetQuality(agentInfo.Quality); string nameFormat = isOwner ? "{0}" : "<color=red>{0}</color>"; SetNameInGame(string.Format(nameFormat, userInfo.ID_User + ": " + " Id " + agentInfo.ID)); }
public override void Load(params object[] input) { JSONTable_Friends friends = SyncData.FriendTable; JSONTable_UserInfo users = SyncData.UserInfos; for (int i = 0; i < friends.Count; i++) { FriendRow info = friends.ReadOnlyRows[i]; if (info.AcceptTime != 0.0f) { UserInfoRow user = users.GetUserById(info.ID_Player); AddFriendTag(info, user); } } }
private void R_DEPLOY(SocketIOEvent obj) { Debugger.Log(obj); string json = obj.data["R_DEPLOY"].ToString(); UnitRow unit = JsonUtility.FromJson <UnitRow>(json); UserInfoRow user = SyncData.UserInfos.GetUserById(unit.ID_User); unitDataReference.Create(unit, user); JSONTable_Unit units = SyncData.UnitTable; units.Insert(unit); //SelectAgentPanel.Add(unit); //Debugger.Log("added " + unit.ID); }
private JSONObject S_UPGRADE() { UserInfoRow userInfo = SyncData.MainUser; Dictionary <string, string> data = new Dictionary <string, string>() { { "ID_Server", userInfo.Server_ID }, { "ID_User", userInfo.ID_User.ToString() }, { "BaseNumber", currentMainBase.BaseNumber.ToString() }, { "ID_Upgrade", ((int)refUpgType.ID).ToString() }, { "UpgradeType", refUpgType.UpgradeType.ToString() }, { "Level", refUpgType.Level.ToString() } }; return(new JSONObject(data)); }
private void OnFindFriendButton() { ReleaseFriendTags(); string userName = UserNameInput.Text; if (string.IsNullOrEmpty(userName)) { Debugger.Log("player name is empty"); return; } JSONTable_UserInfo users = SyncData.UserInfos; UserInfoRow foundUser = users.GetUserByName(userName); if (foundUser != null) { FriendRow friendInfo = FriendTable.GetFriendInfoById(foundUser.ID_User); if (friendInfo == null) { if (foundUser.ID_User != SyncData.User_ID) { CreateFriendTag ( new FriendRow() { ID_Player = foundUser.ID_User, RequestBool = true, }, foundUser, false ); } } else { CreateFriendTag ( friendInfo, foundUser, true ); } } else { NotFoundMessage.gameObject.SetActive(true); } }
public static void ToRow(UserInfo bean, UserInfoRow row) { if (bean == null) { return; } row.UserId = bean.UserId; row.Unit = (int)bean.Unit; row.Height = bean.Height; row.Weight = bean.Weight; row.Sex = (int)bean.Sex; row.ZipCode = bean.ZipCode; row.CountryId = bean.CountryId; row.TimeZoneName = bean.TimeZoneName; }
public void Create(UnitRow unitData, UserInfoRow user) { AgentRemote agentRemote = AgentPooling.GetItem(unitData.ID_Unit); if (agentRemote == null || user == null) { return; } else { agentRemote.Dispose(); this.AddAgent(unitData.ID, agentRemote); LightweightLabel label = labelPooling.GetItem(); agentRemote.transform.position = MapIns.CellToWorld(unitData.Position_Cell.Parse3Int().ToClientPosition()); agentRemote.OnDead += delegate { AgentPooling.Release(agentRemote.Type, agentRemote); labelPooling.Release(label); MyAgentRemoteManager.Remove(agentRemote.AgentID); this.RemoveAgent(agentRemote.AgentID); }; label.Initalize(agentRemote, MainCamera); bool isOwner = unitData.ID_User == PlayerInfo.Info.ID_User; agentRemote.Initalize(UnitTable, label, unitData, user, isOwner); if (isOwner) { if (agentRemote.NavAgent == null) { agentRemote.gameObject.AddComponent <NavAgent>(); } MyAgentRemoteManager.Add(agentRemote); agentRemote.name = "Owner " + unitData.ID; } else { agentRemote.name = "other " + unitData.ID; } agentRemote.gameObject.SetActive(true); } }
private JSONObject S_DEPLOY() { UserInfoRow user = SyncData.MainUser; BaseInfoRow baseInfo = SyncData.CurrentMainBase; Dictionary <string, string> data = new Dictionary <string, string>() { { "Server_ID", user.Server_ID }, { "ID_User", user.ID_User.ToString() }, { "ID_Unit", ((int)refTag.Type).ToString() }, { "Quality", ((int)refTag.Slider.Value).ToString() }, { "BaseNumber", baseInfo.BaseNumber.ToString() } }; JSONObject packet = new JSONObject(data); Debugger.Log(packet); return(packet); }
internal static UserInfo ToBean(UserInfoRow row) { if (row == null) { return(null); } var bean = new UserInfo(); bean.UserId = row.UserId; bean.Unit = (TUnitType)row.Unit; bean.Height = row.Height; bean.Weight = row.Weight; bean.Sex = (TSexType)row.Sex; bean.ZipCode = row.ZipCode; bean.CountryId = row.CountryId; bean.TimeZoneName = row.TimeZoneName; return(bean); }
private JSONObject S_TRAINING() { UserInfoRow user = SyncData.MainUser; BaseInfoRow baseInfo = SyncData.CurrentMainBase; Dictionary <string, string> data = new Dictionary <string, string>() { { "ID_User", user.ID_User.ToString() }, { "Server_ID", user.Server_ID.ToString() }, { "BaseNumber", baseInfo.BaseNumber.ToString() }, { "ID_Unit", ((int)refType.ID).ToString() }, { "Level", refType.Level.ToString() }, { "Quality", quality.ToString() }, }; JSONObject result = new JSONObject(data); Debug.Log(result.ToString()); return(result); }
public void Initalize( JSONTable_Unit subject, LightweightLabel label, UnitRow unitData, UserInfoRow user, bool isOwner) { Label = label; unitSubject = subject; AgentInfo.UserInfo = user; AgentInfo.UnitInfo = unitData; IsOwner = isOwner; //string format = IsOwner ? "{0}" : "<color=red>{0}</color>"; // not friend //if (!IsOwner) //{ // bool isFriend = Singleton.Instance<FriendSys>().IsMyFriend(user.ID_User); // format = isFriend ? "<color=green>{0}</color>" : format; // friend //} string format = GetLabelFormat(); Label.NameInGame = string.Format(format, "Id " + unitData.ID + ": " + user.NameInGame); Label.SetHP(unitData.Hea_cur, unitData.Health); Label.Quality = unitData.Quality; Label.gameObject.SetActive(true); observer = subject.ObserverPooling.GetItem(); observer.RefreshSubject(unitData); observer.OnSubjectUpdated += SubjectChanged; subject.Register(observer); }
private void AddFriendTag(FriendRow info, UserInfoRow user) { FriendTag tag = GetFriendTag(info); tag.UserName.text = user.NameInGame; tag.Describe.text = "Waiting " + info.AcceptTimeString(); tag.RemoveButton.OnClickEvents += delegate { OnRejectButton(info); ReleaseTag(tag); }; if (!info.RequestBool) { //tag.Add_AcceptButon.gameObject.SetActive(true); tag.Add_AcceptButon.OnClickEvents += delegate { OnAcceptButton(info); ReleaseTag(tag); }; } tag.gameObject.SetActive(true); }
private void InitMessage( List <Vector3Int> clientPath, List <float> separateTime, Vector3Int curPosition, AgentRemote ownerRemote, AgentRemote enemyRemote) { curPosition = curPosition.ToSerPosition(); List <Vector3Int> serverPath = new List <Vector3Int>(clientPath); for (int i = 0; i < serverPath.Count; i++) { serverPath[i] = serverPath[i].ToSerPosition(); } serverPath = serverPath.Invert(); int ownerUnitType = (int)ownerRemote.Type; int ownerAgentId = ownerRemote.AgentID; string attack_unit_id = "NULL"; const string format = "{{" + "\"Server_ID\":" + "{0}," + "\"ID\":" + "{1}," + "\"ID_Unit\":" + "{2}," + "\"ID_User\":" + "{3}," + "\"Position_Cell\":" + "\"{4}\"," + "\"Next_Cell\":" + "\"{5}\"," + "\"End_Cell\":" + "\"{6}\"," + "\"TimeMoveNextCell\":" + "{7}," + "\"TimeFinishMove\":" + "{8}," + "\"ListMove\":" + "{9}," + "\"Attack_Unit_ID\":" + "\"{10}\"" + "}}"; UserInfoRow user = ownerRemote.UserInfo; Vector3Int endPosition = serverPath[serverPath.Count - 1]; if (enemyRemote != null) { UserInfoRow otherUser = enemyRemote.UserInfo; attack_unit_id = string.Format("{0}_{1}_{2}_{3}", user.Server_ID, (int)enemyRemote.Type, otherUser.ID_User, enemyRemote.AgentID); } moveJson = string.Format(format, user.Server_ID, ownerAgentId, ownerUnitType, user.ID_User, curPosition.ToPositionString(), serverPath[0].ToPositionString(), endPosition.ToPositionString(), GMath.SecondToMilisecond(GMath.Round(separateTime[0], 3)), GMath.SecondToMilisecond(GMath.Round(separateTime.Sum(), 3)), GetJsonFrom1(serverPath, separateTime, serverPath[0]), attack_unit_id ); moveJson = string.Format("{{\"S_MOVE\":{0}}}", moveJson); }
private void CreateFriendTag(FriendRow friendInfo, UserInfoRow userInfo, bool isExisted) { FriendTag tag = GetFriendTag(friendInfo); tag.UserName.text = userInfo.NameInGame; if (isExisted) { bool alreadyFriend = IsAlreadyFriend(friendInfo); bool waitingAccept = IsWaitingAccept(friendInfo); bool waitingRemove = IsWaitingUnFriend(friendInfo); tag.UserName.text = userInfo.NameInGame; if (alreadyFriend) { tag.RemoveButton.OnClickEvents += delegate { OnUnfriendButton(friendInfo); ReleaseTag(tag); }; } else if (waitingAccept) { tag.RemoveButton.OnClickEvents += delegate { OnRejectButton(friendInfo); ReleaseTag(tag); }; tag.Add_AcceptButon.OnClickEvents += delegate { OnAcceptButton(friendInfo); ReleaseTag(tag); }; } //else if(waitingRemove) //{ // tag.RemoveButton.gameObject.SetActive(false); // tag.Add_AcceptButon.gameObject.SetActive(false); //} string acceptTime = friendInfo.AcceptTime != 0.0f ? "Waiting " + friendInfo.AcceptTimeString() : null; string removeTime = friendInfo.RemoveTime != 0.0f ? "Removing " + friendInfo.RemoveTimeString() : null; tag.Describe.text = acceptTime + removeTime; } else { // doesn't friend tag.RemoveButton.gameObject.SetActive(false); tag.Add_AcceptButon.gameObject.SetActive(true); tag.Add_AcceptButon.OnClickEvents += delegate { OnAddFriendButton(friendInfo); ReleaseTag(tag); }; } tag.gameObject.SetActive(true); }
public UserInfoRowChangeEvent(UserInfoRow row, global::System.Data.DataRowAction action) { this.eventRow = row; this.eventAction = action; }