Ejemplo n.º 1
0
    /**
     * enter
     * =====
     * Called to switch from player to minigame view and "check-out" this minigame
     *
     * @param: p - Player wanting to enter this minigame
     */
    public virtual void enter(GameObject p)
    {
        HoverHUD.GetComponentInChildren <Text>().text = hud;
        inUse  = true;
        player = p;

        player.GetComponent <Player>().stopHover();

        Camera c  = viewpoint.GetComponent <Camera>();
        Camera c2 = player.GetComponentInChildren <Camera>();

        c2.enabled = false;
        c.rect     = c2.rect;
        c.enabled  = true;
        gameObject.GetComponent <Interactable>().HoverHUD.GetComponent <CanvasGroup>().alpha = 0f;
        HUD.GetComponent <CanvasGroup>().alpha = 1f;
        controller = player.GetComponent <Controller>();

        player.GetComponent <Player>().hideCrosshair();

        CustomFirstPersonController cfpc = player.GetComponent <CustomFirstPersonController>();
        Player playerScript = player.GetComponent <Player>();

        cfpc.enabled         = false;
        playerScript.enabled = false;

        //player.SetActive(false);
    }
 // Start is called before the first frame update
 void Start()
 {
     healthGO     = FindObjectOfType <PlayerHealth>();
     FPController = FindObjectOfType <CustomFirstPersonController>();
     Debug.Log("CurrentUpgradeVisual instantiated");
     updateStaminaVisuals(0, FPController.GetMaxStamina(), GameObject.Find("BuyMenu").GetComponent <Shop>().get_UPGRADE_COST());
 }
Ejemplo n.º 3
0
    public override void OnStartLocalPlayer()
    {
        localPlayer = this;

        CmdSetPlayerID(Network.player.ipAddress);

        inventory = GetComponent <PlayerInventory> ();

        animationController = GetComponent <PlayerAnimationController> ();

        uiManager = GameObject.FindObjectOfType <UIManager> ();
        if (!uiManager)
        {
            Debug.LogException(new System.Exception("No UIManager object found in scene"));
        }


        playerMesh       = transform.Find("Player Model/Mesh").gameObject;     // Set mesh to "Local Player Mesh" layer, which is culled by player's camera
        playerMesh.layer = 8;                                                  // ...so the player doesn't see his own body

        playerHands = transform.Find("Camera/Player Hands").gameObject;
        playerHands.SetActive(true);

        foreach (Transform child in transform.Find("Player Model").GetComponentsInChildren <Transform>())
        {
            if (child.tag == "Right Hand Third Person")
            {
                thirdPersonRightHand = child.gameObject;
                break;
            }
        }

        foreach (Transform child in thirdPersonRightHand.GetComponentsInChildren <Transform>())
        {
            child.gameObject.layer = 8;
        }

        // Enable camera and controller components for just the local instance

        camera         = GetComponentInChildren <Camera> ();
        camera.enabled = true;

        Debug.Log(camera);

        audioListener         = GetComponentInChildren <AudioListener> ();
        audioListener.enabled = true;

        firstPersonController         = GetComponent <CustomFirstPersonController> ();
        firstPersonController.enabled = true;


        uiManager.UpdateInventoryPanelsAfterSync();
        uiManager.EnableCursorLock();

        GameObject.FindObjectOfType <Canvas> ().worldCamera   = camera;
        GameObject.FindObjectOfType <Canvas> ().planeDistance = 0.1f;

        DebugID();
    }
Ejemplo n.º 4
0
    /**
     * exit
     * ====
     * Exit minigame and change perspective back to player
     */
    public virtual void exit()
    {
        CustomFirstPersonController cfpc = player.GetComponent <CustomFirstPersonController>();
        Player playerScript = player.GetComponent <Player>();

        sfx.playCancel();

        cfpc.enabled         = true;
        playerScript.enabled = true;

        player.GetComponent <Player>().showCrosshair();

        player.GetComponentInChildren <Camera>().enabled = true;
        viewpoint.GetComponent <Camera>().enabled        = false;
        HUD.GetComponent <CanvasGroup>().alpha           = 0f;
        GameObject.Find("CrossHair").GetComponent <CanvasGroup>().alpha = 1f;
        player = null;
        inUse  = false;
    }