コード例 #1
0
ファイル: CarrotFarmer.cs プロジェクト: Redge-Ballard/TownSim
    public void Start()
    {
        dest = GetComponent <Pathfinding.AIDestinationSetter>();
        ai   = GetComponent <Pathfinding.IAstarAI>();
        int rando = Random.Range(0, plants.Length - 1);

        while (plants[rando].IsOccupied())
        {
            rando = Random.Range(0, plants.Length - 1);
        }
        growth = plants[rando];
        growth.MakeOccupied();
        original = growth.point.transform;
        for (int i = 0; i < plants.Length; i++)
        {
            if (plants[i].IsReady())
            {
                original = plants[i].point.transform;
                growth   = plants[i];
                growth.MakeOccupied();
            }
        }
        dest.target  = original;
        dest.enabled = true;
    }
コード例 #2
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();
 }
コード例 #3
0
    void Awake()
    {
        stem             = GetComponent <Stem>();
        growthController = GetComponentInChildren <GrowthController>();
        objectAimer2D    = GetComponentInChildren <ObjectAimer2D>();

        lastHeadPosition = transform.position;
    }
コード例 #4
0
 public void Start()
 {
     _TransformComp   = transform;
     _GrowthComponent = GetComponent <GrowthController>();
     gameObject.SetActive(false);
 }