Esempio n. 1
0
 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();
 }
Esempio n. 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;
     }
 }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
    public override void Activate()
    {
        status = goalStatus.active;

        ai.isStopped   = false;
        ai.destination = eventObj.position;
        ai.SearchPath();
    }
Esempio n. 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();
    }
Esempio n. 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));
            }
        }
Esempio n. 7
0
 private void OnEnable()
 {
     ai.isStopped   = false;
     ai.destination = findRandomRoom();
     ai.SearchPath();
 }
Esempio n. 8
0
 private void OnEnable()
 {
     ai.isStopped   = false;
     ai.destination = searchableArea.returnRandomPoint();
     ai.SearchPath();
 }