private bool HasEnergy() { HpControl control = Owner.Device.GetControlOfType <HpControl>(); if (control != null) { return(control.Hp == control.MaxHp); } return(true); }
void Awake() { anim = GetComponent<Animator> (); hpObject = Instantiate (prefabHP); hpControl = hpObject.GetComponent<HpControl> (); hpControl.targetTransform = transform; GameObject worldCanvas = GameObject.Find("UI_worldspace"); Vector3 nameOff = new Vector3 (0f, 3.0f, 0f); GameObject nameObj = Instantiate (prefabTextname,transform.position + nameOff,Quaternion.identity) as GameObject; nameObj.transform.SetParent (worldCanvas.transform); nameText = nameObj.GetComponent<Text>(); nameText.text = "绿石怪"; }
void OnCollisionEnter(Collision collision) { HpControl target = collision.collider.GetComponent <HpControl>(); if (target != null) { if (collision.gameObject.layer != ignoreLayer) { target.TakeDamage(damage); } Destroy(gameObject); } if (collision.gameObject.layer == gameObject.layer) { Destroy(gameObject); } }
public void PowerUp(int powerId) { if (Ship != null) { switch (powerId) { case 1: Nukes++; break; case 2: bulletDamageMult += 0.1f; Shot Dmg = Ship.GetComponentInChildren <Shot>(); if (Dmg != null) { Dmg.damageMultiplier = bulletDamageMult; } break; case 3: bulletSpeedMult += 0.01f; Shot Spd = Ship.GetComponentInChildren <Shot>(); if (Spd != null) { Spd.speedMultiplier = bulletDamageMult; } break; case 4: bulletFirerateMult += 0.1f; Shot Frt = Ship.GetComponentInChildren <Shot>(); if (Frt != null) { Frt.fireMultiplier = bulletFirerateMult; } break; case 5: HpControl lifes = Ship.GetComponentInChildren <HpControl>(); if (lifes != null) { lifes.extraLife(); } break; case 6: HpControl baseHealth = Base.GetComponent <HpControl>(); if (baseHealth != null) { baseHealth.GainHealth(30); } break; case 7: HpControl shpHealth = Ship.GetComponentInChildren <HpControl>(); if (shpHealth != null) { shpHealth.GainHealth(30); } break; case 8: Shot Sprd = Ship.GetComponentInChildren <Shot>(); if (Sprd != null) { Sprd.SpreadLevelUp(); } break; case 9: BulletCollection bullLvl = Ship.GetComponentInChildren <BulletCollection>(); bullLvl.LevelUp(); break; default: break; } } }