Esempio n. 1
0
 public void NPCSwipeFinsih()
 {
     if (IsParent)
     {
         currentState = NPCStates.IDLE;
     }
     else
     {
         currentState = NPCStates.PATROL;
     }
 }
Esempio n. 2
0
        // se entra in collisione con il nemico scompare e rispawna in cella.
        void OnTriggerEnter(Collider other)
        {
            //Player p = other.gameObject.GetComponent<Player> ();
            Enemy e = other.gameObject.GetComponent <Enemy>();

            if (e != null && p == null)
            {
                this.transform.position = gc.NpcSpawnPoint.position;
            }
            if (p != null && e == null)
            {
                currentNPCState = NPCStates.Free;
            }
        }
Esempio n. 3
0
    public void SetState(NPCStates state)
    {
        this.currentState = state;

        switch (currentState)
        {
        case NPCStates.Idle:
            anim.SetBool(idleAnimation, true);
            anim.SetBool(walkAnimation, false);
            anim.SetBool(panicAnimation, false);
            anim.SetBool(angryAnimation, false);
            anim.SetBool(happyAnimation, false);
            break;

        case NPCStates.Walking:
            anim.SetBool(idleAnimation, false);
            anim.SetBool(walkAnimation, true);
            anim.SetBool(panicAnimation, false);
            anim.SetBool(angryAnimation, false);
            anim.SetBool(happyAnimation, false);
            break;

        case NPCStates.Panicking:
            anim.SetBool(idleAnimation, false);
            anim.SetBool(walkAnimation, false);
            anim.SetBool(panicAnimation, true);
            anim.SetBool(angryAnimation, false);
            anim.SetBool(happyAnimation, false);
            break;

        case NPCStates.Angry:
            anim.SetBool(idleAnimation, false);
            anim.SetBool(walkAnimation, false);
            anim.SetBool(panicAnimation, false);
            anim.SetBool(angryAnimation, true);
            anim.SetBool(happyAnimation, false);
            break;

        case NPCStates.Happy:
            anim.SetBool(idleAnimation, false);
            anim.SetBool(walkAnimation, false);
            anim.SetBool(panicAnimation, false);
            anim.SetBool(angryAnimation, false);
            anim.SetBool(happyAnimation, true);
            break;

        default:
            break;
        }
    }
Esempio n. 4
0
    public void ReadFile()
    {
        NPCStates npcFileStates = JsonArrayHandler <NPCStates> .ReadJsonFile(filePath);

        npcStates.Clear();
        foreach (var npcState in npcFileStates.items)
        {
            npcStates.Add(npcState);
        }

        for (int i = 0; i < npcStates.Count; i++)
        {
            npcs[i].currentQuest = npcStates[i].questNumber;
        }
    }
Esempio n. 5
0
    //Possibly something to limit the angry reaction. Seems a little exessive right now.

    protected override void Start()
    {
        base.Start();

        _ursa = FindObjectOfType <UrsaController>();

        if (IsParent || IsFriend)
        {
            currentState = NPCStates.IDLE;
        }

        if (IsFriend)
        {
            facingRight = false;
        }
    }
