public void Initialize() { if (thisObject == null) { Debug.Log("Debug Reference Invalid!"); return; } thisObjectCharacter = thisObject.GetComponent <BareboneCharacter>(); thisObjectBase = thisObject.GetComponent <BareboneObject>(); // IF PLAYER HAS CHARACTER SCRIPT if (thisObjectCharacter != null) { nameText.text = thisObjectCharacter.CharacterName; typeText.text = thisObjectCharacter.ObjectType.ToString(); healthText.text = thisObjectCharacter.CurrentHealth.ToString() + " / " + thisObjectCharacter.MaximumHealth.ToString(); if (!StatInitialize) { CreateStats(); } } // IF PLAYER HAS NO CHARACTER SCRIPT else if (thisObjectBase != null) { nameText.text = thisObjectBase.GeneralName; typeText.text = thisObjectBase.ObjectType.ToString(); } else { Debug.Log("Cannot Comprehend Object Selected, Object has no Barebone Script!!"); } }
// Collision to Check who's getting hit. public void OnTriggerEnter(Collider other) { BareboneObject receiver = other.transform.GetComponent <BareboneObject>(); // if Weapon is not active if (!this.active) { return; } //Check if the hit item is an Object if (!receiver) { return; } if (receiver.Team != team) { // if Collision isLiving if (receiver.ObjectType == ObjectType.Living) { Parameters parameters = new Parameters(); parameters.Initialize(); // Adds all the Damage the weapon can send for (int i = 0; i < bareboneDamages.Count; i++) { BareboneDamage damage = new BareboneDamage(); parameters.AddParameter <BareboneDamage>("DamageType" + i, new BareboneDamage().Copy(bareboneDamages[0])); } // Checks if the weapon has an owner, if so, the owner is also passed as a parameter. if (Owner != null) { if (Owner.GetComponent <BareboneCharacter>()) { parameters.AddParameter <BareboneCharacter>("DamageDealer", Owner); } } // Add Effects receiver.ReceiveDamage(parameters); active = false; } } if (environmentWeapon) { StartCoroutine(ResetActive()); } }
public void Start() { parent = this.transform.parent.GetComponent <BareboneObject>(); }