Example #1
0
        private IEnumerator TimerCourutine()
        {
            for (var i = 0; i < Seconds; i++)
            {
                yield return(Tick());
            }

            ExplosionObject.gameObject.SetActive(true);
            yield return(new WaitForFixedUpdate());

            yield return(new WaitForFixedUpdate());

            var explosionScript = ExplosionObject.GetComponent <ExplosionScript>();

            if (explosionScript != null)
            {
                explosionScript.ExplodeNow(null);
            }
            var rb = GetComponent <Rigidbody2D>();

            if (rb != null)
            {
                rb.velocity = Vector2.zero;
            }
        }
Example #2
0
    /// <summary>
    /// Handle triggers.  Triggers are collisions with objects without rigid bodies such as boundaries and switches.
    /// </summary>
    /// <param name="other"></param>
    private void OnTriggerEnter(Collider other)
    {
        GameObject otherObject = other.gameObject;

        switch (otherObject.tag)
        {
        case "ExplosionTag":
            ExplosionObject explosion = otherObject.GetComponent <ExplosionObject>();

            // This enemy is being hit by a explosion.  Reduce its health by the strength of the explosion
            m_health -= explosion.m_ExplosionStrength;

            if (m_health <= 0)
            {
                m_explosionDeath = true;
                // This enemy has taken too much damage, kill it.
                HandleDeath();
            }
            break;

        default:
            Debug.Log("Encountered an unhandled tag: " + otherObject.tag);
            break;
        }
    }
Example #3
0
    public override void OnKilled()
    {
        ExplosionObject explosion = ObjectPool.instance.GetExplosionObject();

        explosion.transform.position = _turretBase.position;
        explosion.Live();

        gameObject.SetActive(false);
    }
Example #4
0
    private void OnGameOver(Wave wave)
    {
        ExplosionObject explosion = GameDirector.Explosion(gameDirector.player.transform.position, 1.0f);

        cameraController.Setup(explosion.transform);
        cameraController.offset += Vector3.right * 10 + Vector3.up * 8;

        SwitchState(GameState.Postgame);
    }
    public IAbilityObject Spawn(Ability ability, float multiplier)
    {
        ExplosionObject obj = HierarchyManager.Instantiate(this, HierarchyCategory.Effects);

        obj.ability    = ability;
        obj.Multiplier = multiplier;
        obj.StartTime  = Time.time;

        return(obj);
    }
Example #6
0
        private void EnableExplode()
        {
            ExplosionObject.gameObject.SetActive(true);
            ExplosionObject.GetComponent <ExplosionScript>().Initialize();
            var rb = GetComponent <Rigidbody2D>();

            rb.velocity  = Vector2.zero;
            rb.simulated = true;

            _hasCollided = true;
        }
Example #7
0
    public override void OnKilled()
    {
        stop = true;

        ExplosionObject explosion = ObjectPool.instance.GetExplosionObject();

        explosion.transform.position   = transform.position;
        explosion.transform.localScale = new Vector3(10, 10, 10);
        explosion.Live();

        _playerWin.Play();
    }
Example #8
0
    public ExplosionObject CreateExplosion(Vector3 position, float scale)
    {
        ExplosionObject explosion = poolManager.AddObject(templateObject) as ExplosionObject;

        explosion.transform.position   = position;
        explosion.transform.localScale = Vector3.one * scale;

        for (int i = 0; i < explosion.transform.childCount; i++)
        {
            explosion.transform.GetChild(i).localScale = Vector3.one * scale;
        }

        explosion.Setup();
        return(explosion);
    }
Example #9
0
    public override void OnKilled()
    {
        ExplosionObject explosion = ObjectPool.instance.GetExplosionObject();

        explosion.transform.position = transform.position;
        explosion.Live();

        //Destroy (gameObject);
        transform.position = new Vector3(9999, 9999, 9999);
        gameObject.SetActive(false);
        if (_owner != null)
        {
            _owner.Spawn(this);
        }
    }
Example #10
0
        protected PhysicsSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            GraphicsScreen.ClearBackground = true;
            GraphicsScreen.BackgroundColor = Color.White;
            GraphicsScreen.DrawReticle     = true;
            SetCamera(new Vector3F(0, 2, 10), 0, 0);

            // Add game objects which implement simple physics interactions.
            _grabObject        = new GrabObject(Services);
            _ballShooterObject = new BallShooterObject(Services);
            _explosionObject   = new ExplosionObject(Services);
            GameObjectService.Objects.Add(_grabObject);
            GameObjectService.Objects.Add(_ballShooterObject);
            GameObjectService.Objects.Add(_explosionObject);
        }
Example #11
0
    private void OnTriggerEnter(Collider collision)
    {
        if (timeCount < 1f)
        {
            return;
        }

        ExplosionObject explosion = ObjectPool.instance.GetExplosionObject();

        explosion.transform.position = transform.position;
        explosion.Live();

        Killable killable = Target.GetComponent <Killable> ();

        if (killable != null)
        {
            //Cause damage
            killable.OnHit(500, _Owner);
        }

        Destroy(gameObject);
    }
Example #12
0
    private void OnTriggerEnter(Collider other)
    {
        GameObject otherObject = other.gameObject;

        switch (otherObject.tag)
        {
        case "ExplosionTag":
            ExplosionObject explosion = otherObject.GetComponent <ExplosionObject>();

            m_health -= explosion.m_ExplosionStrength;

            if (m_health <= 0)
            {
                m_explosionDeath = true;
                HandleDeath();
            }
            break;

        default:
            Debug.Log("Encountered an unhandled tag: " + otherObject.tag);
            break;
        }
    }
Example #13
0
 private void Awake()
 {
     box       = GetComponent <BoxCollider2D>();
     explosion = GetComponentInChildren <ExplosionObject>();
     animator  = GetComponent <Animator>();
 }