Пример #1
0
 private void OnStateChange(AIController.AIState newState)
 {
     if (newState == EffectState)
     {
         StateEnterEvent.Invoke();
     }
     else
     {
         StateExitEvent.Invoke();
     }
 }
Пример #2
0
 private void OnAIStateChanged(AIController.AIState newState)
 {
     if (newState == AIController.AIState.Walking)
     {
         _animator.Play(WalkAnimationStateHash, -1, Random.Range(0.0f, 1.0f));
     }
     else if (newState == AIController.AIState.Idle)
     {
         _animator.Play(IdleAnimationStateHash, -1, Random.Range(0.0f, 1.0f));
     }
     else if (newState == AIController.AIState.Attacking)
     {
         _animator.Play(AttackAnimationStateHash);
     }
 }
Пример #3
0
    /// <summary>
    /// rigidbody, navmesh, animation, collider 조절
    /// _bool은 무조건 true->false
    /// </summary>
    /// <param name="_bool"></param>
    public void ConditionRegulate(AIController.AIState _state, bool _bool)
    {
        // 상태에 따라 끄는 것들 조절
        switch (_state)
        {
        // 죽는상태 : rigidbody, navmesh, animation, collider
        case AIController.AIState.DEATH:
            nav.enabled = !_bool;

            rd.isKinematic = _bool;
            rd.velocity    = Vector3.zero;

            col.isTrigger = _bool;
            col.enabled   = !_bool;

            anim.enabled = !_bool;
            break;

        // 도약, 넉백 : navmesh, rigidbody
        case AIController.AIState.LEAP:
            nav.updatePosition = !_bool;
            nav.enabled        = !_bool;

            rd.isKinematic = !_bool;

            col.isTrigger = _bool;
            // col.enabled = !_bool;         ** 점프 중 벽 못뚫게
            break;

        case AIController.AIState.KNOCKBACK:
            nav.updatePosition = !_bool;
            nav.enabled        = !_bool;

            rd.isKinematic = !_bool;
            col.isTrigger  = _bool;
            break;

        case AIController.AIState.RUSH:
            rd.isKinematic = !_bool;

            nav.updatePosition = !_bool;
            nav.updateRotation = !_bool;
            break;
        }
    }
 public void TakeOrder()
 {
     this.state     = AIController.AIState.Ordering;
     this.happiness = 100f;
     this.happinessMeter.SetFill(this.happiness / 100f);
     this.orderTime = this.timeToOrder;
     this.animator.SetTrigger("OrderTaken");
     this.animator.SetFloat("Happiness", this.happiness);
     this.desiredFood = FoodMenu.Instance.GetRandomFood();
     this.speechBubble.gameObject.SetActive(true);
     this.speechBubble.food = this.desiredFood;
     if (this.Male)
     {
         SFXController.PlaySound(SFXController.Sounds.MaleCustomerGreet);
         return;
     }
     SFXController.PlaySound(SFXController.Sounds.FemaleCustomerGreet);
 }
Пример #5
0
    /// <summary>
    ///  게스트용 착륙확인
    /// </summary>
    /// <param name="pos"></param>
    /// <param name="state"></param>
    /// <returns></returns>
    protected bool LandingAndStatusCheck(Vector3 targetPos, AIController.AIState state)
    {
        if (Physics.Raycast(transform.position, -transform.up, groundHeight, groundLayer))
        {
            ConditionRegulate(state, false);
            NavMeshHit hit;
            nav.SamplePathPosition(groundLayer, 2f, out hit);
            nav.nextPosition = hit.position;
            // NavMesh.CalculatePath(transform.position, targetPos, NavMesh.AllAreas, nav.path);
            // Debug.Log("되돌아오기:" + nav.nextPosition);
            // col.radius = 0.5f;

            nav.avoidancePriority = lowProperty;
            nav.acceleration      = 12;

            return(true);
        }

        return(false);
    }
 public void DeliverFood(Food deliveredFood)
 {
     if (deliveredFood.name == this.desiredFood.name)
     {
         this.state = AIController.AIState.Eating;
         this.animator.SetTrigger("ServedFood");
         this.eatTime = this.timeToEat;
         GameController.AddTip(GameController.Instance.activeDifficultyVariables.baseTip * this.happiness);
         if (this.happiness <= 50f)
         {
             this.happiness = 50f;
             this.animator.SetFloat("Happiness", this.happiness);
         }
         if (this.Male)
         {
             SFXController.PlaySound(SFXController.Sounds.MaleCustomerThank);
         }
         else
         {
             SFXController.PlaySound(SFXController.Sounds.FemaleCustomerThank);
         }
     }
     else
     {
         this.state     = AIController.AIState.Leaving;
         this.happiness = 0f;
         this.animator.SetFloat("Happiness", this.happiness);
         GameController.AddAngryCustomer();
         this.StandUp();
         if (this.Male)
         {
             SFXController.PlaySound(SFXController.Sounds.MaleCustomerLeave);
         }
         else
         {
             SFXController.PlaySound(SFXController.Sounds.FemaleCustomerLeave);
         }
     }
     this.happinessMeter.gameObject.SetActive(false);
 }
