// Use this for initialization void Start() { healthText = GetComponent <Text>(); // connect with mainCamera mainCamera = Camera.main; jfpc = mainCamera.GetComponent <JumperFirstPersonController>(); }
// This is the game GUI script, it is used for indicating the Cooldown, Health, and other fantastic // effects void Start() { // init canvas CanvasObject = GetComponent <Canvas>(); CanvasObject.enabled = false; // init camera mainCamera = Camera.main; // init camara script jfpc = Camera.main.GetComponent <JumperFirstPersonController>(); }
// Use this for initialization void Start() { // game start isGameStarted = true; // init camera mainCamera = Camera.main; jfpc = mainCamera.GetComponent <JumperFirstPersonController>(); // To start the game, controller will automatically generate 4 random checkpoints including a goal in the space. // To ensure that all checkpoints are generated for player to move in a general direction rather than move randomly, // hence I divide z direction to 4 parts, so that there will have 4 different sections four generating checkpoint // Assume z max is 5000 (it means that one round of SpaceJumper may use less that 60 seconds) zMax = 20000 + mainCamera.transform.position.z; zMin = 20000 + mainCamera.transform.position.z; float zCoor = Random.Range(zMin, zMax); // create temp array for storing check point position anchorpointList = new Vector3[5]; // create empty z list float[] z = new float[5]; z[0] = zMax; for (int i = 1; i < 5; i++) { z[i] = zCoor / 4.0f * i; } // create checkpoints for (int i = 0; i < 5; i++) { if (i != 4) { x = Random.Range(xMin, xMax); y = Random.Range(yMin, yMax); } else { x = 0; y = 0; spaceshipPos = new Vector3(x, y, z[i]); } (Instantiate(anchorpoint, new Vector3(x, y, z[i]), Quaternion.Euler(0, 0, 0)) as GameObject).GetComponent <AnchorPointScript>().setIndex(i); // add to position list anchorpointList[i] = new Vector3(x, y, z[i]); } // anchor point anchorPointNum = 5; // create Spaceship Instantiate(spaceship, new Vector3(1000, 0, 21000), Quaternion.Euler(0, 90, 0)); // init GUI // init gameoverGUI gameoverGUI = GameObject.FindGameObjectWithTag("gameoverGUI"); gameoverScript = gameoverGUI.GetComponent <GameoverGUIScript>(); // LeftDistance GameObject leftDistanceToSSGUI = GameObject.FindGameObjectWithTag("uiLeftDisToSS"); leftDistanceToSSGUI.GetComponent <LeftDistatnceToSSScript>().initGameController(gameObject); // create guide lines (leftGLInstance = Instantiate(leftGuideLine) as GameObject).GetComponent <LeftGuideLineController>().setPathList(anchorpointList); (rightGLInstance = Instantiate(rightGuideLine) as GameObject).GetComponent <RightGuideLineController>().setPathList(anchorpointList); // Boost Speed of character boostSpeed(); isShakeExecuted = false; }
// Use this for initialization void Start() { jfpc = Camera.main.GetComponent <JumperFirstPersonController>(); speedIndicator = GetComponent <Text>(); }