Пример #1
0
    // Use this for initialization
    void Start()
    {
        mPlayer        = gameObject.GetComponent <PlayerPhysics>();
        mPickupManager = gameObject.GetComponent <PlayerPickupManager>();

        mInControl        = false;
        mReversedControls = false;
        mThrust           = 1.0f; //Random.Range(0.5f, 1.0f);
        mTargetPickup     = null;

        GeneratePersonality(0.4f, 0.9f);
        //mPersonality.mAwayFromEdges = 0.5f;
        //mPersonality.mEarlySteer = 0.65f;
    }
Пример #2
0
    private void CmdSwapItems(NetworkInstanceId handId, NetworkInstanceId socketManagerId, int socketNumber)
    {
        if (debug)
        {
            Debug.Log("PlayerToolbeltManager Server: The client has asked us to swap items between their hand and their toolbelt");
        }

        /* Get our hand manager */
        HandManager hand = InternalGetHand(handId);

        if (hand == null)
        {
            return;
        }

        /* Get the socket that the client provided */
        SojournSocket socket = GetSojournSocket(socketManagerId, socketNumber);

        if (socket == null)
        {
            return;
        }

        /* Conver the socket into a toolbelt slot */
        PlayerToolbeltSlot toolbeltSlot = (PlayerToolbeltSlot)socket;

        if (toolbeltSlot == null)
        {
            Debug.LogError("PlayerToolbeltManager Server: The client sent us a bad toolbelt slot!");
            return;
        }

        /* Get the attached object from the toolbelt slot */
        GameObject attachedObj = toolbeltSlot.GetAttachedObject();

        if (attachedObj == null)
        {
            Debug.LogError("SojournToolbeltManager Server: There is nothing attached to this toolbelt slot!");
            return;
        }

        /* Get the toolbelt item from the socket */
        SojournItem toolbeltItem = attachedObj.GetComponent <SojournItem>();

        if (toolbeltItem == null)
        {
            return;
        }

        /* Make the toolbelt item pickupable */
        toolbeltItem.SetCanBePickedUp(true);

        if (debug)
        {
            Debug.Log("PlayerToolbeltManager Server: We are allowing the swap");
        }

        /* Get the object from the player's hand */
        GameObject handItemObj = hand.GetPickedUpObject();

        if (handItemObj == null)
        {
            throw new System.Exception("There is supposed to be something in our hand!");
        }

        /* Get the sojourn item component from the hand object */
        SojournItem handItem = handItemObj.GetComponent <SojournItem>();

        if (handItem == null)
        {
            throw new System.Exception("Why is this player holding something that isn't a sojourn item!");
        }

        /* Detach the item from the toolbar socket */
        if (!toolbeltItem.ServerDetach())
        {
            throw new System.Exception("Failed to detach item from toolbelt!");
        }

        /* Attach The item to the toolbar */
        if (!handItem.ServerAttach(toolbeltSlot, playerController))
        {
            throw new System.Exception("Failed to attach hand item to toolbelt!");
        }

        PlayerPickupManager pickup = hand.GetPlayerController().GetComponent <PlayerPickupManager>();

        Debug.Assert(pickup != null);

        /* Tell the player to pickup the item on their toolbelt */
        if (!pickup.ClientPickUp(hand, toolbeltItem))
        {
            throw new System.Exception("Failed to pickup item that was attached to our toolbelt!");
        }

        if (debug)
        {
            Debug.Log("PlayerToolbeltManager Server: We have swapped the items");
        }
    }
Пример #3
0
    private void CmdPickupItem(NetworkInstanceId handId, NetworkInstanceId socketManagerId, int socketNumber)
    {
        if (debug)
        {
            Debug.Log("PlayerToolbeltManager Server: The client has asked us to swap items between their hand and their toolbelt");
        }

        /* Get our hand manager */
        HandManager hand = InternalGetHand(handId);

        if (hand == null)
        {
            return;
        }

        /* Get the socket that the client provided */
        SojournSocket socket = GetSojournSocket(socketManagerId, socketNumber);

        if (socket == null)
        {
            return;
        }

        /* Convert the socket into a toolbelt slot */
        PlayerToolbeltSlot toolbeltSlot = (PlayerToolbeltSlot)socket;

        if (toolbeltSlot == null)
        {
            Debug.LogError("PlayerToolbeltManager Server: The client sent us a bad toolbelt slot!");
            return;
        }

        /* Get the attached object from the toolbelt slot */
        GameObject attachedObj = toolbeltSlot.GetAttachedObject();

        if (attachedObj == null)
        {
            Debug.LogError("SojournToolbeltManager Server: There is nothing attached to this toolbelt slot!");
            return;
        }

        /* Get the toolbelt item from the socket */
        SojournItem toolbeltItem = attachedObj.GetComponent <SojournItem>();

        if (toolbeltItem == null)
        {
            return;
        }

        /* Make the toolbelt item pickupable */
        toolbeltItem.SetCanBePickedUp(true);

        /* Get the player controller for this player */
        PlayerEntityController player = hand.GetPlayerController();

        if (player == null)
        {
            throw new System.Exception("Why is there no player controller for this hand?");
        }

        /* Get the player pickup manager for this hand */
        PlayerPickupManager pickup = player.GetComponent <PlayerPickupManager>();

        if (!pickup.ServerPickUp(hand, toolbeltItem))
        {
            throw new System.Exception("Failed to have player pickup item on toolbelt!");
        }

        if (debug)
        {
            Debug.Log("PlayerToolbeltManager Server: Player picked up item from their toolbelt.");
        }
    }