public void Initalize(AgentRemote remote, Camera cam) { canvasCamera = cam; navRemote = remote; active = true; //gameObject.SetActive(true); }
private AgentRemote CreatePoolingItem(int id, ListUpgrade type) { AgentRemote remote = Create(type); remote?.FirstSetup(id); return(remote); }
private bool AddAgent(int id, AgentRemote remote) { if (!AllAgents.ContainsKey(id)) { AllAgents.Add(id, remote); return(true); } return(false); }
public void Move(List <Vector3Int> path, List <float> separateTime, Vector3Int curCellPosition, AgentRemote ownerRemote, AgentRemote otherRemote) { InitMessage(path, separateTime, curCellPosition, ownerRemote, otherRemote); Emit("S_MOVE");; }
private void Attack_Action() { AgentRemote owner = NavAgentController.CurrentAgent.Remote; AgentRemote enemy = NavAgentController.GetEnemyAt(NavAgentController.CursorController.SelectedPosition); if (!FriendSys.IsMyFriend(enemy.UserInfo.ID_User)) { SIO_AttackListener.S_ATTACK(owner, enemy); } }
public void Dispose() { SetHP(1, 1); NameInGame = ""; Quality = 0; active = false; navRemote = null; canvasCamera = null; gameObject.SetActive(false); }
private void LoadAgents() { Object[] objs = AssetUtil.Load(@"Prefabs\Agents"); for (int i = 0; i < objs.Length; i++) { GameObject go = objs[i] as GameObject; AgentRemote remote = go.GetComponent <AgentRemote>(); int hashCode = remote.Type.GetHashCode(); AgentPrefabs[hashCode] = remote; } }
public void Release(ListUpgrade type, AgentRemote agent) { if (AgentPools.TryGetValue(type.GetHashCode(), out Pooling <AgentRemote> pool)) { pool.Release(agent); } else { CreatePool(type).Release(agent); } }
private void OnSelected(AgentRemote remote) { ResizeAnimation.Close(); MyAgentManager.ActiveNav(remote.AgentID); Vector3Int position = remote.CurrentPosition; CameraGroup.CameraMoveToAgent(position); VisiableCancelButton(); selectedId = remote.AgentID; }
public void R_MOVE(SocketIOEvent obj) { //Debugger.Log(obj.ToString().Substring(0,150)); JSONObject r_move = obj.data["R_MOVE"]; int id = -1; r_move.GetField(ref id, "ID"); if (!MyAgentManager.IsOwnerAgent(id)) { AgentRemote agent = AgentManager.GetAgentRemote(id); agent?.FixedMove.StartMove(r_move); } }
private Vector3Int FindNextValidPosition(int unitId) { bool isOwnerAgent = AgentManager.IsOwnerAgent(unitId); if (!isOwnerAgent) { agentRemote = AgentManager.GetAgentRemote(unitId); if (agentRemote != null) { breathFS.GetNearestCell(agentRemote.CurrentPosition, out Vector3Int res); return(res); } } return(Generic.Contants.Constants.InvalidPosition); }
public void Add(AgentRemote remote) { SelectableAgentElement el = selectablePooling.GetItem(); el.PlaceholderComp.Text = remote.AgentID.ToString(); el.SelectableComp.OnClickEvents += delegate { OnSelected(remote); }; el.gameObject.SetActive(true); el.RectTransform.SetAsLastSibling(); Catcher.Add(el); }
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 void InitBaseDefend() { // Debugger.Log(baseDefends.Length + " " + baseInfo.Count); ReadOnlyCollection <BaseInfoRow> baseInfoRows = SyncData.BaseInfos.ReadOnlyRows; for (int i = 0; i < baseDefends.Length && i < baseInfo.Count; i++) { Vector3 basePos = Map.CellToWorld(baseInfoRows[i].Position.Parse3Int().ToClientPosition()); for (int j = 0; j < baseDefends[i].Count; j++) { BaseDefendRow row = baseDefends[i].ReadOnlyRows[j]; AgentRemote agent = Manager.GetItem(row.ID_Unit); if (agent != null) { agent.transform.position = basePos; agent.gameObject.SetActive(true); } } } }
public JSONObject CreateAttackInfo(AgentRemote ownerRemote, AgentRemote otherRemote) { InfoDict.Clear(); UnitRow ownerUnit = ownerRemote.UnitInfo; UnitRow otherUnit = otherRemote.UnitInfo; InfoDict["Server_ID"] = ownerRemote.UserInfo.Server_ID; InfoDict["ID_Attack"] = ownerUnit.ID.ToString(); InfoDict["ID_Unit_Attack"] = ((int)ownerUnit.ID_Unit).ToString(); InfoDict["ID_User_Attack"] = ownerUnit.ID_User.ToString(); InfoDict["ID_Defend"] = otherUnit.ID.ToString(); InfoDict["ID_Unit_Defend"] = ((int)otherUnit.ID_Unit).ToString(); InfoDict["ID_User_Defend"] = otherUnit.ID_User.ToString(); InfoDict["Position_Cell_Attacker"] = ownerRemote.CurrentPosition.ToSerPosition().ToPositionString(); JSONObject data = new JSONObject(infoDict); Debugger.Log(data); return(data); }
public void R_DEPLOY(SocketIOEvent obj) { //Debugger.Log(obj); string json = obj.data["R_DEPLOY"].ToString(); UnitRow unit = JsonUtility.FromJson <UnitRow>(json); AgentRemote agent = MyAgent.GetNavRemote(unit.ID); int posCount = positions.Count; if (agent != null && posCount > 0) { agent.NavAgent.AsyncStartMove(agent.CurrentPosition, positions[posCount - 1], null); positions.RemoveAt(posCount - 1); if (positions.Count > 0) { Debugger.Log("start coroutine"); StartCoroutine(DeployCoroutine()); } } else { Debugger.Log("Agent null " + unit.ID); } }
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 Awake() { agent = GetComponent <AgentRemote>(); }
public void S_ATTACK(AgentRemote owner, AgentRemote other) { JSONObject attackInfo = AttackInfoGenerator.CreateAttackInfo(owner, other); Emit("S_ATTACK", attackInfo); }