void HealthDrop() { if (healthDropTimer + 1.0f < Time.time) { healthDropTimer = Time.time; Collider[] hitColliders = Physics.OverlapSphere(transform.position, 5.0f); int workerCount = 0; int blondeCount = 0; int sailorCount = 0; for (int i = 0; i < hitColliders.Length; ++i) { CitizenScript citizen = hitColliders[i].GetComponent <CitizenScript>(); AIAttackScript citizenAI = hitColliders[i].GetComponent <AIAttackScript>(); if ((citizen != null) && !citizenAI.IsStopped()) { if (citizen.GetType() == CitizenScript.CitizenTypes.Worker) { ++workerCount; } else if (citizen.GetType() == CitizenScript.CitizenTypes.Blonde) { ++blondeCount; } else if (citizen.GetType() == CitizenScript.CitizenTypes.Sailor) { ++sailorCount; } } } float healthDrop = workerCount * healthDropPerWorker + blondeCount * healthDropPerBlonde + sailorCount * healthDropPerSailor; health -= healthDrop; if (healthDrop > 0.0f) { //print(23); GameObject message = (GameObject)Instantiate(Resources.Load("prefabs/message")); Vector3 pos = GetComponent <Collider>().bounds.center; pos.y = 0; message.GetComponentInChildren <PopupMessageScript>().pos = pos; //transform.position/* + new Vector3(0,0,10.0f)*/; message.GetComponent <RectTransform>().SetParent(canvas.transform); message.transform.SetSiblingIndex(0); message.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0); message.GetComponentInChildren <Text>().text = (-healthDrop).ToString(); } if (health <= 0) { EndGame(false); } } }
bool ProcessCitizen(Collider citizenCollider) { CitizenScript citizen = citizenCollider.GetComponent <CitizenScript>(); AIAttackScript citizenAI = citizenCollider.GetComponent <AIAttackScript>(); if ((citizen != null) && !citizenAI.IsStopped()) { if ((target == null) || (citizenAI == target)) { bool hit = false; int moneyEarned = 0; if (m_type == WeaponTypes.LieGenerator) { hit = true; } else if (m_type == WeaponTypes.DrinkSpot) { targetPointerLine.SetColors(new Color(0.811f, 0.713f, 0.368f), new Color(0.811f, 0.713f, 0.368f)); if (citizen.GetType() == CitizenScript.CitizenTypes.Worker) { hit = true; moneyEarned = 10; } else if (citizen.GetType() == CitizenScript.CitizenTypes.Sailor) { hit = true; moneyEarned = 40; } } else if (m_type == WeaponTypes.ShoppingCenter) { targetPointerLine.SetColors(new Color(0.972f, 0.388f, 0.388f), new Color(0.972f, 0.388f, 0.388f)); if (citizen.GetType() == CitizenScript.CitizenTypes.Blonde) { hit = true; moneyEarned = 20; } } else if (m_type == WeaponTypes.Brothel) { targetPointerLine.SetColors(new Color(0.145f, 0.054f, 0.533f), new Color(0.145f, 0.054f, 0.533f)); if (citizen.GetType() == CitizenScript.CitizenTypes.Sailor) { hit = true; moneyEarned = 40; } else if (citizen.GetType() == CitizenScript.CitizenTypes.Worker) { hit = true; moneyEarned = 10; } } /*if (target == null) * {*/ //targetPointer.Play(); if (hit && (target == null)) { target = citizenAI; } if ((citizenAI != target) && (m_type != WeaponTypes.LieGenerator)) { return(false); } //} if (hit) { targetPointerLine.enabled = true; attackTimer = Time.time; if (m_type == WeaponTypes.LieGenerator) { //citizenAI.Stop(); citizenAI.Hit(10); } else if (m_type == WeaponTypes.DrinkSpot) { citizenAI.Hit(1); citizenAI.home = transform.position; } else if (m_type == WeaponTypes.ShoppingCenter) { citizenAI.Hit(5); citizenAI.home = transform.position; } else if (m_type == WeaponTypes.Brothel) { citizenAI.Hit(7); citizenAI.home = transform.position; } } if (citizenAI.IsStopped()) { target = null; //targetPointer.Stop(); targetPointerLine.enabled = false; StatsScript.money += moneyEarned; //print(23); GameObject message = (GameObject)Instantiate(Resources.Load("prefabs/message")); Vector3 pos = GetComponent <Collider>().bounds.center; pos.y = 0; message.GetComponentInChildren <PopupMessageScript>().pos = pos; //transform.position/* + new Vector3(0,0,10.0f)*/; message.GetComponent <RectTransform>().SetParent(canvas.transform); message.transform.SetSiblingIndex(0); message.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 0); message.GetComponentInChildren <Text>().text = "$" + moneyEarned.ToString() + "K"; message.GetComponentInChildren <Text>().color = new Color(0.0f, 0.7f, 0.0f); } return(true); } } return(false); }