void shooter() { //Sounds and particles for shooting ShotsFired.Play(); GetComponent <AudioSource>().Play(); RaycastHit hit; if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range)) { //Checking if raycast hits the enemy or tree and calls for smackings Target target = hit.transform.GetComponent <Target>(); if (target != null) { target.TakeDamage(damage); } TreeHit tree = hit.transform.GetComponent <TreeHit>(); if (tree != null) { tree.TakeDamage(damage); } Instantiate(ShotImpact, hit.point, Quaternion.LookRotation(hit.normal)); } }
public override void OnThink() { if (DateTime.Now >= m_NextTalk) { foreach (Item tree in this.GetItemsInRange(1)) { if (tree is TreeHit) { if (this.FindItemOnLayer(Layer.FirstValid) != null && !(this.FindItemOnLayer(Layer.FirstValid) is Hatchet)) { this.Delete(); } else if (this.FindItemOnLayer(Layer.TwoHanded) != null && !(this.FindItemOnLayer(Layer.TwoHanded) is Hatchet)) { this.Delete(); } TreeHit log = (TreeHit)tree; log.OnDoubleClick(this); m_NextTalk = (DateTime.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(2, 5))); } } } }