Ejemplo n.º 1
0
    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);
                });
            }
        }
    }
Ejemplo n.º 2
0
 private void UpdateClientCounter(RTSClient cl)
 {
     _actionQueue.Enqueue(() =>
     {
         ClientCountLabel.GetComponent <Text>().text = "Connected clients: " + SM.Server.clients.Count;
     });
 }
Ejemplo n.º 3
0
    private void DestroyActor(RTSClient cl)
    {
        var cp = clientProperties[cl];

        Destroy(cp.gameObject);
        cp.gameObject = null;
    }
Ejemplo n.º 4
0
 private void MoveCameraOnFirstActor(RTSClient cl)
 {
     _actionQueue.Enqueue(() =>
     {
         var targetPos = WorldUtils.L2ToUnityCoords(cl.UserChar.X, cl.UserChar.Y, 0);
         MainCamera.GetComponent <CameraMovement>().LookAt(targetPos);
     });
 }
Ejemplo n.º 5
0
 private void RemoveClientFromList(RTSClient cl)
 {
     _actionQueue.Enqueue(() =>
     {
         Destroy(clientProperties[cl].gameObject);
         clientProperties.Remove(cl);
     });
 }
Ejemplo n.º 6
0
 private void UpdateClientInfo(RTSClient cl)
 {
     _actionQueue.Enqueue(() =>
     {
         SetName(cl.UserChar.Name);
         SetStatus(cl.UserChar.Status.ToString());
         SetStatusColor();
     });
 }
Ejemplo n.º 7
0
 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);
         }
     });
 }
Ejemplo n.º 8
0
 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;
     });
 }
Ejemplo n.º 9
0
    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;
    }
Ejemplo n.º 10
0
    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();
    }
Ejemplo n.º 11
0
    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();
    }
Ejemplo n.º 12
0
 protected void Start()
 {
     client          = actor.client;
     AIStateChanged += SM.userActorManager.clientProperties[client].panel.OnAIStateChanged;
     SwitchState(GetDefaultState());
 }
Ejemplo n.º 13
0
 private void UpdateStatus(RTSClient cl)
 {
     _actionQueue.Enqueue(SetStatusColor);
 }
Ejemplo n.º 14
0
 private void AddClientToList(RTSClient cl)
 {
     clientProperties.Add(cl, new ActorProperties());
     cl.StatusPacketEvent += ManagePresence;
 }