private void Instance_ProjectileExplosion()
        {
            ParticleEmitter particle = new ParticleFactory().Create("explosion") as ParticleEmitter;

            particle.transform.SetPosition(grenade.transform.position);
            particle.Emit();
            grenade.Destroy();
            grenade = null;
        }
Beispiel #2
0
        public override void Update(float deltaTime)
        {
            base.Update(deltaTime);

            currentTime += deltaTime;
            if (grenade != null)
            {
                if (startPositionX == -10)
                {
                    startPositionX = grenade.transform.position.x;
                }
                if (startPositionY == -10)
                {
                    startPositionY = grenade.transform.position.y;
                }

                float lastX = grenade.transform.position.x;
                float lastY = grenade.transform.position.y;
                if (lastY <= 300f)
                {
                    grenade.transform.SetPosition(calculatePos(50f, -9.8f, (float)(50 * (Math.PI / 180.0)), new Vector2(startPositionX, startPositionY), currentTime));
                    //Console.WriteLine(grenade.transform.position.x + " " + grenade.transform.position.y);
                }
                else
                {
                    grenade.Destroy();
                    grenade = null;
                    Console.WriteLine("boom");
                }
            }

            //if (Math.Abs(crate.transform.position.x - tank.transform.position.x) <= (crate.transform.size.x) && Math.Abs(crate.transform.position.y - tank.transform.position.y) <= (crate.transform.size.y))
            //{
            //    crate.Destroy();
            //}
        }