Ejemplo n.º 1
0
 public static void Destroy(IDestroyable obj)
 {
     if (obj != null)
     {
         obj.Destroy();
     }
 }
Ejemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Ground")
        {
            spriteRenderer.sprite = onGround;

            direction = Vector2.right;
            speed     = 5;
        }

        if (other.tag == "Enemy")
        {
            IDestroyable iD = other.GetComponent <IDestroyable>();
            iD.Destroy();

            direction = tempDirection;

            Destroy();
        }

        if (other.tag == "Terrain")
        {
            Destroy();
        }
    }
Ejemplo n.º 3
0
    public IAction RemoveFieldObject(Vector2Int targetFieldObjectCell)
    {
        IDestroyable fieldObjectToRemove = fieldMatrix.GetObjectFromStorage(targetFieldObjectCell);
        fieldMatrix.SetObjectToDefault(targetFieldObjectCell);

        if (fieldObjectToRemove != null) return new ActionSingle((callback) => { fieldObjectToRemove.Destroy(callback); });
        else return null;
    }
Ejemplo n.º 4
0
        public void Destroy(IDestroyable d)
        {
            toDestroy.Add(d);

            if (!d.IsDestroyed)
            {
                d.Destroy();
            }
        }
Ejemplo n.º 5
0
    private void OnTriggerEnter(Collider other)
    {
        IDestroyable destroyable = other.transform.root.GetComponentInChildren <IDestroyable>();

        if (destroyable != null)
        {
            destroyable.Destroy();
        }
    }
Ejemplo n.º 6
0
        public void DestroyComponent(int x, int y, GameTime gameTime)
        {
            IDestroyable toDestroy = (components[x, y] as IDestroyable);

            if (toDestroy != null)
            {
                toDestroy.Destroy(gameTime);
            }
        }
        /// <summary> Perform damage on the killable object </summary>
        /// <param name="destroyable"> The killable to act on. </param>
        /// <param name="damageAmount">The amount of damage to perform. </param>
        private void Damage(IDestroyable destroyable, int damageAmount)
        {
            destroyable.Health -= (int)(damageAmount / destroyable.Resistance.BulletResistance);
            Log.InfoFormat("Damaged {0}. Health remaining: {1}", destroyable, destroyable.Health);

            if (destroyable.Health <= 0)
            {
                destroyable.Destroy();
            }
        }
Ejemplo n.º 8
0
 public void Trigger(GameObject collider)
 {
     if (collider.tag != "Bullet")
     {
         Destroy(gameObject);
         IDestroyable destroyable = collider.GetComponent <IDestroyable>();
         if (destroyable != null)
         {
             destroyable.Destroy();
         }
     }
 }
Ejemplo n.º 9
0
    public void OnDestroy(int damage, GameObject victim)
    {
        IDestroyable component = victim.GetComponent <IDestroyable> ();

        if (component is BigAsteroidDestroyModel)
        {
            GameManager.Instanse.AsteroidsSpawnController.OnBigAsteroidDestroy(victim.transform.position);
        }
        if (component is UFODestroyModel)
        {
            GameManager.Instanse.UFOSpawnController.OnUFODestroy();
        }
        component.Destroy();
    }
Ejemplo n.º 10
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Enemy")
        {
            IDestroyable iD = other.GetComponent <IDestroyable>();
            iD.Destroy();

            Destroy();
        }
        else if (other.tag == "Terrain" || other.tag == "Core")
        {
            Destroy();
        }
    }
Ejemplo n.º 11
0
 private void OnTriggerStay(Collider other)
 {
     if (other.tag == "Boi")
     {
         if (Input.GetButtonDown("Fire2"))
         {
             IDestroyable destroyable = gameObject.GetComponent <IDestroyable>();
             if (destroyable != null)
             {
                 destroyable.Destroy();
             }
         }
     }
 }
