Пример #1
0
    /// <summary>
    /// Instruct P0ly to enter the hiding state.
    /// </summary>
    private void GoHide()
    {
        Transform userTransform = Camera.main.transform;
        Vector3   destination   = userTransform.position + (-userTransform.forward * HideDistance);

        destination += (userTransform.right * Random.Range(-HideDistance / 2, HideDistance / 2));
        Destination  = destination;
        State        = PolyStates.Hiding;
    }
Пример #2
0
    /// <summary>
    /// Instruct P0ly to enter the charging state.
    /// </summary>
    private void GoCharge()
    {
        Vector3 polyHalfExtents = Poly.GetComponentInChildren <Collider>().bounds.extents / 2f;

        Destination = ChargingStation.GetComponent <Collider>().bounds.center -
                      new Vector3(polyHalfExtents.x / 2.5f, polyHalfExtents.y * 2.5f, polyHalfExtents.z / 4f);

        State = PolyStates.Charging;
    }
Пример #3
0
    /// <summary>
    /// Places P0ly into the requested state.
    /// </summary>
    public void SetState(PolyStates state)
    {
        switch (state)
        {
        case PolyStates.Charging:
            GoCharge();
            break;

        case PolyStates.Hiding:
            GoHide();
            break;

        case PolyStates.Returning:
            ReturnToUser();
            break;

        default:
            GoIdle();
            break;
        }
    }
Пример #4
0
 /// <summary>
 /// Instruct P0ly to enter the idle state.
 /// </summary>
 private void GoIdle()
 {
     Destination = Position;
     State       = PolyStates.Idle;
 }
Пример #5
0
 /// <summary>
 /// Instruct P0ly to enter the returning state.
 /// </summary>
 private void ReturnToUser()
 {
     Destination = Camera.main.transform.position + ((Camera.main.transform.forward) * 1.5f);
     State       = PolyStates.Returning;
 }