RaydraPlayerz ThePlayer; //!reference to the RaydraPlayerz object that holds this RaydraWeapon object void Start() { Bolts = new List <RaydraProjectile>(); for (int i = 0; i < Bolts.Count; ++i) { Bolts[i] = null; //initialize the array elements to null } X8Animator = this.GetComponentInParent <Animator>(); WeaponCharger = new RaydraCharger(1); //find the player object ThePlayer = GetComponentInParent <RaydraPlayerz>(); X8Animator.SetBool("Shoot", false); X8Animator.SetBool("Phase", false); X8Animator.SetBool("Tackle", false); X8Animator.SetBool("WeaponCharged", false); TheBall = FindObjectOfType <RaydraCellz>(); }
public X8Timer ShootTimer = new X8Timer(.5f); //this will time how longer the player faces the recticle void Start() { innerShield = gameObject.GetComponentInChildren <RaydraShield>(); //!search for the sheild in the children of the parent object _myCamera = this.GetComponentInChildren <Camera>(); //get the camera that is connected to this game object bool ScoreMode = false; //initally we are not in score mode //!the player info that unity will keep tract of p_fCameraAngleTheta = 43f; //!initialize the angle that player if facing p_fCameraAnglePhi = 45f; //!The camera is initially yyyyin this state p_fPlayerToFocusAngleTheta = 43f; //!initialize the angle that player if facing p_fPlayerToFocusAnglePhi = 45f; //!//!initialize the angle that player if facing in the upward direction p_fJumpVelocity = .40f; //!initialize the upward jump force ForceOfGravity = 1f / 60f; //!this will have a unit per second force of gravity, in the downward direction p_fOrientationAngle = 90f; //!Angle that the player is facing in degrees p_v3OrientationVect = new Vector3(0, 0, 1f); //!Direction player is facing represented as an angle p_v3PlayerToFocusVect = new Vector3(0, 0, 0); //!The vector the represents the direction the camera if facing p_v3PlayerToCameraVect = new Vector3(0, 0, 0); //!The Vector Data the represent the player to camera direction PlayerMovementState = MovingState.IsStandingStill; //!Intially the player is not moving PlayerJumpState = JumpingState.NotJumping; //!initlialize the the player is not jumping PlayerTackleHitState = TackeHitState.NoContact; //!Initial the tackle state of the player PlayerTackleState = TackleState.IsNotTackling; //!Initial the tackle state of the player PlayerAttackState = AttackMode.NotFiringAbility; //!Initial the shoot state of the player PlayerRaydraState = RaydraState.NotInRaydraMode; //!initailly the player is not in Raydra Mode PlayerCameraState = CameraPerspective.Normal; //!initially the camera to do nothing PlayerPhaseState = PhaseState.IsNotPhasing; PlayerBallThrowState = BallThrowingState.NotBeingThrown; //!Initial the vertical state of the player PlayerBallPossessionState = BallPossessionState.HasBall; //!Initial the Possession State of the player // PlayerMotionVector = new Vector3 (this.transform.position.x,.transform.position.y,playerData.transform.position.z); p_v3PlayerVectorDirection = Vector3.zero; //! This is direction that te player is headed as a vector _armWeapon = this.GetComponentInChildren <RaydraWeapon>(); //!reference to the arm weapon on the player which is null to begin with p_bFacePlayer = false; //! variable that determines weather or not to face the player, this variable determine weather or not this medthod is recursive p_fMass = 0f; //!initialize the mass of the player p_StateTime = 0f; // Time elasped in current state p_Collider = null; //initialize the first collider connect to this body pRidgidBody = null; Controls = GetComponent <RaydraControls>(); if (CameraFocusOverHead != null) { p_v3PlayerToCameraVect = CameraFocusOverHead.transform.position - _myCamera.transform.position; } p_fCameraAnglePhi = Vector3.Angle(new Vector3(0, 1, 0), p_v3PlayerToCameraVect); p_fCameraAngleTheta = Vector3.Angle(new Vector3(1, 0, 0), p_v3PlayerToCameraVect); p_fPlayerToFocusAnglePhi = Vector3.Angle(new Vector3(0, 1, 0), p_v3PlayerToFocusVect); p_fPlayerToFocusAngleTheta = Vector3.Angle(new Vector3(1, 0, 0), p_v3PlayerToFocusVect); X8Animator = GetComponent <Animator>(); isGrounded = false; if (p_v3PlayerToFocusVect.z < 0) { p_fPlayerToFocusAngleTheta = 360 - p_fPlayerToFocusAngleTheta; //make sure that the angle is at the correct corridinate } if (p_v3PlayerToCameraVect.z < 0) { p_fCameraAngleTheta = 360 - p_fCameraAngleTheta; //make sure that the angle is at the correct corridinate } TheBall = FindObjectOfType <RaydraCellz>(); X8Animator = GetComponent <Animator>(); //get the reference to the animator PlayerMovementState = MovingState.IsStandingStill; EnemyAI = GetComponent <Ai>(); //get the ai script attached to the player (if there is one) if (EnemyAI != null) { Debug.Log("enemy AI" + EnemyAI.ToString()); } }
/** Start the initialization of variable */ void Start() { TheBall = FindObjectOfType <RaydraCellz>(); //find the RaydraCell in the scene editor GameObject ControlHub = GameObject.Find("ControlHub"); ShootPoint = GameObject.FindGameObjectWithTag("ShootPoint"); // GoalSphere =GameObject.FindGameObjectWithTag("GoalPoint"); //Get the line rendered that is attached to this game object LineRenderer[] CameraDrawLineArray = CameraOrientationDrawLine.GetComponents <LineRenderer>(); LineRenderer[] PlayerDrawLineArray = PlayerOrientationDrawLine.GetComponents <LineRenderer>(); //OrientationDrawLine = OrientationDrawLineArray[0]; //GetComponent<Animator>() returns and array, so we are just grabbing the first element X8Animator = this.GetComponents <Animator>()[0]; if (CameraOrientationDrawLine == null)//return null if there is problem { return; } //if(CameraDrawLine == null CharacterDrawLine = PlayerDrawLineArray[0]; CharacterDrawLine.SetPosition(0, new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z)); CharacterDrawLine.SetPosition(1, new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z + 1)); CameraDrawLine = CameraDrawLineArray[0]; CameraDrawLine.SetPosition(0, new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z)); CameraDrawLine.SetPosition(1, new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z + 1)); CharacterDrawLine.SetWidth(.05f, .05f); CameraDrawLine.SetWidth(.05f, .05f); Hub = ControlHub.GetComponent <CentralHub>(); ThePlayer = GetComponent <RaydraPlayerz>(); //new RaydraPlayer (this.gameObject); ThePlayer.MyCamera.transform.LookAt(CameraFocus.transform.position, CameraFocus.transform.up); //initial the camera to the focus point vector PlayerDrawLineVector = ThePlayer.p_v3PlayerToFocusVect = ThePlayer.MyCamera.transform.position - CameraFocus.transform.position; //initialize the camera to the player ThePlayer.p_v3PlayerToCameraVect = CameraFocusOverHead.transform.position - ThePlayer.MyCamera.transform.position; //get the length of the camera to focus point vector PlayerToFocusLength = Math.Abs(ThePlayer.p_v3PlayerToFocusVect.magnitude); //get the length of player to the camera PlayerToCameraLength = Math.Abs(ThePlayer.p_v3PlayerToCameraVect.magnitude); ThePlayer.p_fCameraAnglePhi = Vector3.Angle(new Vector3(0, 1, 0), ThePlayer.p_v3PlayerToCameraVect); ThePlayer.p_fCameraAngleTheta = Vector3.Angle(new Vector3(1, 0, 0), ThePlayer.p_v3PlayerToCameraVect); ThePlayer.p_fCameraAnglePhi = (int)ThePlayer.p_fCameraAnglePhi; ThePlayer.p_fCameraAngleTheta = (int)ThePlayer.p_fCameraAngleTheta; ThePlayer.p_fPlayerToFocusAnglePhi = (int)Vector3.Angle(new Vector3(0, 1, 0), ThePlayer.p_v3PlayerToFocusVect); ThePlayer.p_fPlayerToFocusAngleTheta = (int)Vector3.Angle(new Vector3(1, 0, 0), ThePlayer.p_v3PlayerToFocusVect); if (ThePlayer.p_v3PlayerToFocusVect.z < 0) { ThePlayer.p_fPlayerToFocusAngleTheta = 360 - ThePlayer.p_fPlayerToFocusAngleTheta; //make sure that the angle is at the correct corridinate } if (ThePlayer.p_v3PlayerToCameraVect.z < 0) { ThePlayer.p_fCameraAngleTheta = 360 - ThePlayer.p_fCameraAngleTheta; //make sure that the angle is at the correct corridinate } //The player orientation or direction the player is walking is always the direction that the camera is looking. PlayerDrawLineVector.y = originalY; PlayerDrawLineVector.x = originalX; PlayerDrawLineVector.z = originalZ; InitialHorizontalControllerPosition1 = Input.GetAxis("RightHorizontal"); //give the initial Horizontal poistion InitialVerticalControllerPosition1 = Input.GetAxis("RightVertical"); InitialHorizontalControllerPosition0 = Input.GetAxis("LeftHorizontal"); //give the initial Horizontal poistion InitialVerticalControllerPosition0 = Input.GetAxis("RightVertical"); X8Animator.SetFloat("Speed", 0); X8Animator.SetBool("Jump", false); X8Animator.SetBool("RunJump", false); X8Animator.SetBool("Tackle", false); X8Animator.SetBool("Shoot", false); X8Animator.SetBool("ThrowBall", false); X8Animator.SetBool("ChargedRun", false); X8Animator.SetBool("StrafeRight", false); X8Animator.SetBool("StrafeLeft", false); X8Animator.SetBool("WeaponCharged", false); StateInfo = X8Animator.GetCurrentAnimatorStateInfo(0); ThePlayer.pRidgidBody = GetComponent <Rigidbody>(); ThePlayer.p_Collider = GetComponent <CapsuleCollider>();//get a reference to the first collider connected to this object turnSpeed = 2; InitialStrafeAxisValue = .16f; InitialRightFlipperValue = -.05f; //this is initail value of the right pressure button InitialLeftFlipperValue = InitialStrafeAxisValue; //this is initail value of the right pressure button ThePlayer.MyCamera.transform.LookAt(CameraFocus.transform.position, Vector3.up); }