コード例 #1
0
ファイル: CarrotFarmer.cs プロジェクト: Redge-Ballard/TownSim
 public void Finish()
 {
     if (dest.target == dropoff.transform)
     {
         for (int i = 0; i < plants.Length; i++)
         {
             if (plants[i].IsReady() && !plants[i].IsOccupied())
             {
                 original = plants[i].point.transform;
                 growth   = plants[i];
                 growth.MakeOccupied();
             }
         }
         dest.target   = original;
         goingToGather = true;
         anim.SetBool("carrying", false);
         Vector3 pos = transform.position;
         pos.x += Random.Range(-0.03f, 0.03f);
         pos.y += Random.Range(-0.03f, 0.03f);
         Instantiate(carrot, pos, Quaternion.Euler(0, 0, Random.Range(0, 360)));
     }
     else
     {
         dest.target = dropoff.transform;
         anim.SetBool("carrying", true);
     }
     ai.SearchPath();
 }
コード例 #2
0
 public void Update()
 {
     if (ai.reachedEndOfPath && dir == 0)
     {
         ai.destination = transform.position - transform.right + transform.up;
         ai.SearchPath();
         ++dir;
     }
     else if (ai.reachedEndOfPath && dir == 1)
     {
         ai.destination = transform.position + transform.right + transform.up;
         ai.SearchPath();
         --dir;
     }
 }
コード例 #3
0
ファイル: MoveToPoint2D.cs プロジェクト: Xzygon/Seeker
        void findDestination()
        {
            object target = Blackboard.Get(blackboardKey);

            if (target == null)
            {
                stopAndCleanUp(false);
                return;
            }

            // get target location
            Vector3 destination = Vector3.zero;

            if (target is Transform)
            {
                if (updateFrequency >= 0.0f)
                {
                    destination = ((Transform)target).position;
                }
            }
            else if (target is Vector3)
            {
                destination = (Vector3)target;
            }
            else
            {
                Debug.LogWarning("NavMoveTo: Blackboard Key '" + this.blackboardKey + "' contained unsupported type '" + target.GetType());
                stopAndCleanUp(false);
                return;
            }
            ai.destination = destination;
            ai.SearchPath();

            moveToKey();
        }
コード例 #4
0
ファイル: HandleComeToMe.cs プロジェクト: Lu-D/StealthRogue
    public override void Activate()
    {
        status = goalStatus.active;

        ai.isStopped   = false;
        ai.destination = eventObj.position;
        ai.SearchPath();
    }
コード例 #5
0
    private void chargePlayer()
    {
        LayerMask viewCastLayer = ~(1 << LayerMask.NameToLayer("PlayerSceneColl") |
                                    1 << LayerMask.NameToLayer("PlayerHurt") |
                                    1 << LayerMask.NameToLayer("Enemy"));
        RaycastHit2D hit = Physics2D.Raycast(transform.position, target - transform.position, chargeDistance, viewCastLayer);

        ai.maxSpeed *= chargeSpeed;

        if (hit.collider != null)
        {
            ai.destination = hit.point;
        }
        else
        {
            ai.destination = transform.position + (target - transform.position).normalized * chargeDistance;
        }

        ai.SearchPath();
    }
コード例 #6
0
        static int _m_SearchPath(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                Pathfinding.IAstarAI gen_to_be_invoked = (Pathfinding.IAstarAI)translator.FastGetCSObj(L, 1);



                {
                    gen_to_be_invoked.SearchPath(  );



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }
        }
コード例 #7
0
ファイル: NavigateToRoom.cs プロジェクト: Lu-D/StealthRogue
 private void OnEnable()
 {
     ai.isStopped   = false;
     ai.destination = findRandomRoom();
     ai.SearchPath();
 }
コード例 #8
0
ファイル: EaterChasePlayer.cs プロジェクト: Lu-D/StealthRogue
 private void OnEnable()
 {
     ai.isStopped   = false;
     ai.destination = searchableArea.returnRandomPoint();
     ai.SearchPath();
 }