コード例 #1
0
    public override void OnStateEnter(BaseStateMachine m)
    {
        hasEnded            = false;
        waypointIndex       = 0;
        ai.controller.speed = speed;
        ai.SetDestination(routeList.routes[selectedRoute].GetGlobalPoint(waypointIndex));
        ai.stopMove = false;

        ai.OnFinishPath += NextPoint;
        done             = false;
        //Debug.Log("MY STATE IS " + name + " AND MY ROUTE IS " + selectedRoute);
        //throw new System.NotImplementedException();
    }
コード例 #2
0
ファイル: FLEE_STATE.cs プロジェクト: AlchSet/Psy-Adventure
    public override void OnStateEnter(BaseStateMachine m)
    {
        Vector2 dir = localFSM.transform.position - ai.target.position;

        RaycastHit2D hit = Physics2D.Raycast(localFSM.transform.position, dir.normalized, 20, 1 << LayerMask.NameToLayer("Concrete"));

        if (hit.collider)
        {
            NNInfo info = AstarPath.active.GetNearest(hit.point, NNConstraint.Default);

            escapePoint = info.position;
        }
        else
        {
            NNInfo info = AstarPath.active.GetNearest((Vector2)localFSM.transform.position + dir.normalized * 20, NNConstraint.Default);
            escapePoint = info.position;
        }


        //Debug.Log("<Color=yellow>MY SPEED IS:</Color>" + ai.controller.speed);

        ai.OnFinishPath += FinishFleePoint;



        ai.SetDestination(escapePoint);
        ai.speed = 3;



        //throw new System.NotImplementedException();
    }
コード例 #3
0
    public override void OnStateEnter(BaseStateMachine m)
    {
        ai.QuitPath();
        if (searchBench)
        {
            Physics2D.OverlapCircleNonAlloc(localFSM.transform.position, 7, availableBenches);
            Collider2D b = null;

            foreach (Collider2D bench in availableBenches)
            {
                if (bench != null && bench.CompareTag("REST"))
                {
                    b = bench;
                }
            }



            if (b != null)
            {
                ai.OnFinishPath += Rejuvenate;
                ai.SetDestination(b.transform.position);
            }
            else
            {
                //F**K IT
                Rejuvenate();
            }
        }
        else
        {
            Rejuvenate();
        }
    }