void UpdateState() { if (curState == CharStates.hold) { return; } if (vaulting) { curState = CharStates.vaulting; return; } if (horizontal != 0 || vertical != 0) { curState = CharStates.moving; } else { curState = CharStates.idle; } if (!onGround) { curState = CharStates.onAir; } }
public ICharStates GetCharStates() { try { CharStates states = new CharStates(); states.LevelBonus = Info.LevelMod; states.States = new Dictionary <string, IState>(); foreach (XElement element in StatesXML.Elements("States").Elements()) { states.States.Add(element.Name.ToString(), ParseState(element, states.LevelBonus)); } states.Languages = new List <string>(); foreach (XElement element in StatesXML.Element("Languages").Elements()) { states.Languages.Add(element.Value); } states.Proficiencies = new List <string>(); foreach (XElement element in StatesXML.Element("Proficiencies").Elements()) { states.Proficiencies.Add(element.Value); } return(states); } catch { return(null); } }
//public Gun gun1; //public List<Gun> guns = new List<Gun>(); //public int gunSelected = 0; // Start is called before the first frame update void Start() { // Assing componentes to our GameObject body = GetComponent <Rigidbody>(); cam = GetComponent <Camera>(); charState = CharStates.Idle; }
private void UpdateState() { if (_CurrentState == CharStates.E_Hold) { return; } if (_Horizontal != 0 || _Vertical != 0) { _CurrentState = CharStates.E_Moving; } else { _CurrentState = CharStates.E_Idle; } if (!_OnGround) { _CurrentState = CharStates.E_OnAir; } }
void UpdateState() { if (curState == CharStates.hold) { return; } if (moving) { curState = CharStates.moving; } else { curState = CharStates.idle; } if (!onGround) { curState = CharStates.onAir; } }
private void UpdateStateMouse() { CharStates state = CharStates.idleSouth; if (target.x > 0) { state = CharStates.walkEast; } else if (target.x < 0) { state = CharStates.walkWest; } else if (target.y > 0) { state = CharStates.walkNorth; } else if (target.y < 0) { state = CharStates.walkSouth; } animator.SetInteger("AnimationState", (int)state); spriteRenderer.flipX = (state == CharStates.walkWest); }
public void SetCharState(CharStates a_CharState) { m_CharState = a_CharState; }
// Update is called once per frame void Update() { // If Character is touching the ground if (isGrounded == true) { // ########################### NEED TO REVIEW THIS PART ########################### // Jumping if (Input.GetKeyDown(KeyCode.Space)) { isGrounded = false; body.AddForce(jump * jumpForce, ForceMode.Impulse); } // Walking mode if (charState != CharStates.Run) { if (Input.GetKey(KeyCode.W)) { // Triggering animation characterAnimation.SetBool("Walking", true); // Moving game obj body.velocity = transform.forward * movementSpeed; } if (Input.GetKeyUp(KeyCode.W)) { // Triggering animation characterAnimation.SetBool("Walking", false); } if (Input.GetKey(KeyCode.S)) { // Triggering animation characterAnimation.SetBool("BackWards", true); // Moving game obj body.velocity = transform.forward * -2.5f; } if (Input.GetKeyUp(KeyCode.S)) { // Triggering animation characterAnimation.SetBool("BackWards", false); } // Activating running mode if (Input.GetKeyDown(KeyCode.LeftShift)) { // Triggering animations characterAnimation.SetBool("Walking", false); characterAnimation.SetBool("BackWards", false); // Entering Running mode charState = CharStates.Run; } if (Input.GetMouseButtonDown(0)) { // Triggering animation characterAnimation.SetTrigger("Shooting"); // Reducing movement speed while aiming movementSpeed = 2; } if (Input.GetMouseButtonUp(0)) { // Triggering animation characterAnimation.SetTrigger("Break"); // Increasing movement speed when not aiming movementSpeed = 5; } } // Running Mode else if (charState == CharStates.Run) { if (Input.GetKey(KeyCode.W)) { // Triggering animation characterAnimation.SetBool("Run", true); // Moving Game obj body.velocity = transform.forward * (movementSpeed + 2.5f); } if (Input.GetKeyUp(KeyCode.W)) { // Triggering animation characterAnimation.SetBool("Run", false); } if (Input.GetKey(KeyCode.S)) { // Triggering animation characterAnimation.SetBool("BackWards", true); // Moving Game obj body.velocity = transform.forward * -5.0f; } if (Input.GetKeyUp(KeyCode.S)) { // Triggering animation characterAnimation.SetBool("BackWards", false); } } // Deactivating running mode if (Input.GetKeyUp(KeyCode.LeftShift)) { // Triggering animations characterAnimation.SetBool("Run", false); //characterAnimation.SetBool("Walking", false); charState = CharStates.Idle; } } // Turning Right if (Input.GetKey(KeyCode.D)) { float currentY = transform.rotation.eulerAngles.y; currentY += (Time.deltaTime * 180); transform.rotation = Quaternion.Euler(0, currentY, 0); } // Turning Left if (Input.GetKey(KeyCode.A)) { float currentY = transform.rotation.eulerAngles.y; currentY -= (Time.deltaTime * 180); transform.rotation = Quaternion.Euler(0, currentY, 0); } }