Пример #1
0
        /// <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);
        }
Пример #2
0
        private bool AliveProcess()
        {
            var overrideReturn = OnAlive();

            var serviceAliveEventArgs = new ServiceAliveEventArgs();

            Alive?.Invoke(this, serviceAliveEventArgs);

            var returnValue = overrideReturn || serviceAliveEventArgs.Alive;

            return(returnValue);
        }
Пример #3
0
 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);
         }
     }
 }
Пример #4
0
    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);
            }
        }
    }
Пример #5
0
 protected virtual void OnAlive(EntityChangedEventArgs e)
 {
     Alive?.Invoke(this, e);
 }
Пример #6
0
 protected virtual void OnAlive(ScriptEntityEventArgs e)
 {
     Alive?.Invoke(this, e);
 }