Ejemplo n.º 1
0
Archivo: Shooter.cs Proyecto: Malpp/TP3
        public override void Update(float timeDelta, IEnumerable <Drawable> entities = null)
        {
            if (Math.Abs(Common.AngleBetweenTwoPoints(Pos, Hero.GetInstance().Pos) - CorrectAngle(Angle)) < 1f)
            {
                correctAngle = true;
            }
            else
            {
                correctAngle = false;
            }

            if (canFire && correctAngle)
            {
                canFire = false;
                EntityManager.AddEnemyProjectile(new EnemyProjectile(Pos + Common.MovePointByAngle(shooterTexture.Size.X * 0.3f, Angle), Angle));
            }

            if (!canFire)
            {
                fireDelta += timeDelta;

                if (fireDelta > fireSpeed)
                {
                    fireDelta = 0;
                    canFire   = true;
                }
            }

            base.Update(timeDelta, entities);
        }
Ejemplo n.º 2
0
Archivo: Sniper.cs Proyecto: Malpp/TP3
        public override void Update(float timeDelta, IEnumerable <Drawable> entities = null)
        {
            if (canFire)
            {
                canFire = false;
                sniperChargingSprite.Color -= new Color(0, 0, 0, 0);

                EntityManager.AddEnemyProjectile(new EnemyProjectile(Pos, sniperTurretSprite.Rotation));
            }

            if (!canFire)
            {
                fireDelta += timeDelta;

                sniperChargingSprite.Color = new Color(
                    sniperChargingSprite.Color.R,
                    sniperChargingSprite.Color.B,
                    sniperChargingSprite.Color.G,
                    (byte)(fireDelta * 255 / fireSpeed));

                if (fireDelta > fireSpeed)
                {
                    fireDelta = 0;
                    canFire   = true;
                }
            }

            //sniperTurretSprite.Rotation = Common.AngleBetweenTwoPoints(Pos, Hero.GetInstance().Pos);

            sniperTurretSprite.Rotation = EstimateShootingAngle(timeDelta);

            base.Update(timeDelta, entities);
        }