Esempio n. 6
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "NPC")
        {
            Debug.Log("NPC Restarted path");

            int i = Random.Range(0, Points.Length);
            agent = other.GetComponent <NavMeshAgent>();
            agent.ResetPath();
            agent.SetDestination(Points[i].transform.position);
            Debug.Log("Onto Next Isle");
            NPCStates CheckingIsle = other.GetComponent <NPCStates>();
            CheckingIsle.checkingIsle = i;
            Debug.Log(CheckingIsle.checkingIsle);
        }
    }
        private void Start()
        {
            enimies      = enimies + 1;                                                                             //Chaneded Here
            player       = GameObject.FindGameObjectWithTag("Player");
            playerHealth = player.GetComponent <PlayerStats>();
            animator     = GetComponent <Animator>();
            chest        = animator.GetBoneTransform(HumanBodyBones.Chest);
            source       = GetComponent <AudioSource>();
            navMeshAgent = GetComponent <NavMeshAgent>();
            aiControl    = GetComponent <AIControl>();
            vision       = GetComponentInChildren <NPCVision>();
            hitFXManager = GetComponent <HitFXManager>();
            states       = GetComponent <NPCStates>();

            visibilityCheckObject      = new GameObject();
            visibilityCheckObject.name = this.name + " visibilityCheckObject";
            visibilityCheckObject.AddComponent <SphereCollider>().radius  = 0.3f;
            visibilityCheckObject.GetComponent <SphereCollider>().enabled = false;

            foreach (Collider collider in GetComponentsInChildren <Collider>())
            {
                collider.enabled = false;
            }
            foreach (Rigidbody rigidbody in GetComponentsInChildren <Rigidbody>())
            {
                rigidbody.isKinematic = true;
            }

            GetComponent <Rigidbody>().isKinematic = false;
            GetComponent <Collider>().enabled      = true;

            StartCoroutine(CheckFriends());

            //Set own position as NavMesh target on start
            desiredPosition = transform.position;

            //Controller variables
            m_Rigidbody     = GetComponent <Rigidbody>();
            m_Capsule       = GetComponent <CapsuleCollider>();
            m_CapsuleHeight = m_Capsule.height;
            m_CapsuleCenter = m_Capsule.center;

            m_Rigidbody.constraints   = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
            m_OrigGroundCheckDistance = m_GroundCheckDistance;
        }
Esempio n. 8
0
    private void EndCallState()
    {
        myAnimator.SetBool("calling", false);
        myAnimator.SetBool("angryCalling", false);

        if (IsParent)
        {
            currentState = NPCStates.IDLE;
        }
        else if (IsFriend)
        {
            currentState = NPCStates.RUNAWAY;
        }
        else
        {
            currentState = NPCStates.PATROL;
        }
    }
Esempio n. 9
0
    public override void Call(float duration, TalkBubbleTypes currentType)
    {
        base.Call(duration, currentType);

        if (currentType == TalkBubbleTypes.ANGRY)
        {
            myAnimator.SetBool("angryCalling", true);
        }
        else
        {
            myAnimator.SetBool("calling", true);
        }

        if (IsFriend && currentType == TalkBubbleTypes.SURPRPISE)
        {
            _ursa.InputActive = false;
        }

        _currentDuration = duration;
        currentState     = NPCStates.CALL;
    }
        //end Fernando vars

        //Fernando script
        private void ChangeState(NPCStates pNewState)
        {
//			Debug.Log ("Changing to " + pNewState);

            avatar = avatar ?? GetComponent <Animator>();

            switch (pNewState)
            {
            case NPCStates.WALKING:
            default:
                ResetMove();
                break;

            case NPCStates.WAITING:
                npcEvents.canMove = false;                              // temporary stop movement

                currentSpeed = 0;
                try
                {
                    if (useAnimator)
                    {
                        avatar.CrossFade(randomIdleAnims [Mathf.Min(randomIdleAnims.Length - 1, Random.Range(0, randomIdleAnims.Length))], 0.3f);
                    }
                }
                catch (System.Exception ex) {
                }
                mWaitingTimer = 0;
                break;

            case NPCStates.SHOCKED:
                //avatar.SetBool("shocked", true);
                break;

            case NPCStates.HIT:
                break;
            }

            mCurrentState = pNewState;
        }
Esempio n. 11
0
    IEnumerator Browse(int i, int j, Collider other)
    {
        NPCStates CheckingIsle = other.GetComponent <NPCStates>();

        anim.Play("Thinking");
        yield return(new WaitForSeconds(waiting));

        anim.Play("Idle");
        if (agent != null)
        {
            if (CheckingIsle.checkingIsle > 0)
            {
                agent.SetDestination(Points[i].transform.position);
                Debug.Log("Onto Next Isle");
            }
            else
            {
                agent.SetDestination(Counter[j].transform.position);
                Debug.Log("Onto Counter");
            }
            CheckingIsle.checkingIsle--;
            Debug.Log(CheckingIsle.checkingIsle);
        }
    }
Esempio n. 12
0
 public void EnemySpotted()
 {
     currentState = NPCStates.SWIPE;
 }