예제 #1
0
    private BlacksmithResourceDeposit GetClosest()
    {
        var stacks = COMPONENT_DATABASE.RetrieveComponents <BlacksmithResourceDeposit>();

        if (stacks.Count == 0)
        {
            return(null);
        }

        BlacksmithResourceDeposit closest = null;
        float closestDist = float.MaxValue;

        foreach (var s in stacks)
        {
            var stack = (BlacksmithResourceDeposit)s;

            if (stack.logs <= 0)
            {
                continue;
            }

            float dist = (stack.gameObject.transform.position - transform.position).magnitude;

            if (dist < closestDist)
            {
                closest     = stack;
                closestDist = dist;
            }
        }

        return(closest);
    }
예제 #2
0
    public override void SetTarget()
    {
        BlacksmithResourceDeposit closest = GetClosest();

        if (closest != null)
        {
            m_TargetDeposit = closest;
            target          = m_TargetDeposit.transform;
        }
    }
예제 #3
0
    public override void SetTarget()
    {
        var closest = GetClosest();

        if (closest != null)
        {
            m_TargetStack = closest;
            target        = m_TargetStack.transform;
        }
    }
예제 #4
0
    private BlacksmithResourceDeposit GetClosest()
    {
        var trees = COMPONENT_DATABASE.RetrieveComponents <BlacksmithResourceDeposit>();

        BlacksmithResourceDeposit closest = null;
        float closestDist = float.MaxValue;

        foreach (var tree in trees)
        {
            float dist = (tree.gameObject.transform.position - transform.position).magnitude;

            if (dist < closestDist)
            {
                closest     = (BlacksmithResourceDeposit)tree;
                closestDist = dist;
            }
        }

        return(closest);
    }
예제 #5
0
 protected override void DoReset()
 {
     m_DepositedWood = false;
     m_TargetDeposit = null;
 }