/****************************************************** * MonoBehaviour methods, Awake ******************************************************/ void Awake() { if (players == null) { players = new PlayerScript[8]; } players[playerId] = this; this.myTransform = transform; this.myRigidbody = rigidbody; playerPosition = GetComponent <PlayerPositionScript>(); controls = GetComponent <PlayerControls>(); follower = GetComponent <PathFollowScript>(); UIMainScript mainUIScript = (UIMainScript)FindObjectOfType(typeof(UIMainScript)); if (mainUIScript != null) { follower.isMoving = true; IsHuman = false; } // register all the multiplier components within this gameobject Component[] multiplierComponents = GetComponentsInChildren(typeof(IAccelMultiplier)); accelMultipliers = new IAccelMultiplier[multiplierComponents.Length]; for (int i = 0; i < multiplierComponents.Length; i++) { accelMultipliers[i] = (IAccelMultiplier)multiplierComponents[i]; } motionListeners = new List <IPlayerMotionListener>(); statListeners = new List <IStatListener>(); IsHuman = isHuman; }
void Start() { player = GetComponent <PlayerScript>(); pathFollower = GetComponent <PathFollowScript>(); myTransform = transform; }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { PlayerScript player = other.GetComponent <PlayerScript>(); player.HP -= HPSettings.RespawnHPCost; PlayerPositionScript posScript = other.GetComponent <PlayerPositionScript>(); Transform previouscheckpoint = posScript.previous; other.gameObject.transform.position = new Vector3(previouscheckpoint.position.x, -3, previouscheckpoint.position.z); Vector3 currentcheckpoint = new Vector3(posScript.current.position.x, 0, posScript.current.position.z); other.gameObject.transform.LookAt(currentcheckpoint); PathFollowScript follower = other.GetComponent <PathFollowScript>(); follower.repathPoints(); int cameracount = Camera.allCameras.Length; for (int i = 0; i < cameracount; i++) { if (Camera.allCameras[i].GetComponent <CarCamera>() != null) { if (Camera.allCameras[i].GetComponent <CarCamera>().targetPlayerId == player.playerId) { Camera.allCameras[i].GetComponent <CarCamera>().isRespawning = false; Camera.allCameras[i].GetComponent <fadeScript>().fadeOut = false; Debug.Log(Camera.allCameras[i]); } } } if (player.IsHuman == true) { other.GetComponent <PlayerControls>().isMoving = true; } else { follower.isMoving = true; } if (other.GetComponent <PlayerScript>().playerStatus == 1) { other.GetComponent <itemEffect>().poisonOff(); //other.GetComponent<PlayerScript>().playerStatus = 0; } else if (other.GetComponent <PlayerScript>().playerStatus == 2) { other.GetComponent <itemEffect>().shieldOff(); //other.GetComponent<PlayerScript>().playerStatus = 0; } if (other.GetComponent <itemEffect>().isAutoPilot == true) { other.GetComponent <itemEffect>().autoPilotOff(); } if (player.itemHeld != 0) { player.itemHeld = 0; } } }