// Use this for initialization
    void Start () {
        player = FirstPersonScript.player;
        if (defaltPanel)
        {
            interact();
        }
	}
 // Use this for initialization
 void Start()
 {
     player = FirstPersonScript.player;
     panels = PausePanelController.panels;
     int buttonOffset = 0;
     for (int i = 0; i < panels.Length; i++)
     {
         if (panels[i] != null)
         {
             PausePanelController panelController = panels[i];
             if (panelController.teleportController == this)
             {
                 CurrentTeleport.text = "Current Location: " + panelController.teleportController.teleportName;
                 buttonOffset ++;
             }
             else
             {
                 GameObject teleportButtonGameObject = (GameObject)Instantiate(ButtonTemplete);
                 Button teleportButton = teleportButtonGameObject.GetComponent<Button>();
                 RectTransform teleportButtonRectTransform = teleportButton.GetComponent<RectTransform>();
                 Text teleportButtonText = teleportButtonGameObject.GetComponentInChildren<Text>();
                 teleportButton.name = panels[i].teleportController.teleportName;
                 teleportButtonGameObject.SetActive(true);
                 teleportButtonGameObject.transform.SetParent(teleportScreen.gameObject.transform, false);
                 teleportButton.onClick.AddListener(delegate { teleport(panelController); });
                 teleportButtonText.text = panels[i].teleportController.teleportName;
                 teleportButtonGameObject.transform.localPosition = new Vector3(0, topButtonYposition - ((i - buttonOffset) * spaceBetweenButtons + (i - buttonOffset) * teleportButtonRectTransform.rect.height), 0);
             }
         }
     }
 }
    void Awake()
    {
	    //Application.targetFrameRate = 20;
	    // get gravity script
	    gravityOnNormals.attachedPlayer = this;
	    //gravityOnNormals = GetComponent<GravityOnNormals>();

	    // set up the camera rotator
	    playerCamera = GameObject.FindWithTag("MainCamera");
	    cameraRotator.Setup(playerCamera.transform, transform);

	    if (Application.isEditor)
	    {
	        cheatsEnabled = true;
	    }

	    // get the spot light
	    spotlight = GameObject.FindGameObjectWithTag("spot light").GetComponent<Light>();
	    spotlight.gameObject.SetActive(false);

	    playerRigidbody = GetComponent<Rigidbody>();

	    player = this;
	    playerCollider = GetComponent<Collider>();
	    gravityOnNormals.Awake();

	    // lock and hid the mouse
	    if (!cursorHidden)
	    {
	        lockCursor(true);
	    }
	}
 public void teleport(PausePanelController nextPanel)
 {
     if (player == null)
     {
         player = FirstPersonScript.player;
     }
     nextPanel.screenManager.OpenPanel(nextPanel.teleportController.teleportScreen);
     player.gameObject.transform.position = nextPanel.teleportPoint.transform.position;
     player.gameObject.transform.rotation = nextPanel.teleportPoint.transform.rotation;
     player.playerCamera.transform.rotation = new Quaternion(0, 0, 0, 0);
     player.gravityOnNormals.rayCastGround();
     screenManager.CloseCurrent();
 }
Exemple #5
0
 private void Awake()
 {
     if (gameController == null)
     {
         gameController = this;
         DontDestroyOnLoad(this);
     }
     else if (gameController != this)
     {
         Destroy(gameObject);
     }
     powerText.text      = "Power: " + power;
     fps                 = GameObject.FindGameObjectWithTag("Player").GetComponent <FirstPersonScript>();
     fps.actualizarPoder = addPower;
     fps.onItemCollision = fpsItemCollision;
 }
Exemple #6
0
	public void pickUpObject (FirstPersonScript player) {
		if (player != playerScript) {
			playerScript = player;
			playerCamera = player.playerCamera.transform;
			cubeControllerSettings = player.cubeControllerSetting;
		}
		RaycastHit hit;
		transform.position = playerCamera.transform.position + playerCamera.transform.up * .5f;
		springJoint = gameObject.AddComponent<SpringJoint> ();
		springJoint.connectedBody = player.GetComponent<Rigidbody> ();
		springJoint.maxDistance = cubeControllerSettings.distanceFromObject;
		springJoint.minDistance = cubeControllerSettings.distanceFromObject;
		springJoint.spring = cubeControllerSettings.spring;
		springJoint.damper = cubeControllerSettings.damper;
		objectRigidbody.drag = cubeControllerSettings.rigidbodyDrag;
		objectRigidbody.angularDrag = cubeControllerSettings.rigidbodyAnglarDrag;
		if (objectRigidbody.SweepTest (playerCamera.transform.forward, out hit, cubeControllerSettings.distanceFromObject)) {
			transform.position += playerCamera.transform.forward * hit.distance;
		} else {
			transform.position += playerCamera.transform.forward * cubeControllerSettings.distanceFromObject;
		}

		objectPickedUp = true;
		gameObject.layer = 9;
	}