private void ManagePresence(RTSClient cl) { if (cl.UserChar.Status == LA2UserChar.ClientStatus.InGame) { if (clientProperties[cl].gameObject == null) { if (clientProperties.Values.All(p => p.gameObject == null)) { cl.FirstPositionPacketEvent += MoveCameraOnFirstActor; } _actionQueue.Enqueue(() => { CreateActor(cl); SM.selectionManager.UpdateSelectedUsers(); }); } } else { if (clientProperties[cl].gameObject != null) { cl.FirstPositionPacketEvent -= MoveCameraOnFirstActor; _actionQueue.Enqueue(() => { DestroyActor(cl); }); } } }
private void UpdateClientCounter(RTSClient cl) { _actionQueue.Enqueue(() => { ClientCountLabel.GetComponent <Text>().text = "Connected clients: " + SM.Server.clients.Count; }); }
private void DestroyActor(RTSClient cl) { var cp = clientProperties[cl]; Destroy(cp.gameObject); cp.gameObject = null; }
private void MoveCameraOnFirstActor(RTSClient cl) { _actionQueue.Enqueue(() => { var targetPos = WorldUtils.L2ToUnityCoords(cl.UserChar.X, cl.UserChar.Y, 0); MainCamera.GetComponent <CameraMovement>().LookAt(targetPos); }); }
private void RemoveClientFromList(RTSClient cl) { _actionQueue.Enqueue(() => { Destroy(clientProperties[cl].gameObject); clientProperties.Remove(cl); }); }
private void UpdateClientInfo(RTSClient cl) { _actionQueue.Enqueue(() => { SetName(cl.UserChar.Name); SetStatus(cl.UserChar.Status.ToString()); SetStatusColor(); }); }
private void RemoveClientFromList(RTSClient cl) { _actionQueue.Enqueue(() => { var clSearchRes = ClientList.GetComponentsInChildren <ClientPanelScript>().SingleOrDefault(c => c.client.clientID == cl.clientID); if (clSearchRes != null) { Destroy(clSearchRes.gameObject); } }); }
private void AddClientToList(RTSClient cl) { _actionQueue.Enqueue(() => { GameObject newClientPanel = Instantiate(ClientPanelPrefab, ClientList.transform); var cps = newClientPanel.GetComponent <ClientPanelScript>(); cps.client = cl; cps.SetHighlight(false); SM.userActorManager.clientProperties[cl].panel = cps; }); }
private void CreateActor(RTSClient cl) { var newActor = Instantiate(UserActorPrefab, WorldUtils.L2ToUnityCoords(cl.UserChar.X, cl.UserChar.Y, 0), WorldUtils.ActorDefaultRotation()); var uas = newActor.GetComponent <UserActorScript>(); uas.client = cl; var cp = clientProperties[cl]; cp.gameObject = newActor; cp.actorScript = uas; }
public void AddUserSelection(RTSClient cl) { foreach (var kv in SM.userActorManager.clientProperties) { if (kv.Key == cl) { if (!kv.Value.isSelected) { kv.Value.isSelected = true; } break; } } ClearPlayerSelection(); ClearNpcSelection(); SelectionChangedEvent?.Invoke(); }
public void RemoveUserSelection(RTSClient cl) { foreach (var kv in SM.userActorManager.clientProperties) { if (kv.Value == null) { continue; } if (kv.Key == cl) { if (kv.Value.isSelected) { kv.Value.isSelected = false; } break; } } SelectionChangedEvent?.Invoke(); }
protected void Start() { client = actor.client; AIStateChanged += SM.userActorManager.clientProperties[client].panel.OnAIStateChanged; SwitchState(GetDefaultState()); }
private void UpdateStatus(RTSClient cl) { _actionQueue.Enqueue(SetStatusColor); }
private void AddClientToList(RTSClient cl) { clientProperties.Add(cl, new ActorProperties()); cl.StatusPacketEvent += ManagePresence; }