void Awake() { //Check for Current Player in the scene GameObject currentPlayer = GameObject.FindWithTag("Player"); if (currentPlayer) { // If there are the player in the scene already. Check for the Spawn Point Name // If it match then Move Player to the SpawnpointPosition string spawnPointName = currentPlayer.GetComponent <StatusC>().spawnPointName; GameObject spawnPoint = GameObject.Find(spawnPointName); if (spawnPoint) { currentPlayer.transform.position = spawnPoint.transform.position; currentPlayer.transform.rotation = spawnPoint.transform.rotation; } GameObject oldCam = currentPlayer.GetComponent <AttackTriggerC>().Maincam.gameObject; if (!oldCam) { return; } GameObject[] cam = GameObject.FindGameObjectsWithTag("MainCamera"); foreach (GameObject cam2 in cam) { if (cam2 != oldCam) { Destroy(cam2.gameObject); } } // If there are the player in the scene already. We will not spawn the new player. return; } //Spawn Player GameObject spawnPlayer = Instantiate(player, transform.position, transform.rotation) as GameObject; mainCam = GameObject.FindWithTag("MainCamera").transform; ARPGcameraC checkCam = mainCam.GetComponent <ARPGcameraC>(); //Check for Main Camera if (mainCam && checkCam) { mainCam.GetComponent <ARPGcameraC>().target = spawnPlayer.transform; } /*else if(mainCam){ * Destroy (mainCam.gameObject); * }*/ Screen.lockCursor = true; //Set Target for All Enemy to Player GameObject[] mon; mon = GameObject.FindGameObjectsWithTag("Enemy"); foreach (GameObject mo in mon) { if (mo) { mo.GetComponent <AIsetC>().followTarget = spawnPlayer.transform; } } }
void Start() { //Check for Current Player in the scene GameObject currentPlayer = GameObject.FindWithTag("Player"); if (currentPlayer) { // If there are the player in the scene already. Check for the Spawn Point Name // If it match then Move Player to the SpawnpointPosition string spawnPointName = currentPlayer.GetComponent <StatusC>().spawnPointName; GameObject spawnPoint = GameObject.Find(spawnPointName); if (spawnPoint && !onLoadGame) { currentPlayer.transform.root.position = spawnPoint.transform.position; currentPlayer.transform.root.rotation = spawnPoint.transform.rotation; } PlayerPrefs.SetFloat("PlayerX", currentPlayer.transform.position.x); PlayerPrefs.SetFloat("PlayerY", currentPlayer.transform.position.y); PlayerPrefs.SetFloat("PlayerZ", currentPlayer.transform.position.z); onLoadGame = false; GameObject oldCam = AttackTriggerC.Maincam.gameObject; if (!oldCam) { return; } GameObject[] cam = GameObject.FindGameObjectsWithTag("MainCamera"); foreach (GameObject cam2 in cam) { if (cam2 != oldCam) { Destroy(cam2.gameObject); } } // If there are the player in the scene already. We will not spawn the new player. return; } //Spawn Player GameObject spawnPlayer = Instantiate(player, transform.position, transform.rotation) as GameObject; mainCam = GameObject.FindWithTag("MainCamera").transform; ARPGcameraC checkCam = mainCam.GetComponent <ARPGcameraC>(); //Check for Main Camera if (mainCam && checkCam) { mainCam.GetComponent <ARPGcameraC>().target = spawnPlayer.transform; } PlayerPrefs.SetFloat("PlayerX", spawnPlayer.transform.position.x); PlayerPrefs.SetFloat("PlayerY", spawnPlayer.transform.position.y); PlayerPrefs.SetFloat("PlayerZ", spawnPlayer.transform.position.z); //Screen.lockCursor = true; Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; }
void Start() { GameObject currentPlayer = GameObject.FindWithTag("Player"); if (currentPlayer) { string spawnPointName = currentPlayer.GetComponent <StatusC>().spawnPointName; GameObject spawnPoint = GameObject.Find(spawnPointName); if (spawnPoint && !onLoadGame) { currentPlayer.transform.root.position = spawnPoint.transform.position; currentPlayer.transform.root.rotation = spawnPoint.transform.rotation; } PlayerPrefs.SetFloat("PlayerX", currentPlayer.transform.position.x); PlayerPrefs.SetFloat("PlayerY", currentPlayer.transform.position.y); PlayerPrefs.SetFloat("PlayerZ", currentPlayer.transform.position.z); onLoadGame = false; GameObject oldCam = currentPlayer.GetComponent <AttackTriggerC>().Maincam.gameObject; if (!oldCam) { return; } GameObject[] cam = GameObject.FindGameObjectsWithTag("MainCamera"); foreach (GameObject cam2 in cam) { if (cam2 != oldCam) { Destroy(cam2.gameObject); } } return; } GameObject spawnPlayer = Instantiate(player, transform.position, transform.rotation) as GameObject; mainCam = GameObject.FindWithTag("MainCamera").transform; ARPGcameraC checkCam = mainCam.GetComponent <ARPGcameraC>(); if (mainCam && checkCam) { mainCam.GetComponent <ARPGcameraC>().target = spawnPlayer.transform; } PlayerPrefs.SetFloat("PlayerX", spawnPlayer.transform.position.x); PlayerPrefs.SetFloat("PlayerY", spawnPlayer.transform.position.y); PlayerPrefs.SetFloat("PlayerZ", spawnPlayer.transform.position.z); Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; }
// Token: 0x06000C31 RID: 3121 RVA: 0x0004D2BC File Offset: 0x0004B6BC private void LateUpdate() { if (!this.target) { return; } if (!this.targetBody) { this.targetBody = this.target; } if (Time.timeScale == 0f) { return; } this.x += CFInput.GetAxis("Mouse X") * this.xSpeed * 0.02f; this.y -= CFInput.GetAxis("Mouse Y") * this.ySpeed * 0.02f; this.distance -= CFInput.GetAxis("Mouse ScrollWheel") * Time.deltaTime * this.zoomRate * Mathf.Abs(this.distance); this.distance = Mathf.Clamp(this.distance, this.minDistance, this.maxDistance); this.y = ARPGcameraC.ClampAngle(this.y, this.yMinLimit, this.yMaxLimit); Quaternion rotation = Quaternion.Euler(0f, this.x, 0f); base.transform.rotation = rotation; this.aim = Quaternion.Euler(0f - this.aimAngle, this.x, 0f); if (CFInput.GetButton("Fire1") || CFInput.GetButton("Fire2") || CFInput.GetAxis("Horizontal") != 0f || CFInput.GetAxis("Vertical") != 0f || this.lockOn) { this.targetBody.transform.rotation = Quaternion.Euler(0f, this.x, 0f); } Vector3 position = this.target.position - (rotation * Vector3.forward * this.distance + new Vector3(this.offsetX, -this.targetHeight, this.offsetZ)); base.transform.position = position; Vector3 vector = this.target.transform.position - new Vector3(0f, -this.targetHeight, 0f); if (Physics.Linecast(vector, base.transform.position, out this.hit) && this.hit.transform.tag == "Wall") { float d = Vector3.Distance(vector, this.hit.point) - 0.28f; position = this.target.position - (rotation * Vector3.forward * d + new Vector3(0f, -this.targetHeight, 0f)); base.transform.position = position; } }
void Awake() { if (!mainModel) { mainModel = this.gameObject; } mStatusC = GetComponent <StatusC>(); //Assign This mainModel to Status Script mStatusC.mainModel = mainModel; mStatusC.useMecanim = useMecanim; //Set tag to Player. gameObject.tag = "Player"; controller = GetComponent <CharacterController>(); cmc = GetComponent <CharacterMotorC>(); if (!useMecanim) { mAnim = mainModel.GetComponent <Animation>(); } else { if (!mAnimator) { mAnimator = mainModel.GetComponent <Animator>(); } } GameObject[] cam = GameObject.FindGameObjectsWithTag("MainCamera"); foreach (GameObject cam2 in cam) { if (cam2) { Destroy(cam2.gameObject); } } GameObject newCam = GameObject.FindWithTag("MainCamera"); newCam = Instantiate(MaincamPrefab, transform.position, transform.rotation) as GameObject; Maincam = newCam.transform; m_RPGCammer = Maincam.GetComponent <ARPGcameraC>(); //m_RPGCammer.distance = 6.0f; //m_RPGCammer.target = this.transform; // Set Target to ARPG Camera if (!cameraZoomPoint || aimingType == AimType.Normal) { //cameraZoomPoint = this.transform; m_RPGCammer.target = this.transform; } else { m_RPGCammer.target = cameraZoomPoint; } m_RPGCammer.targetBody = this.transform; str = mStatusC.addAtk; matk = mStatusC.addMatk; //Set All Attack Animation'sLayer to 15 int animationSize = attackCombo.Length; int a = 0; if (animationSize > 0 && !useMecanim) { while (a < animationSize && attackCombo[a]) { mAnim[attackCombo[a].name].layer = 15; a++; } } //-------------------------------- //Spawn new Attack Point if you didn't assign it. if (!attackPoint) { if (!attackPointPrefab) { print("Please assign Attack Point"); freeze = true; return; } GameObject newAtkPoint = Instantiate(attackPointPrefab, transform.position, transform.rotation) as GameObject; newAtkPoint.transform.parent = this.transform; attackPoint = newAtkPoint.transform; } if (!useMecanim) { hurt = GetComponent <PlayerAnimationC>().hurt; } if (aimingType == AimType.Raycast) {//Auto Lock On for Raycast Mode m_RPGCammer.lockOn = true; } GameObject minimap = GameObject.FindWithTag("Minimap"); if (minimap) { GameObject mapcam = minimap.GetComponent <MinimapOnOffC>().minimapCam; mapcam.GetComponent <MinimapCameraC>().target = this.transform; } followState = AIState.Idle; if (!useMecanim) { //If using Legacy Animation mAnim = mainModel.GetComponent <Animation>(); mAnim.Play("idle"); // mAnim[hurtAnimation.name].layer = 10; } else { //If using Mecanim Animation if (!mAnimator) { mAnimator = mainModel.GetComponent <Animator>(); } } mAudio = GetComponent <AudioSource>(); }
void Awake() { //Check for Current Player in the scene GameObject currentPlayer = GameObject.FindWithTag("Player"); if (currentPlayer) { // If there are the player in the scene already. Check for the Spawn Point Name // If it match then Move Player to the SpawnpointPosition string spawnPointName = currentPlayer.GetComponent <StatusC>().spawnPointName; GameObject spawnPoint = GameObject.Find(spawnPointName); if (spawnPoint) { currentPlayer.transform.position = spawnPoint.transform.position; currentPlayer.transform.rotation = spawnPoint.transform.rotation; } GameObject oldCam = currentPlayer.GetComponent <AttackTriggerC>().Maincam.gameObject; if (!oldCam) { return; } GameObject[] cam = GameObject.FindGameObjectsWithTag("MainCamera"); foreach (GameObject cam2 in cam) { if (cam2 != oldCam) { Destroy(cam2.gameObject); } } // If there are the player in the scene already. We will not spawn the new player. return; } //Spawn Player GameObject spawnPlayer = Instantiate(player, transform.position, transform.rotation) as GameObject; mainCam = GameObject.FindWithTag("MainCamera").transform; ARPGcameraC checkCam = mainCam.GetComponent <ARPGcameraC>(); //Check for Main Camera if (mainCam && checkCam) { mainCam.GetComponent <ARPGcameraC>().target = spawnPlayer.transform; }/*else if(mainCam){ * Destroy (mainCam.gameObject); * }*/ mainCam.GetComponent <Camera>().fieldOfView = 80.0f; Screen.lockCursor = false; //移动到AI出现的时候 锁定玩家 //Set Target for All Enemy to Player // GameObject[] mon; // mon = GameObject.FindGameObjectsWithTag("Enemy"); // foreach(GameObject mo in mon) { // if(mo){ // AIsetC tempAI = mo.GetComponent<AIsetC>(); // if(tempAI==null) // { // Debug.LogError("null ai "+mo.name); // continue; // } // tempAI.followTarget = spawnPlayer.transform; // } // } }