Ejemplo n.º 12
0
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            other.gameObject.GetComponent <PlayerHealth> ().SetHealth(100);
        }

        IDestroyable destroyableObject = (IDestroyable)other.gameObject.GetComponent(typeof(IDestroyable));

        if (destroyableObject != null)
        {
            destroyableObject.Destroy();
            FirePoof.Play();
        }
    }
Ejemplo n.º 13
0
        public void Trigger(GameObject collider)
        {
            if (!isActivated)
            {
                return;
            }

            if (collider.tag == "Player")
            {
                IDestroyable destroyable = collider.GetComponent <IDestroyable>();
                if (destroyable == null)
                {
                    return;
                }
                destroyable.Destroy();
            }
        }
Ejemplo n.º 14
0
 private void OnCollisionEnter(Collision collision)
 {
     //Debug.Log("Łup-");
     if (collision.gameObject.tag == "City")
     {
         // Debug.Log("-du-");
         IDestroyable destroyable = collision.gameObject.GetComponent <IDestroyable>();
         if (destroyable != null)
         {
             destroyable.Destroy();
         }
         Destroy(gameObject);
     }
     if (collision.gameObject.tag == "Player")
     {
         //Debug.LogError("Player hitted!");
         BBHitIntoPlayer?.Invoke(damageForBullets);
         Destroy(gameObject);
     }
 }
        public IEnumerator WaitBang()
        {
            while (lifeTime > 0)
            {
                lifeTime -= Time.deltaTime;
                yield return(null);
            }

            if (OnBang != null)
            {
                OnBang(this, null);
            }

            spriteRender.enabled = false;

            yield return(StartCoroutine(bangEffect.Show(power)));

            //Sends rays in all directions and destroys objects
            Vector2[] directions = new Vector2[] {
                new Vector2(-power, 0),
                new Vector2(power, 0),
                new Vector2(0, -power),
                new Vector2(0, power),
            };
            RaycastHit2D[] hits;
            for (int i = 0; i < directions.Length; i++)
            {
                hits = Physics2D.LinecastAll(transform.position, (Vector2)transform.position + directions[i], contactLayer);
                for (int j = 0; j < hits.Length; j++)
                {
                    IDestroyable obj = hits[j].collider.GetComponent <IDestroyable>();
                    //Checks the location of objects behind an impenetrable wall
                    if (obj == null)
                    {
                        break;
                    }
                    obj.Destroy();
                }
            }
        }
Ejemplo n.º 16
0
 private void OnCollisionEnter(Collision collision)
 {
     //Debug.Log("Łup-");
     if (collision.gameObject.tag == "City")
     {
         // Debug.Log("-du-");
         IDestroyable destroyable = collision.gameObject.GetComponent <IDestroyable>();
         if (destroyable != null)
         {
             destroyable.Destroy();
         }
     }
     if (collision.gameObject.tag == "Player")
     {
         //Debug.LogError("Player hitted!");
         RocketHitIntoPlayer?.Invoke(damageForBullets);
         Destroy(gameObject);
     }
     //trailRenderer.transform.parent = null;
     //Destroy(trailRenderer.gameObject, 13);
     Destroy(gameObject);
 }
Ejemplo n.º 17
0
 public override void Execute()
 {
     _objectToDestroy.OnDestroyed -= OnObjectDestroyedOutside;
     _objectToDestroy.Destroy();
     Finish(true);
 }
Ejemplo n.º 18
0
        private void TryDestroyDestroyableObject(Collider2D triggeredObject)
        {
            IDestroyable objectToBeDestroyed = triggeredObject.GetComponent <IDestroyable> ();

            objectToBeDestroyed?.Destroy();
        }
Ejemplo n.º 19
0
 public void Execute()
 {
     block.Destroy();
 }
Ejemplo n.º 20
0
 private void DestroyDestroyable()
 {
     _destroyable?.Destroy();
     Logging.Log(_source, "Destroy");
 }