Пример #7
0
        // Token: 0x06001FEF RID: 8175 RVA: 0x00188B88 File Offset: 0x00186D88
        public override ControlInput GetInput()
        {
            ControlInput result = default(ControlInput);

            if (this.isPaused)
            {
                return(result);
            }
            AIController.AIState aistate = this.state;
            if (aistate != AIController.AIState.Entering)
            {
                if (aistate == AIController.AIState.Leaving)
                {
                    if (this.leaveTarget.position.x > base.transform.position.x)
                    {
                        result.horizontal = 1f;
                        this.SetFlip(false);
                    }
                    else
                    {
                        result.horizontal = -1f;
                        this.SetFlip(true);
                    }
                }
            }
            else if (this.targetChair.transform.position.x > base.transform.position.x)
            {
                result.horizontal = 1f;
                this.SetFlip(false);
            }
            else
            {
                result.horizontal = -1f;
                this.SetFlip(true);
            }
            return(result);
        }
Пример #8
0
    /// <summary>
    /// AI상태에 따른 애니메이션 행동하기
    /// anim.setXX
    /// </summary>
    /// <param name="state">행동상태</param>
    public override void AIAnimationCheck(AIController.AIState state)
    {
        base.AIAnimationCheck(state);

        switch (state)
        {
        case AIController.AIState.IDLE:                 // 대기
            anim.SetInteger(hashAnimNumInteger, m_idleAnimNum);
            anim.SetBool(hashChaseBool, false);
            break;

        case AIController.AIState.PATROL:                           // 탐색
            switch (patrolState)
            {
            case PatrolState.IDLE:
                switch (idleState)
                {
                case IdleState.NON:                                                 // Idle행동 그대로 실행
                    break;

                case IdleState.EAT:                                                 // 시체 먹기
                    anim.SetInteger(hashAnimNumInteger, c_biteAnimation);
                    break;
                }
                break;

            case PatrolState.CLOSE:                                          // 랜덤 순찰
                anim.SetBool(hashChaseBool, true);
                break;
            }
            break;

        case AIController.AIState.CHASE:                // 추적
            //if (nav.enabled)
            //    nav.speed = aiCon.aiInfo.chaseSpeed;
            if (agent.speed != 0)
            {
                anim.SetFloat(hashChaseSpeedFloat, m_mulChaseSpeed);
            }
            anim.SetBool(hashAttackBool, false);
            anim.SetBool(hashChaseBool, true);
            anim.applyRootMotion = false;
            break;

        case AIController.AIState.ATTACK:                // 싸움
            anim.SetBool(hashAttackBool, true);
            break;

        case AIController.AIState.CLIMB:                // 벽타기
            anim.SetBool(hashClimbBool, true);
            break;

        case AIController.AIState.LAND:                 // 벽 뛰어내리기
            Debug.Log("뛰어내리기");
            LandingAnimWeight();
            break;

        case AIController.AIState.JUMP:                 // 벽점프
            anim.SetTrigger(hashJumpTrigger);
            anim.applyRootMotion = true;
            break;

        case AIController.AIState.KNOCKBACK:            // 넉백
            anim.SetTrigger(hahsStunBool);
            break;
        }
    }
