Example #1
0
    [HideInInspector] public static Vector3 dirAwayFromObject; //Set in OnCollisionEnter

    public void OnEnter(CivillianController agent)
    {
        //Reset path to prevent errors when switching
        if (agent.navAgent.hasPath)
        {
            agent.navAgent.ResetPath();
        }

        //Update the priority so we push through other agents when blocked
        agent.navAgent.avoidancePriority = 30;

        currentAgent = agent;                            //Storing reference
        currentAgent.currentState = State.State_Retreat; //Setting currentState - kinda temporary i hope

        if (agent.initialSpawn)
        {
            agent.initialSpawn = false;
        }

        //Update icon
        agent.civIconStateScript.myState = script_civilianIconState.gameState.retreat;

        //Update animator
        if (currentAgent.m_Animator.enabled == false) //This is here temporarilly until we get a intriged animation going, this just unfreezes anim
        {
            currentAgent.m_Animator.enabled = true;
        }

        //Play scared sound clip
        agent.PlayScaredSound();

        currentAgent.navAgent.speed = 5.0f; //Add some additional speed to make them feel really spooked
        currentAgent.m_Animator.SetBool("Scared", true);

        //Debug.Log(currentAgent.gameObject.name + " State: RETREAT");
        agent.txtState.text = "RETREAT";

        if (agent.TRIGGERED_floating)   //Was scared by a floating object - multiply base scariness by x 1
        {
            CheckScaryRating();
            ectoplasm.GetComponent <ectoplasmController>().modifier = Camera.main.GetComponent <valueController>().EctoSidSeenScareValue;
            currentAgent.currentScareValue += (currentAgent.sid.GetComponent <playerPossession>().itemThrown.GetComponent <ItemController>().baseScariness);
        }
        else if (agent.TRIGGERED_hit)   //Was hit by an item - multiply base scariness by x2
        {
            CheckScaryRating();
            ectoplasm.GetComponent <ectoplasmController>().modifier = Camera.main.GetComponent <valueController>().EctoThrowScareValue;
            currentAgent.currentScareValue += (currentAgent.sid.GetComponent <playerPossession>().itemThrown.GetComponent <ItemController>().baseScariness);
        }
        else if (agent.TRIGGERED_repel) //Was lured to an item and spooked - multiply by x5??
        {
            CheckScaryRating();
            ectoplasm.GetComponent <ectoplasmController>().modifier = Camera.main.GetComponent <valueController>().EctoRepelledScareValue;
            currentAgent.currentScareValue += (currentAgent.sid.GetComponent <playerPossession>().itemThrown.GetComponent <ItemController>().baseScariness);
        }

        currentAgent.testParticle = ectoplasm;
    }