/** * @brief Handles the given command * @param command, the command to handle * @return returns true when the command is done, and return false when the command is still not done */ bool HandleCommand(HumanCommand command) { CurrentState = command.state; switch (command.state) { case CharacterStates.WALK: case CharacterStates.RUN: Vector3 dir = command.target - transform.position; float dist = dir.sqrMagnitude; if (CurrentState == CharacterStates.WALK) { rigid.MovePosition(transform.position + dir.normalized * walkSpeed * Time.deltaTime); } else { rigid.MovePosition(transform.position + dir.normalized * runSpeed * Time.deltaTime); } if (dist <= 0.001f) { return(true); } break; default: return(true); } return(false); }
public void setCurrentState() { if (rb.velocity.y < 0) { currentState = CharacterStates.falling; } else if (rb.velocity.y > 0) { currentState = CharacterStates.jumping; } else if (rb.velocity.y == 0) { RaycastHit info; if (Physics.Raycast(transform.position, -transform.up, out info, 1)) { currentState = CharacterStates.freeRoam; } else { currentState = CharacterStates.falling; } } }
void Start() { state = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterStates>(); tState = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterTotalState>(); attackPower = GameObject.Find("UI/CharacterStateInfo/StateInfo 1/Text (1)").GetComponent <Text>(); defencePower = GameObject.Find("UI/CharacterStateInfo/StateInfo 1/Text (2)").GetComponent <Text>(); }
public void SetCharacterEgg() { _characterState = CharacterStates.Egg; _spriteRenderer.sprite = _sprites[0]; _generatedRaver = 0; _animator.SetBool("clicked", false); }
/// <summary> /// Gets and stores components for further use /// </summary> protected virtual void Initialization() { _character = GetComponent <Character>(); _controller = GetComponent <CoreController>(); _characterBasicMovement = GetComponent <CharacterHorizontalMovement>(); //_characterGravity = GetComponent<CharacterGravity> (); _spriteRenderer = GetComponent <SpriteRenderer>(); //_health = GetComponent<Health> (); _animator = _character._animator; //_sceneCamera = _character.SceneCamera; _inputManager = _character.LinkedInputManager; _state = _character.CharacterState; _movement = _character.MovementState; _condition = _character.ConditionState; _abilityInitialized = true; if (_animator != null) { InitializeAnimatorParameters(); } if (_character._userProfiler != null) { _userProfiler = _character._userProfiler; } }
private void SetState(CharacterStates main, int sub) { switch (main) { case CharacterStates.Normal: character.SetState(main, (CharacterNormalStates)sub); break; case CharacterStates.Abnormal: character.SetState(main, (CharacterAbnormalStates)sub); break; case CharacterStates.Gather: character.SetState(main, (CharacterGatherStates)sub); break; case CharacterStates.Attack: character.SetState(main, (CharacterAttackStates)sub); break; case CharacterStates.Busy: character.SetState(main, (CharacterBusyStates)sub); break; default: break; } }
public void ChangeState(CharacterStates newState) { switch (newState) { case CharacterStates.Idle: currentState = 0; break; case CharacterStates.Walking: currentState = 1; break; case CharacterStates.Damage_Received: currentState = 2; break; case CharacterStates.Attack_State: currentState = 3; break; case CharacterStates.Injured_State: currentState = 4; break; default: break; } UpdateStateAnimator(currentState); }
public void ChangeState(CharacterStates state) { Debug.Log("Changing state from: " + CharacterState.ToString() + " to: " + state.ToString()); if(CharacterState == CharacterStates.DEAD) return; CharacterState = state; }
public void RemoveState(Character character, CharacterStates state) { var stateController = character.Controller.GetInstance <StateController>(); stateController.RemoveState(state); Out.WriteLog("Removed state for character " + state, LogKeys.ALL_CHARACTER_LOG, character.Id); }
void Awake() { status = GetComponent <CharacterStates>(); player = GetComponent <Transform>(); navi = GetComponent <NavMeshAgent>(); anim = GetComponent <Animator>(); isPwrUp = false; pwrUpMSTimer = 0.0f; pwrUpASTimer = 0.0f; isAtkSpdPwrUp = false; isMoveSpdPwrUp = false; baseMSpeed = navi.speed; baseASpeed = anim.speed; isTrapDebuff = false; allTrapTimer = 0.0f; asSlowTimer = 0.0f; msSlowTimer = 0.0f; frostTimer = 0.0f; isMoveSpdTrap = false; isAtkSpdTrap = false; isFrostTrap = false; isBurnTrap = false; isPoisonTrap = false; isStaticTrap = false; }
/** * @brief Change the state of the AI to the desired state * @param state, the state to change into */ public void ChangeState(CharacterStates state) { HumanCommand command = new HumanCommand(); command.state = state; commandQueue.Enqueue(command); }
protected virtual void Initialization() { _character = GetComponent <CharacterMotor2D>(); _controller = GetComponent <CController>(); _characterHorizontalMovement = GetComponent <CharacterHorizontalMovement>(); _characterGravity = GetComponent <CharacterGravity>(); _spriteRenderer = GetComponent <SpriteRenderer>(); _health = GetComponent <Health>(); //BindAnimator(); //_sceneCamera = _character.SceneCamera; _inputManager = _character.LinkedInputManager; _state = _character.CharacterState; if (GetComponent <InputManager>() == null) { _character.LoadStates(_movement); _character.LoadCondition(_condition); } else { _movement = _character.MovementState; _condition = _character.ConditionState; } AbilityPermitted = true; if (_character.MovementState == null) { print(""); } _abilityInitialized = true; }
// Use this for initialization void Start() { _animator = GetComponent <Animator>(); _characterController = GetComponent <CharacterController>(); _states = GetComponent <CharacterStates>(); _inputs = GetComponent <Inputs>(); }
internal void setState(CharacterStates value, bool isForce = false) { if (_state != value || isForce) { switch (value) { case CharacterStates.MOVE: playMove(); break; case CharacterStates.HIT: playAnimation(EnemyAnimatorTypes.TRIGGER_HIT); hitPlayerSignal.Dispatch(); break; case CharacterStates.DEFEAT: setState(CharacterStates.IDLE); playAnimation(EnemyAnimatorTypes.TRIGGER_DEFEAT); break; case CharacterStates.DEATH: setDeath(); setState(CharacterStates.IDLE); playAnimation(EnemyAnimatorTypes.TRIGGER_DEATH); break; case CharacterStates.IDLE: stopMove(); playAnimation(EnemyAnimatorTypes.TRIGGER_IDLE); break; } _state = value; } }
public void ExecuteJump() { ApplyAccelerationVector(new Vector2(0, -5)); _state = CharacterStates.Jump; if (Math.Abs(_velocityPerFrame.X) < 2) { if (_facingDirection == Directions.Left) { _jumpedVelocity = new Vector2(-2, _velocityPerFrame.Y); } else { _jumpedVelocity = new Vector2(2, _velocityPerFrame.Y); } } else { _jumpedVelocity = _velocityPerFrame; } _totalAdditionalJumpAccel = new Vector2(0, 0); _canContinueJump = true; SetRisingAnimation(); }
private WeaponManager[] weaponManagers; // The guns that the player is holding #endregion #region Initialization private void Awake() { movementAudio = GetComponent <AudioSource>(); dashCooling = false; currentNumberOfBombs = initialNumberOfBombs; currentNumberOfLives = initialNumberOfLives; currentDashDistance = 0; moveSpeed = walkSpeed; // Setting up joystick information storage joystickInformation = new float[2][]; joystickInformation[0] = new float[2] { 0, 0 }; joystickInformation[1] = new float[2] { 0, 0 }; // Initializing states and setting character to grounded availableStates = new CharacterStates[] { new Idle(this), new Walking(this), new Dashing(this), new CharacterPaused(this) }; currentState = availableStates[0]; dashIndicators = new MeshRenderer[2] { transform.GetChild(0).GetChild(1).GetChild(1).GetComponent <MeshRenderer>(), transform.GetChild(0).GetChild(2).GetChild(1).GetComponent <MeshRenderer>() }; verticalRotatorTransform = transform.GetChild(0).transform; // Bad, do better GameObject[] weapons = GameObject.FindGameObjectsWithTag("Weapon"); weaponManagers = new WeaponManager[] { weapons[0].GetComponent <WeaponManager>(), weapons[1].GetComponent <WeaponManager>() }; }
void Start() { player = GetComponent <Transform>(); // enemy = GameObject.FindGameObjectWithTag("Enemy").GetComponent<Transform>(); anim = GetComponent <Animator>(); navi = GetComponent <NavMeshAgent>(); animator = GetComponent <CharacterAnimatior>(); state = GetComponent <CharacterStates>(); // miniState = GameObject.FindGameObjectWithTag("Enemy").GetComponent<MinionState>(); prop = GetComponent <PropManager>(); if (photonView.isMine) { Camera.main.GetComponent <FollowCamera>().player = camPivot; } skillManager = GameObject.Find("UI/CharacterStateInfo/Skll").GetComponent <SkillManager>(); total = GetComponent <CharacterTotalState>(); parent = transform.root.gameObject; genPoints = GameObject.Find("PlayerGenpoints").GetComponentsInChildren <Transform>(); }
private void FixedUpdate() { switch (States) { case CharacterStates.Box: transform.localScale = _boxSettings.Scale; RollDirection(_boxSettings); break; case CharacterStates.Stick: transform.localScale = _stickSettings.Scale; RollDirection(_stickSettings); break; } if (Input.GetKeyDown(KeyCode.F)) { if (States == CharacterStates.Box) { States = CharacterStates.Stick; } else if (States == CharacterStates.Stick) { States = CharacterStates.Box; } } }
public void Init(CharacterParametersSO charSO) { parametersSO = charSO; agent = GetComponent <NavMeshAgent>(); animator = GetComponent <Animator>(); currentState = CharacterStates.Idle; mainCollider = GetComponent <Collider>(); ragdollColliders = GetComponentsInChildren <Collider>(true); rb = GetComponent <Rigidbody>(); rbs = GetComponentsInChildren <Rigidbody>(true); rigBuilder = GetComponent <RigBuilder>(); rigBuilder.enabled = false; if (parametersSO.team != 1) { SetBullet(PlayerControlHandler.instance.bulletParametersSO[0]); } GetComponentInChildren <SpriteRenderer>().color = parametersSO.team == 1 ? Color.green : Color.red; SetRagdol(false); }
//handling mouvement states transition and enter/exit callbacks public void TransitionToState(CharacterStates newState) { CharacterStates tmpInitialState = CurrentCharacterState; OnStateExit(tmpInitialState, newState); CurrentCharacterState = newState; OnStateEnter(newState, tmpInitialState); }
// Start is called before the first frame update private void Awake() { rb = GetComponent <Rigidbody>(); agent = GetComponent <NavMeshAgent>(); colli = GetComponent <Collider>(); anim = GetComponent <Animator>(); characterStates = GetComponent <CharacterStates>(); }
void Start() { state = GameObject.FindGameObjectWithTag("Player").GetComponent <CharacterStates>(); image = GameObject.Find("Cam").GetComponent <RawImage>(); playerName = photonView.owner.NickName; nameText.text = playerName; }
/** * @brief Initializes the variables as well as setting the start state of the AI */ private void Awake() { anim = GetComponent <Animator>(); rigid = GetComponent <Rigidbody>(); commandQueue = new Queue <HumanCommand>(); characterState = startState; anim.SetInteger("State", (int)characterState); }
void Awake() { characterState_ = CharacterStates.NEUTRAL; characterPosition = new Vector3(0, 0, 0); animator_ = gameObject.GetComponent <Animator>(); LastCollideObject_ = null; gameManagerScript_ = GameObject.Find("GameManager").GetComponent <GameManagerScript>(); }
void pursue() { //transform.LookAt(target.position); if (_characterState != CharacterStates.RUNNING) { _characterState = CharacterStates.RUNNING; } }
void Update() { if (alive) { if (!stunned) { if (isGrounded) { State = CharacterStates.idle; } Walk(); if (Input.GetButtonDown("Jump") && (isGrounded || doubleJump)) { Jump(); } if (Input.GetKeyDown(KeyCode.P)) { PushAbilyty(); } if (Input.GetKeyDown(KeyCode.A)) { SlowAbility(); } foreach (Touch touch in Input.touches) { if (touch.phase == TouchPhase.Began) { startTouchPosition = touch.position; } if (touch.phase == TouchPhase.Ended) { endTouchPosition = touch.position; ActionAfterTouch(); } } if (pushAbilityCoolDown > 0.0f || slowAbilityCoolDown > 0.0f) { pushAbilityCoolDown -= Time.deltaTime; slowAbilityCoolDown -= Time.deltaTime; Image[] abilityImages = gameUI.GetComponentsInChildren <Image>(); abilityImages[0].fillAmount = Mathf.Clamp(1 - pushAbilityCoolDown / 3.0f, 0.0f, 1.0f); abilityImages[1].fillAmount = Mathf.Clamp(1 - slowAbilityCoolDown / 3.0f, 0.0f, 1.0f); } } SetScore(); } else { transform.position = characterFreezePosition; } }
// Use this for initialization void Start() { Vector3 rot = transform.localRotation.eulerAngles; rotY = rot.y; rotX = rot.x; _states = transform.parent.GetComponent <CharacterStates>(); _inputs = transform.parent.GetComponent <Inputs>(); }
public void setState(string mainKey, CharacterStates state) { EnemyColliderModel mainColliderModel = getColliderModel(mainKey); if (mainColliderModel != null) { mainColliderModel.setState(state); } }
void Start() { anim = GetComponent <CharacterAnimatior>(); status = GetComponent <CharacterStates>(); mAnim = GetComponent <MinionAnimator>(); charBar = GameObject.FindGameObjectWithTag("CharUI").GetComponent <CharacterUI>(); mainUI = GameObject.Find("UI").GetComponent <MainUiBar>(); }
/// <summary> /// Checking allowed transitions by map /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <returns></returns> /// <exception cref="OverflowException"></exception> public bool IsAllowedTransition(CharacterStates from, CharacterStates to) { if (@from != to) { return(_map.Any(x => [email protected](@from) && [email protected](to))); } Out.QuickLog("Invalid transition request", LogKeys.ERROR_LOG); throw new OverflowException("Invalid transition request"); }
public virtual void TakeDamage(int amount) { health -= amount; if (amount <= 0) { currentState = CharacterStates.Dead; Debug.Log(characterName + "died!"); } }
void Awake() { Sprite = GetComponentInChildren <CharacterSprite>(); Input = new CharacterInput(); StateMachine = new FiniteStateMachine(); States = new CharacterStates(); States.idleState = new IdleState(this); States.jumpingState = new JumpingState(this); }
private void UpdateEnumStatesHandler() { AnimationMovementSpeed = playerAnimator.GetFloat("MovementSpeed"); if (AnimationMovementSpeed <= 0.1 && isGrounded == true) { currentCharacterState = CharacterStates.Idle; } else if (AnimationMovementSpeed >= 0.1f && isGrounded == true) { currentCharacterState = CharacterStates.Walk; } else if (isGrounded == false) { currentCharacterState = CharacterStates.Jump; } }
void Awake() { verticleDir = transform.up; forwardDir = transform.forward; sideDir = transform.right; rb = GetComponent<Rigidbody>(); playerState = CharacterStates.Idle; if (!instance) instance = this; }
protected void SetState(CharacterStates newState) { if(newState != characterState) { switch(newState) { case CharacterStates.Idle: characterState = newState; OnCharacterIdle(); break; case CharacterStates.Attack: if(characterState != CharacterStates.Block) OnCharacterAttack(); characterState = newState; break; case CharacterStates.Jump: characterState = newState; OnCharacterJump(); break; case CharacterStates.Block: characterState = newState; OnCharacterBlock(); break; case CharacterStates.Run: characterState = newState; OnCharacterRun(); break; case CharacterStates.Ground: characterState = newState; OnCharacterGround(); break; } } }
public void SetCharacterMain() { _characterState = CharacterStates.Main; _animator.runtimeAnimatorController = _animationControllers[_generatedRaver]; _animator.SetBool("clicked", true); }
void UserInput() { FwdVel = (Input.GetAxis("Vertical") * movmentSpeed); SideVel = (Input.GetAxis("Horizontal") * movmentSpeed); if(Input.GetButtonDown("Jump")) { jump = true; } else if(Input.GetButtonUp("Jump")) { jump = false; } if (Input.GetKey(KeyCode.Alpha4)) { playerState = CharacterStates.Grab; } if (Input.GetKeyUp(KeyCode.Alpha4)) { playerState = CharacterStates.Idle; } }