private void Phase1Attack() { // move only when it's not attacking if (!this._fireController.IsAttacking) { this._direction = this._pointFollower.GetDirection(); this._movement.MoveInDirection(this._direction); } // when not moving turn south if (this._direction == Direction.None) { if (!this._isFacingSouth) { this._animator.SetTrigger(AnimatorHelper.GetAnimatorParameterFromDirection(Direction.South)); this._isFacingSouth = true; } } else { this._isFacingSouth = false; } // when dragon is not moving and can attack is set to true -> attack if (this._direction == Direction.None && this._canAttack) { // attack this._canAttack = false; this._fireController.StartFire(); Invoke(nameof(this.CallEndFire), this.AttackDuration); } }
protected virtual void GetComponentsSetup() { animator = GetComponentInChildren <Animator>(); animatorHelper = GetComponentInChildren <AnimatorHelper>(); soundManager = GetComponentInChildren <ObjectSoundManager>(); }
void Awake () { Animator animator = GetComponent<Animator> (); if (null != animator) { animatorHelper = new AnimatorHelper (animator); } }
public virtual void PlayAnimation(ANIM_INDEX index, float translationDuration, float normalizedTime) { if (ani != null) { ani.CrossFade(AnimatorHelper.GetAnimationName(index), translationDuration, -1, normalizedTime); ani.SetInteger(CURRENT_ANIMATION, (int)index); } }
private void Awake() { anim = GetComponent <AnimatorHelper>(); if (anim == null) { Debug.LogError($"{typeof(AnimatorHelper)} not found"); } }
private void StartPhase2() { this._movement.MoveInDirection(Direction.None); this._animator.SetTrigger(AnimatorHelper.GetAnimatorParameterFromDirection(Direction.South)); this._currentAttackPhase = AttackPhase.Phase2; Invoke(nameof(this.FreezeRotationAndStartFire), 1f); InvokeRepeating(nameof(this.ShuffleDragons), 0f, this._shuffleDragonsInterval); }
// Number of seconds user's mouse hasn't moved and user is moving. // Used for zeroing the camera while running. void Awake(){ animator = GetComponent<Animator>(); animatorHelper = GetComponent<AnimatorHelper>(); testNavPath = new NavMeshPath(); if (GameManager.Inst.LevelLoaded == GameManager.Level.MOTION_TEST) loadDestinationIndicators = false; } // End of Awake().
private void Awake() { controller = GetComponent <CharacterController>(); agent = GetComponent <NavMeshAgent>(); anim = GetComponent <AnimatorHelper>(); if (agent.enabled) { agent.isStopped = true; } }
private void GetAllComponets() { PathGenerator = GetComponent <PathGenerator>(); NavAgent = GetComponent <NavMeshAgent>(); Obstacle = GetComponent <NavMeshObstacle>(); Animator = GetComponent <Animator>(); damageableManager = GetComponent <DamageableManager>(); ragdoll = GetComponent <RagdollHelper>(); animatorHelper = GetComponent <AnimatorHelper>(); }
public static void SetTrigger(this Animator self, string name, System.Action finishCallback) { AnimatorHelper helper = self.GetComponent <AnimatorHelper> (); if (helper == null) { helper = self.gameObject.AddComponent <AnimatorHelper> (); } helper.animator = self; helper.SetTrigger(name, finishCallback); }
public static float CurrentStateAnimationLength(this Animator self, string stateName) { AnimatorHelper helper = self.GetComponent <AnimatorHelper> (); if (helper == null) { helper = self.gameObject.AddComponent <AnimatorHelper> (); } helper.animator = self; return(helper.CurrentStateAnimationLength(stateName)); }
public static void Play(this Animator self, string stateName, int layer, System.Action finishCallback) { AnimatorHelper helper = self.GetComponent <AnimatorHelper> (); if (helper == null) { helper = self.gameObject.AddComponent <AnimatorHelper> (); } helper.animator = self; helper.Play(stateName, layer, finishCallback); }
private void AnimatorGeneratorWindowOnYes(AnimatorGeneratorDialogWindow sender) { var animatorController = AnimatorHelper.GetAnimatorController(sender.Path); AnimatorHelper.ReplaceAnimator(animatorController, sender.Animations); if (sender.SetAnimatorControllerInModel) { _state = SetAnimatorState; _animatorController = animatorController; AssetDatabase.ImportAsset(sender.Path, ImportAssetOptions.ForceUpdate); } }
public virtual bool ShouldPlayNextAnimation(ANIM_INDEX current) { AnimatorStateInfo info = ani.GetCurrentAnimatorStateInfo(0); switch (current) { case ANIM_INDEX.IDLE: case ANIM_INDEX.PREPARE: case ANIM_INDEX.RUN: return(true); case ANIM_INDEX.DEAD: return(false); default: return(!ani.IsInTransition(0) && info.IsName(AnimatorHelper.GetAnimationName(current)) && info.normalizedTime >= 0.95f); } }
void OnGUI() { if (GUILayout.Button("Dying")) { animator.Play("Dying"); } if (GUILayout.Button("HoldLog")) { animator.Play("HoldLog"); } if (GUILayout.Button("Idle_Neutral")) { animator.Play("Idle_Neutral"); } if (GUILayout.Button("DyingTurn")) { AnimatorHelper.Turn(animator, "Dying"); } }
// Update is called once per frame void Update() { if (this._isDead) { this.ChangeLayer(Constants.Layers.BehindShrek); var colliders = GetComponentsInChildren <BoxCollider2D>(); foreach (var boxCollider2D in colliders) { boxCollider2D.enabled = false; } GetComponentInChildren <Canvas>().enabled = false; return; } this._direction = this._pointFollower.GetDirection(); this._attackController.UpdatePosition(this._direction); this.ChangeLayer(this._pointFollower.GetLayerName()); if (this._direction == Direction.None) { if (Time.time > this._elapsedTimeAttack) { // do the attack here this._childAnimatorHelper.Animators.ForEach(animator => animator.SetTrigger(Constants.AnimatorParameters.Hit)); this._attackController.Attack(Constants.Tags.Player, this.AttackDamage); this._elapsedTimeAttack = Time.time + AttackInterval; } // turning to face PointToFollow var deltaY = this.PointToFollow.transform.position.y - this.Center.transform.position.y; var deltaX = this.PointToFollow.transform.position.x - this.Center.transform.position.x; var directionToTurn = Math.Abs(deltaX) < Math.Abs(deltaY) ? (deltaY > 0 ? Direction.North : Direction.South) : (deltaX > 0 ? Direction.East : Direction.West); if (this._lastDirectionToTurn != directionToTurn) { this._childAnimatorHelper.Animators.ForEach(animator => animator.SetTrigger(AnimatorHelper.GetAnimatorParameterFromDirection(directionToTurn))); this._attackController.UpdatePosition(directionToTurn); } this._lastDirectionToTurn = directionToTurn; } this._movement.MoveInDirection(this._direction); }
private void Awake() { controller = GetComponent <CharacterController>(); animHelper = GetComponent <AnimatorHelper>(); rb = GetComponent <Rigidbody>(); }
public override STATUS GetNextStatus() { STATUS status = base.GetNextStatus(); if (status != STATUS.NONE) { return(status); } if (mTouchHandler.IsTouched(TOUCH_KEY.Attack)) { float h = mController.GetCurrentAnimationNormalizedTime(); if (h > 0.65f && mController.getAnimator().GetCurrentAnimatorStateInfo(0).IsName(AnimatorHelper.GetAnimationName(mAnimIndex))) { mIsChangeNextStatus = true; } } if (mController.ShouldPlayNextAnimation(mAnimIndex) || mIsChangeNextStatus) { if (mNextStatus == STATUS.NONE) { mNextStatus = STATUS.IDLE; } //攻击时候是否可以转向 //if (mTouchHandler.IsTouched (TOUCH_KEY.Left)) { // mController.SetDirection(Dir.LEFT); //}else if (mTouchHandler.IsTouched (TOUCH_KEY.Right)) { // mController.SetDirection(Dir.RIGHT); //} return(mIsChangeNextStatus ? mNextStatus : STATUS.IDLE); // return mTouchHandler.IsTouched(TOUCH_KEY.Attack) ? mNextStatus : STATUS.IDLE; } return(STATUS.NONE); }
protected bool CheckAnimatorIsAttack(AnimatorStateInfo stateInfo) { return(stateInfo.IsName(AnimatorHelper.GetAnimationName(ANIM_INDEX.ATT)) || stateInfo.IsName(AnimatorHelper.GetAnimationName(ANIM_INDEX.ATT01)) || stateInfo.IsName(AnimatorHelper.GetAnimationName(ANIM_INDEX.ATT02)) || stateInfo.IsName(AnimatorHelper.GetAnimationName(ANIM_INDEX.ATT03))); }
// to store the function void Start() { Instance = this; }