/// <summary> /// Создать экземпляр prefab на сцене /// </summary> /// <param name="position">Место появления</param> /// <param name="parent">Объект требуемого родителя</param> public void CreateMeteor(Vector3 position, GameObject parent) { GameObject newMeteor = Instantiate(generateObject, position, Quaternion.identity, parent.transform); newMeteor.GetComponentInChildren <Slider>().value = newMeteor.GetComponentInChildren <Slider>().maxValue = r.Next(20, 100); CreateNewMeteor?.Invoke(newMeteor); }
private bool AliveProcess() { var overrideReturn = OnAlive(); var serviceAliveEventArgs = new ServiceAliveEventArgs(); Alive?.Invoke(this, serviceAliveEventArgs); var returnValue = overrideReturn || serviceAliveEventArgs.Alive; return(returnValue); }
public void Hit(int damage) { if (timeouthit <= 0) { gameObject.GetComponent <Slider>().value -= damage; timeouthit = 2.0f; if (gameObject.GetComponent <Slider>().value <= 0) { isDead?.Invoke(gameObject); } } }
public void SetDead(bool isDead) { if (isDead) { // Spawn a particle. this.gameObject.SetActive(false); if (Died != null) { Died.Invoke(this); } } else { this.gameObject.SetActive(true); collisionTracker.collidingObjectDictionary.Clear(); if (Alive != null) { Alive.Invoke(this); } } }
protected virtual void OnAlive(EntityChangedEventArgs e) { Alive?.Invoke(this, e); }
protected virtual void OnAlive(ScriptEntityEventArgs e) { Alive?.Invoke(this, e); }