private IEnumerator FloatingXPTextDisplay(ItemOre ore) { floatingOreText = (GameObject)GameObject.Instantiate(Resources.Load("FloatingXPText"), transform.position, Quaternion.identity); floatingOreTextScript = floatingOreText.GetComponent<FloatingXPText>(); floatingOreTextScript.parent2 = transform; floatingOreTextScript.textColor = new Color(1.0f, 0.6f, 0.0f, 1.0f); yield return new WaitForEndOfFrame(); floatingOreTextScript.displayText("+1 " + ore.ToString()); Destroy(floatingOreText,2); // Surface level parent should be a rogue room, so assume: renderer.material.SetTexture("_DecalTex", crackTextures[0]); ((RogueRoom)_cube.Parent).DestroyMineableBlock(this); //Destroy (gameObject); }
/// <summary> /// Destroys the cube, and alerts all necessary parties that it was. /// </summary> void killUnit() { if (_cube.Type != ItemBase.tOreType.Stone && _cube.Type != ItemBase.tOreType.NOT_ORE) { floatingOreText = (GameObject)GameObject.Instantiate(Resources.Load("FloatingXPText"), transform.position, Quaternion.identity); floatingOreTextScript = floatingOreText.GetComponent<FloatingXPText>(); floatingOreTextScript.parent2 = transform; floatingOreTextScript.enabled = true; floatingOreTextScript.textColor = new Color(1.0f, 0.6f, 0.0f, 1.0f); ItemOre ore = new ItemOre(_cube.Type); floatingOreTextScript.displayText("+1 " + ore.ToString()); StartCoroutine(FloatingXPTextDisplay(ore)); Inventory.getInstance().inventoryAddItem(ore); } else { // Surface level parent should be a rogue room, so assume: renderer.material.SetTexture("_DecalTex", crackTextures[0]); ((RogueRoom)_cube.Parent).DestroyMineableBlock(this); } //_cube.Parent.DestroyCube(_cube); //Destroy (gameObject); }
protected override void Start() { moveSpeed = 5.0f; control = GetComponent<CharacterController>(); base.Start(); //gets reference to weapon, among other things. healthBar = (Transform) GameObject.Instantiate(healthBarStatic, transform.position, Quaternion.identity); floatingDamageText = (GameObject) GameObject.Instantiate(Resources.Load("FloatingDamageText"), transform.position, Quaternion.identity); floatingDamageTextScript = floatingDamageText.GetComponent<FloatingDamageText>(); floatingDamageTextScript.parent = transform; floatingXPText = (GameObject) GameObject.Instantiate(Resources.Load("FloatingXPText"), transform.position, Quaternion.identity); floatingXPTextScript = floatingXPText.GetComponent<FloatingXPText>(); floatingXPTextScript.parent2 = transform; }