Example #1
0
    public GameObject GetClosestWater()
    {
        WaterDeposit res     = null;
        float        closest = Mathf.Infinity;

        if (playerList.waters.Count > 0)
        {
            foreach (WaterDeposit o in playerList.waters)
            {
                float dist = (transform.position - o.transform.position).sqrMagnitude;
                if (res == null || dist < closest)
                {
                    res     = o;
                    closest = dist;
                }
            }
        }

        if (!res)
        {
            return(null);
        }

        return(res.gameObject);
    }
Example #2
0
    private void GetClosestStore()
    {
        HashSet <WaterDeposit> water = owner.playerList.waters;

        Vector3 pos     = resourceStore.transform.position;
        Vector3 current = ResourceManager.InvalidPosition;

        foreach (WaterDeposit h in water)
        {
            Vector3 distance = h.transform.position - pos;
            if (distance.sqrMagnitude < current.sqrMagnitude)
            {
                resourceDeposit = h;
                current         = distance;
            }
        }
    }
Example #3
0
 public override void StopActions()
 {
     base.StopActions();
     resourceDeposit = null;
     resourceStore   = null;
 }