// Use this for initialization void Start() { //setting our current state to alive m_eCurrentPlayerState = E_PLAYER_STATE.E_PLAYER_STATE_ALIVE; verticalAxis = "_Vertical"; horizontalAxis = "_Horizontal"; rotationAxisX = "_Rotation_X"; rotationAxisY = "_Rotation_Y"; Fire = "_Fire"; Throw = "_Throw"; Jump = "_Jump"; // Loops through our players and assigns variables for input from different controllers for (uint i = 0; i < MAX_PLAYERS; ++i) { if (m_playerID == i) { verticalAxis = "P" + (i + 1) + verticalAxis; //"_Vertical"; horizontalAxis = "P" + (i + 1) + horizontalAxis; // "_Horizontal"; rotationAxisX = "P" + (i + 1) + rotationAxisX; // "_Rotation_X"; rotationAxisY = "P" + (i + 1) + rotationAxisY; // "_Rotation_Y"; Fire = "P" + (i + 1) + Fire; Throw = "P" + (i + 1) + Throw; Jump = "P" + (i + 1) + Jump; } } healthBars = FindObjectOfType <healthBar> (); animator = GetComponentInChildren <Animator> (); }
//private bool isBombAllocated = false; // Use this for initialization void Start() { m_rigidBody = GetComponent <Rigidbody>(); //if rigid body == null if (!m_rigidBody) { Debug.LogError("No Rigidbody"); } //setting our current state to alive m_eCurrentPlayerState = E_PLAYER_STATE.E_PLAYER_STATE_ALIVE; /*int randSelection = (int)Random.Range(0, MAX_PLAYERS - 1); * Debug.Log("Player: " + randSelection); */ for (uint i = 0; i < MAX_PLAYERS; ++i) { if (m_playerID == i) { verticalAxis = "P" + (i + 1) + "_Vertical"; horizontalAxis = "P" + (i + 1) + "_Horizontal"; } // Choose someone to allocate the bomb too if (m_playerID == 2)//c_bomb.randSelection) // TODO: randSelection { m_eCurrentPlayerState = E_PLAYER_STATE.E_PLAYER_STATE_BOMB; this.gameObject.tag = "HasBomb"; } //*/ } }
public CCharacterState GetState(E_PLAYER_STATE Type, CPlayer Player) { IntPtr cPtr = testPINVOKE.CCharacterStateManager_GetState__SWIG_1(swigCPtr, (int)Type, CPlayer.getCPtr(Player)); CCharacterState ret = (cPtr == IntPtr.Zero) ? null : new CCharacterState(cPtr, false); return(ret); }
// Update is called once per frame void Update() { //creating a variable that gets the input axis float moveHorizontal = Input.GetAxis(horizontalAxis); float moveVertical = Input.GetAxis(verticalAxis); Vector3 movementDirection = new Vector3(moveHorizontal, 0.0f, moveVertical); //Switches between player states switch (m_eCurrentPlayerState) { //checks if the player is alive case E_PLAYER_STATE.E_PLAYER_STATE_ALIVE: { m_rigidBody.AddForce(movementDirection * playerSpeed * Time.deltaTime); r_bomb.SetActive(false); //Debug.Log("Alive!"); break; } case E_PLAYER_STATE.E_PLAYER_STATE_BOMB: { m_rigidBody.AddForce(movementDirection * (playerSpeed + speedBoost) * Time.deltaTime); r_bomb.SetActive(true); /* if(c_bomb.bombTime <= 0) * { * m_eCurrentPlayerState = E_PLAYER_STATE.E_PLAYER_STATE_DEAD; * } */ //Debug.Log("Bomb!"); break; } //if player is dead case E_PLAYER_STATE.E_PLAYER_STATE_DEAD: { // Particle effect bomb (explosion) r_bombExplosionParticleEffect.SetActive(true); // actions to perform after a certain time uint uiBombEffectTimer = 2; Invoke("BombEffectDead", uiBombEffectTimer); Debug.Log("Dead :("); break; } default: { Debug.LogError("No State Chosen!"); break; } } //TODO: change to random number if (m_playerID == 2 && Time.deltaTime >= 60) { m_eCurrentPlayerState = E_PLAYER_STATE.E_PLAYER_STATE_DEAD; } }
public CCharacterState GetState(E_PLAYER_STATE Type, CPlayer Player, SWIGTYPE_p_u32 Level) { IntPtr cPtr = testPINVOKE.CCharacterStateManager_GetState__SWIG_0(swigCPtr, (int)Type, CPlayer.getCPtr(Player), SWIGTYPE_p_u32.getCPtr(Level)); CCharacterState ret = (cPtr == IntPtr.Zero) ? null : new CCharacterState(cPtr, false); if (testPINVOKE.SWIGPendingException.Pending) { throw testPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
void OnCollisionStay(Collision a_collision) { //if current players state is "BOMB" if (m_eCurrentPlayerState == E_PLAYER_STATE.E_PLAYER_STATE_BOMB && a_collision.collider.GetComponent <PlayerController>().m_eCurrentPlayerState == E_PLAYER_STATE.E_PLAYER_STATE_ALIVE) { //And is colliding with another player if (a_collision.collider.tag == "Player") { // change the other players state a_collision.collider.GetComponent <PlayerController>().m_eCurrentPlayerState = E_PLAYER_STATE.E_PLAYER_STATE_BOMB; //change the state of ourselves to alive m_eCurrentPlayerState = E_PLAYER_STATE.E_PLAYER_STATE_ALIVE; //r_camera.fieldOfView = Mathf.Lerp(70, 60, Time.time); Debug.Log("CHECK IF COLLIDED: OnCollExit"); } } else { Debug.Log("GLHF"); } }
public void SetPlayerStateDead(uint a_uiPlayerStateDead) { m_eCurrentPlayerState = (E_PLAYER_STATE)a_uiPlayerStateDead; }
public E_PLAYER_STATE GetStateType() { E_PLAYER_STATE ret = (E_PLAYER_STATE)testPINVOKE.CCharacterState_GetStateType(swigCPtr); return(ret); }
public void SetPlayerState(E_PLAYER_STATE State) { testPINVOKE.CPlayerPimpl_SetPlayerState(swigCPtr, (int)State); }
// Update is called once per frame void Update() { //creating a variable that gets the input axis float moveHorizontal = Input.GetAxis(horizontalAxis); float moveVertical = Input.GetAxis(verticalAxis); float moveRotationX = Input.GetAxis(rotationAxisX); float moveRotationY = Input.GetAxis(rotationAxisY); // Movement if (moveHorizontal < -fRot || moveHorizontal > fRot || moveVertical < -fRot || moveVertical > fRot) { Vector3 movementDirection = new Vector3(moveHorizontal, 0.0f, moveVertical); Vector3 pos = transform.position + movementDirection * playerSpeed * Time.deltaTime; transform.position = Vector3.Lerp(transform.position, pos, 0.2f); //Debug.Log("HELP"); animator.SetBool("Walking", true); // c_walk.CrossFade("Walk"); } // we're not moving so play the idle animation else { animator.SetBool("Walking", false); // c_idle.Play ("idle"); } // If we are rotating // Rotation/ Direction with the (right) analog stick if (moveRotationX < -fRot || moveRotationX > fRot || moveRotationY < -fRot || moveRotationY > fRot) { transform.forward = new Vector3(moveRotationX, 0.0f, moveRotationY); Debug.LogFormat("{0}", m_playerID); } // if we topple over if (Input.GetButton("Reset")) { transform.localRotation = Quaternion.Lerp(transform.localRotation, Quaternion.identity, 0.2f); } if (Input.GetButton("Jump")) { // TODO: do jump } if (health <= 0) { m_eCurrentPlayerState = E_PLAYER_STATE.E_PLAYER_STATE_DEAD; //DO STUFF animator.SetBool("Dead", true); } //m_rigidBody.AddForce(movementDirection * playerSpeed * Time.deltaTime); //Switches between player states #region Player States switch (m_eCurrentPlayerState) { //checks if the player is alive case E_PLAYER_STATE.E_PLAYER_STATE_ALIVE: { // r_weapon.SetActive(false); //Debug.Log("Alive!"); break; } case E_PLAYER_STATE.E_PLAYER_STATE_WEAPON: { r_weapon.SetActive(true); //Debug.Log("Bomb!"); break; } //if player is dead case E_PLAYER_STATE.E_PLAYER_STATE_DEAD: { // Particle effect bomb (explosion) //r_bombExplosionParticleEffect.SetActive(true); // actions to perform after a certain time uint uiBombEffectTimer = 2; Invoke("BombEffectDead", uiBombEffectTimer); // c_death.CrossFade("Death"); Debug.Log("Dead :("); break; } default: { Debug.LogError("No State Chosen!"); break; } } #endregion }
public E_PLAYER_STATE GetPlayerState() { E_PLAYER_STATE ret = (E_PLAYER_STATE)testPINVOKE.CPlayer_GetPlayerState(swigCPtr); return(ret); }
public void SetCharacterState(E_PLAYER_STATE State) { testPINVOKE.CPlayer_SetCharacterState(swigCPtr, (int)State); }