public override void Update(GameTime gameTime)
        {
            //if(Site != null)
            //    Site.Update(gameTime);
            if (MyProjectile != null &&
                MyProjectile.ProjectileState == Projectile.PROJECTILE_STATE.STILL)
            {
                myProjectile.TilePosition = TilePosition;
                // fire the rocket and it looks for the target
                if (InputEngine.IsKeyHeld(Keys.Space) || InputEngine.IsMouseLeftClick() ||
                    InputEngine.CurrentPadState.Buttons.A == ButtonState.Pressed)
                {
                    MyProjectile.fire(Site.TilePosition);
                }
            }

            //if (MyProjectile != null)
            //    MyProjectile.Update(gameTime);
            // update the health bar object
            //if (Hbar != null)
            //{
            //    Hbar.position = PixelPosition + new Vector2(-10, -20);
            //    Hbar.health = Health;
            //}
            base.Update(gameTime);
        }
Exemplo n.º 2
0
        public override bool PreAI()
        {
            // pre AI of the charge ball is responsible for telling us if the weapon has changed or the projectile should otherwise die

            bool isPassingPreAi = base.PreAI();

            if (!isPassingPreAi && MyProjectile != null)
            {
                MyProjectile.StartKillRoutine();
            }
            return(isPassingPreAi);
        }
        void OnProjectileHit(ref MyEventProjectileHit msg)
        {
            MyEntity target;

            if (MyEntities.TryGetEntityById(new MyEntityIdentifier(msg.TargetEntityId), out target))
            {
                MyEntity source;
                if (!msg.SourceEntityId.HasValue || !MyEntities.TryGetEntityById(new MyEntityIdentifier(msg.SourceEntityId.Value), out source))
                {
                    source = null;
                }
                var ammo = MyAmmoConstants.GetAmmoProperties(msg.AmmoType);

                target.DoDamage(ammo.HealthDamage, ammo.ShipDamage, ammo.EMPDamage, ammo.DamageType, ammo.AmmoType, source);
                MyProjectile.ApplyProjectileForce(target, msg.Position, Vector3.Normalize(msg.Direction), !(target is MySmallShipBot));
            }
        }