예제 #1
0
            public override bool Action()
            {
                if (AICtrl.StateMachineAnimator.GetBool("IsDead"))
                {
                    Interrupt();
                }
                MovementControls mvmt        = AICtrl.MvmntCmp;
                SwitchDirection  dirSwitcher = AICtrl.DirSwitcherCmp;

                mvmt.SetVelocityX((mvmt.RunSpeed / 2) * dirSwitcher.Direction);
                //if(this.origAnimatorSpeed == -1)
                //    this.origAnimatorSpeed = AACmp.AnimatorCmp.speed;

                //AACmp.AnimatorCmp.speed = this.wanderAnimatorSpeed;

                float timePassed = Time.timeSinceLevelLoad - this.timeSinceLastWander;

                if (timePassed <= 1)
                {
                    return(false);
                }

                this.timeSinceLastWander = Time.timeSinceLevelLoad;
                int randDir = Random.Range(0, 2);

                randDir = randDir == 0 ? -1 : 1;
                dirSwitcher.OnSwitchDirection(randDir);
                return(true);
            }//Action
예제 #2
0
        }//Start


        public void OnJumpEvent(AAbility cmp) {
            float timePassed = Time.timeSinceLevelLoad - this.timeOfLand;
            float velDiff = Mathf.Abs(_mvmnt.Velocity.x) - Mathf.Abs(_mvmnt.RunSpeed);
            if (velDiff >= MaxAddedSpeed)
                return;

            if (timePassed <= HopInterval) {
                if (velocityAtJump == float.MinValue)
                    velocityAtJump = _mvmnt.Velocity.x;

                float dir = Mathf.Sign(this.transform.localScale.x);
                _mvmnt.SetVelocityX(velocityAtJump + (AddPerHop * dir));
                this.velocityAtJump = _mvmnt.Velocity.x;
            } else {
                velocityAtJump = float.MinValue;
            }
        }