コード例 #1
0
ファイル: Deer.cs プロジェクト: jamesleakos/artemis
 void SwitchToAlert()
 {
     velocity.x       = 0;
     deerState        = DeerState.alert;
     alertActionState = AlertActionState.idle;
     endAlertTime     = Time.time + alertAttentionSpan;
 }
コード例 #2
0
ファイル: Deer.cs プロジェクト: jamesleakos/artemis
    void AlertBehavior()
    {
        // Test for Sightline
        if (GeometryUtility.TestPlanesAABB(planes, thisCollider.bounds))
        {
            if (Time.time > NextTimeToRaycast)
            {
                RaycastHit2D hit = LookAtPlayerDeer();
                if (playerInSight && Mathf.Abs(player.velocity.x) > 1)
                {
                    SwitchToScared();
                }
                else
                {
                    if (Time.time > endAlertTime)
                    {
                        if (playerTransform != null)
                        {
                            if (playerInSight && playerTransform.position.x > globalMinFriendRange.x && playerTransform.position.x < globalMaxFriendRange.x)   // player inside friend zone
                            {
                                SwitchToFriendly();
                            }
                            else
                            {
                                SwitchToGrazing();
                            }
                        }
                    }
                }
            }
        }
        else
        {
            if (Time.time > endAlertTime)
            {
                SwitchToGrazing();
            }
            else
            {
                if (alertCycleCounter == nextAlertAction)
                {
                    alertCycleCounter = 0;
                    int actionSelection = Random.Range(1, 4);
                    if (actionSelection == 1)
                    {
                        alertActionState = AlertActionState.earTwitch;
                    }
                    else if (actionSelection == 2)
                    {
                        alertActionState = AlertActionState.idle;
                    }
                    else if (actionSelection == 3)
                    {
                        alertActionState = AlertActionState.tailTwitch;
                    }

                    nextAlertAction = 1;
                }
            }
        }
    }