Пример #9
0
    // 행동에 따른 애니메이션
    public override void AIAnimationCheck(AIController.AIState state)
    {
        base.AIAnimationCheck(state);

        switch (state)
        {
        case AIController.AIState.IDLE:                 // 대기
            anim.SetInteger(hashAnimNumInteger, 0);
            anim.SetBool(hashChaseBool, false);
            break;

        case AIController.AIState.PATROL:                           // 탐색
            switch (patrolState)
            {
            case PatrolState.IDLE:
                switch (idleState)
                {
                case IdleState.NON:
                    break;

                case IdleState.EAT:
                    anim.SetInteger(hashAnimNumInteger, c_biteAnimation);
                    break;
                }
                break;

            case PatrolState.CLOSE:
                anim.SetBool(hashChaseBool, true);
                break;
            }
            break;

        case AIController.AIState.CHASE:                            // 추적
            //if (nav.enabled)
            //    nav.speed = aiCon.aiInfo.chaseSpeed;
            if (agent.speed != 0)
            {
                anim.SetFloat(hashChaseSpeedFloat, m_mulChaseSpeed);
            }
            anim.SetBool(hashAttackBool, false);
            anim.SetBool(hashChaseBool, true);
            anim.applyRootMotion = false;
            break;

        // 스킬마다 애니메이션 다름
        case AIController.AIState.ATTACK:                // 싸움
            anim.SetInteger(hashAttackNumInteger, 0);
            anim.SetBool(hashAttackBool, true);
            break;

        case AIController.AIState.SPIT:
            anim.SetInteger(hashAttackNumInteger, 1);
            anim.SetBool(hashAttackBool, true);
            break;

        case AIController.AIState.CLIMB:                // 벽타기
            anim.SetBool(hashClimbBool, true);
            break;

        case AIController.AIState.LAND:                 // 벽 뛰어내리기
            Debug.Log("뛰어내리기");
            LandingAnimWeight();
            break;

        case AIController.AIState.KNOCKBACK:
            //Debug.Log("제대로 실행?");
            anim.SetTrigger(hahsStunBool);
            break;

        // 거리가 멀수록 애니메이션 속도가 느려짐
        case AIController.AIState.LEAP:
            anim.SetInteger(hashAttackNumInteger, 1);
            anim.SetBool(hashAttackBool, true);
            float _leapSpeed = m_leapVelocity / SkillManager.instance.dictSkill[aiCon.aiInfo.skill.skillIds[1]].maxDist;
            anim.SetFloat(hashLeapSpeedFloat, _leapSpeed);
            break;

        case AIController.AIState.RUSH:
            anim.SetInteger(hashAttackNumInteger, 1);
            anim.SetBool(hashAttackBool, true);
            break;
        }
    }
Пример #10
0
 // state에 따른 애니메이션 행동하기 : 상속
 public virtual void AIAnimationCheck(AIController.AIState state)
 {
 }
        private void Update()
        {
            if (this.isPaused)
            {
                return;
            }
            switch (this.state)
            {
            case AIController.AIState.Entering:
                if (Mathf.Abs(base.transform.position.x - this.targetChair.transform.position.x) <= this.distanceThreshold)
                {
                    this.SitDown();
                    this.happiness = 100f;
                    this.happinessMeter.SetFill(this.happiness / 100f);
                    this.state = AIController.AIState.Menu;
                    return;
                }
                break;

            case AIController.AIState.Menu:
                if (this.happiness <= 0f)
                {
                    this.StandUp();
                    this.state = AIController.AIState.Leaving;
                    GameController.AddAngryCustomer();
                    return;
                }
                this.ReduceHappiness();
                return;

            case AIController.AIState.Ordering:
                if (this.orderTime <= 0f)
                {
                    this.state = AIController.AIState.Waiting;
                    this.speechBubble.GetComponent <Animator>().SetTrigger("BubbleDrop");
                    this.animator.SetTrigger("DoneOrdering");
                    return;
                }
                this.orderTime -= Time.deltaTime;
                return;

            case AIController.AIState.Waiting:
                if (this.happiness <= 0f)
                {
                    this.StandUp();
                    this.state = AIController.AIState.Leaving;
                    GameController.AddAngryCustomer();
                    return;
                }
                this.ReduceHappiness();
                return;

            case AIController.AIState.Eating:
                if (this.eatTime <= 0f)
                {
                    this.StandUp();
                    this.state = AIController.AIState.Leaving;
                    return;
                }
                this.eatTime -= Time.deltaTime;
                return;

            case AIController.AIState.Leaving:
                if (Mathf.Abs(base.transform.position.x - this.leaveTarget.position.x) <= this.distanceThreshold)
                {
                    UnityEngine.Object.Destroy(base.gameObject);
                    this.leaveTarget.GetComponent <CustomerSpawner>().OpenDoor();
                }
                break;

            default:
                return;
            }
        }