예제 #1
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player"))
     {
         money PlayerWallet = other.GetComponent <money>();
         PlayerWallet.CollectMoney(HowManyMoneyGetWhenContact);
         Destroy(this.gameObject);
         //transform.position = Vector2.Lerp(transform.position, other.transform.position, Time.deltaTime * 10f);
     }
 }
예제 #2
0
    private void Update()
    {
        Collider2D[] otherCivillan = Physics2D.OverlapCircleAll(transform.position, detectRadius);
        for (int i = 0; i < otherCivillan.Length; i++)
        {
            if (otherCivillan != null && (otherCivillan[i].gameObject.tag == "Enemy" || otherCivillan[i].gameObject.tag == "Player"))
            {
                if (otherCivillan[i].GetComponent <AIBrain>())
                {
                    if (otherCivillan[i].GetComponent <AIBrain>().BiBenh&& !BiBenh && !shieldCircle.activeInHierarchy)
                    {
                        BiBenh           = true;
                        CoBiVirusKo.text = "Đã nhiễm virus: ";
                        DoTayRua         = 100;
                        paidForVirusOnce = true;
                        virusCircle.GetComponent <Image>().fillAmount = 1;
                        if (VirusRuaBangSoapTrueSaniFalse)
                        {
                            CoBiVirusKo.text += "Diệt bằng xà phòng";
                        }
                        else
                        {
                            CoBiVirusKo.text += "Diệt bằng nước rửa tay";
                        }
                    }
                }
                if (otherCivillan[i].gameObject.tag == "Player" && BiBenh)
                {
                    if (GameObject.FindGameObjectWithTag("ShieldForPlayer").GetComponent <SpriteRenderer>().enabled == false)
                    {
                        if (!haveJustDamaged)
                        {
                            haveJustDamaged = true;
                            otherCivillan[i].GetComponent <Enemy>().TakeDamage(20);
                        }
                        StartCoroutine(Forcefield(.3f));
                    }
                }
            }
        }

        Canvas.transform.LookAt(Canvas.transform.position + Vector3.forward);
        shieldCircle.transform.LookAt(shieldCircle.transform.position + Vector3.forward);
        virusCircle.transform.LookAt(virusCircle.transform.position + Vector3.forward);
        vacxinCircle.transform.LookAt(vacxinCircle.transform.position + Vector3.forward);
        if (daxetnghiem)
        {
            if (Input.GetKey(KeyCode.Space))
            {
                panel.SetActive(true);
            }
            else
            {
                panel.SetActive(false);
            }
            if ((MedicHat.activeSelf && Shield.activeSelf) || (!MedicHat.activeSelf && (Mask.activeSelf || Shield.activeSelf)))
            {
                shieldCircle.SetActive(true);
            }
            else
            {
                shieldCircle.SetActive(false);
            }
            if (BiBenh)
            {
                virusCircle.SetActive(true);
            }
            else
            {
                virusCircle.SetActive(false);
            }
            if (NeedTiemPhong)
            {
                vacxinCircle.SetActive(true);
            }
            else
            {
                vacxinCircle.SetActive(false);
            }
        }
        else
        {
            shieldCircle.SetActive(false);
            virusCircle.SetActive(false);
            vacxinCircle.SetActive(false);
        }

        if (DoTayRua <= 0)
        {
            DoTayRua = 0;
            BiBenh   = false;
            if (paidForVirusOnce)
            {
                playerWallet.CollectMoney(12);
                paidForVirusOnce = false;
                GetComponent <randomDestinationAI>().quarantine = true;
            }
            CoBiVirusKo.text = "Đã hết nhiễm virus";
            virusCircle.GetComponent <Image>().fillAmount = 0;
        }
        if (TiemBaoNhieu <= 0)
        {
            TiemBaoNhieu  = 0;
            NeedTiemPhong = false;
            if (paidForVacxinOnce)
            {
                playerWallet.CollectMoney(8);
                paidForVacxinOnce = false;
            }
            TextTiemPhong.text = "Không cần tiêm phòng";
            vacxinCircle.GetComponent <Image>().fillAmount = 0;
        }

        if (BiSot == true)
        {
            Pri_TimeMacBenh += Time.deltaTime;
        }
        if (Pri_TimeMacBenh >= TimeMacBenh)
        {
            Pri_TimeMacBenh  = 0f;
            BiBenh           = true;
            CoBiVirusKo.text = "Đã nhiễm virus: ";
            DoTayRua         = 100;
            paidForVirusOnce = true;
            virusCircle.GetComponent <Image>().fillAmount = 1;
            if (VirusRuaBangSoapTrueSaniFalse)
            {
                CoBiVirusKo.text += "Diệt bằng xà phòng";
            }
            else
            {
                CoBiVirusKo.text += "Diệt bằng nước rửa tay";
            }
        }
        if (DenkhuCachLy == true)
        {
            BiSot             = false;
            CoBiSotKhong.text = "Không sốt";
            Pri_TimeMacBenh   = 0;
        }
    }