Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        realMode         = currentMode;
        lastSeenPosition = alertManager.lastSeenPosition;
        myAnim.SetFloat("velocity", Mathf.Abs(rb.velocity.y));
        distanceToTarget = Mathf.Abs(transform.position.x - target.x);
        if (lastPosition.x != transform.position.x)
        {
            myAnim.SetBool("walking", true);
        }
        else
        {
            myAnim.SetBool("walking", false);
        }
        lastPosition = transform.position;
        if (isPickedUp && currentMode != EnemyMode.TRANQUILIZED)
        {
            transform.parent.gameObject.SendMessage("Throw");
        }
        if (currentMode != EnemyMode.SURPRISED)
        {
            myAnim.SetBool("surprised", false);
        }
        if (currentMode != EnemyMode.F****D)
        {
            myAnim.SetBool("f****d", false);
        }
        switch (currentMode)
        {
        case EnemyMode.ALERTED:
            target = new Vector3(lastSeenPosition.x, transform.position.y, transform.position.z);
            NoticeTarget();
            break;

        case EnemyMode.FLEEING:
            Flee();
            break;

        case EnemyMode.TRANQUILIZED:
            break;

        case EnemyMode.CONFUSED:
            dm.ShowConfused();
            currentMode = EnemyMode.PATROLLING;
            break;

        case EnemyMode.F****D:
//			Flee2();
            myAnim.SetBool("f****d", true);
            if (alertManager.currentMode == AlertMode.HIGH_ALERT)
            {
                alertManager.Alerted();
            }
            target = transform.position;
            break;

        case EnemyMode.PURSUING:
            target = new Vector3(lastSeenPosition.x, transform.position.y, transform.position.z);
            Pursue();
            break;

        case EnemyMode.PATROLLING:
            if (flipCycle == null)
            {
//				flipCycle = StartCoroutine ("FlipCycle");
//				CancelFlipCycle ();
            }
            Patrol();
            break;

        case EnemyMode.SURPRISED:
            myAnim.SetBool("surprised", true);
            break;

        case EnemyMode.STASHED:
            break;
        }

        switch (alertManager.currentMode)
        {
        case AlertMode.ALERTED:
            if (currentMode != EnemyMode.FLEEING && currentMode != EnemyMode.SURPRISED && currentMode != EnemyMode.FLEEING && currentMode != EnemyMode.F****D && currentMode != EnemyMode.TRANQUILIZED)
            {
                currentMode = EnemyMode.PURSUING;
                target      = alertManager.lastSeenPosition;
                forgotten   = false;
            }
            break;

        case AlertMode.PATROLLING:

            if (currentMode != EnemyMode.FLEEING && currentMode != EnemyMode.SURPRISED && currentMode != EnemyMode.FLEEING && currentMode != EnemyMode.F****D && currentMode != EnemyMode.TRANQUILIZED)
            {
                if (!forgotten)
                {
                    ForgetTarget();
                }
            }
            if (currentMode == EnemyMode.F****D)
            {
                ForgetTarget();
            }
            break;
        }
    }