Пример #1
0
    public static void ControlHumanoid(HumanPlayer player)
    {
        if (player == null || player.entity == null || !entity2Homonid.ContainsKey(player.entity) || player2Entity.ContainsValue(player.entity))
        {
            return;
        }

        ControllableHomonid availableAgent = entity2Homonid [player.entity];

        if (availableAgent == null || player == null || player.GetInputDevice() == null)
        {
            return;
        }
        //dbg code
        UnityEditor.Selection.activeGameObject = availableAgent.gameObject;
        var inputDevice = player.GetInputDevice();

        Debug.Log("asserting controll");
        if (inputDevice != null)
        {
            foreach (var entry in displaysMap)
            {
                if (entry.Value == availableAgent.gameObject)
                {
                    TakeControlOf(entry.Key);
                }
            }
            player.TakeControlOf(availableAgent);
        }
    }
Пример #2
0
    public static void ReleaseHumanoid(HumanPlayer player)
    {
        if (player == null || player.entity == null || !entity2Homonid.ContainsKey(player.entity) || player2Entity.ContainsValue(player.entity))
        {
            return;
        }
        ControllableHomonid availableAgent = entity2Homonid [player.entity];

        if (availableAgent == null || player == null || player.GetInputDevice() == null)
        {
            return;
        }
        var inputDevice = player.GetInputDevice();

        Debug.Log("releasing controll");
        player2Entity.Remove(player);
        ReleaseControlOf(player.entity);
    }