void OnTriggerEnter(Collider other)
    {
        MerchantSellHandler m;

        if (!other.CompareTag("Worker"))
        {
            return;
        }
        //Debug.Log ("Trigger enter WORKER");

        BazarController tmp             = transform.parent.GetComponent <BazarController>();
        GameObject      closestMerchant = null;
        float           currDistance    = float.MaxValue;

        foreach (GameObject iMerchant in tmp.m_merchantList)
        {
            float tmpDistance = Vector3.Distance(iMerchant.transform.position, other.transform.position);
            m = iMerchant.GetComponent <MerchantSellHandler>();
            if (m.isBusy())
            {
                continue;
            }
            if (tmpDistance < currDistance)
            {
                currDistance    = tmpDistance;
                closestMerchant = iMerchant;
            }
        }
        if (closestMerchant == null)
        {
            return;
        }
        m = closestMerchant.GetComponent <MerchantSellHandler>();
        m.ChaseTarget(other);
    }
    void OnTriggerExit(Collider other)
    {
        if (!other.CompareTag("Worker"))
        {
            return;
        }
        //Debug.Log ("Trigger exit WORKER");

        BazarController tmp = transform.parent.GetComponent <BazarController>();

        foreach (GameObject iMerchant in tmp.m_merchantList)
        {
            MerchantSellHandler m = iMerchant.GetComponent <MerchantSellHandler>();
            m.ForgetTarget(other);
        }
    }
Esempio n. 3
0
    public void selectBazaar(GameObject newSourceGameObject)
    {
        if (currentGUIMode == 0)
        {
            //Let's start by de-selecting the previously selected object
            if (sourceBazaar != null)
            {
                Component[] renderers = sourceBazaar.GetComponentsInChildren <Renderer>();
                foreach (Renderer rendu in renderers)                   //TODO: gör det här effektivare DOY
                {
                    if (rendu.name == "tent_exterior")
                    {
                        rendu.material.color = Color.white;
                    }
                }
            }


            if (newSourceGameObject != null)
            {
                sourceBazaar = newSourceGameObject.GetComponent <BazarController>();

                Component[] renderers = newSourceGameObject.GetComponentsInChildren <Renderer>();
                foreach (Renderer rendu in renderers)                   //TODO: gör det här effektivare DOY
                {
                    if (rendu.name == "tent_exterior")
                    {
                        rendu.material.color = Color.red;
                    }
                }
            }
            else
            {
                sourceBazaar = null;
            }
        }
    }
Esempio n. 4
0
 public void SetBazaar(BazarController b)
 {
     bazaar = b;
 }