Beispiel #1
0
        protected override void UpdateLocally(GameTime gameTime, GraphicsDevice graphicsDevice)
        {
            if (selectedCube == this)
            {
                double angle    = MouseController.DetermineAngleFromMouse(Mario.GetInstance().GetCenter());
                int    desiredX = (int)(56 * Math.Cos(angle)) + Mario.GetInstance().GetCenter().X - this.GetHitBox().Width / 2;
                int    desiredY = (int)(56 * Math.Sin(angle)) + Mario.GetInstance().GetCenter().Y - this.GetHitBox().Height / 2;
                this.XSpeed = (desiredX - this.positionInGame.X) / 5;
                this.YSpeed = (desiredY - this.positionInGame.Y) / 5;
            }
            else
            {
                if (XSpeed > 12)
                {
                    XSpeed = 12;
                }
                else if (XSpeed < -12)
                {
                    XSpeed = -12;
                }
                else if (YSpeed < -10)
                {
                    YSpeed = -10;
                }
                this.XSpeed = (XSpeed * .96f);
                this.Gravity.Update(gameTime);
            }

            if (this.positionInGame.Y > 800)
            {
                if (IsCollidable)
                {
                    Systems.Events.TheInstance.CompanionDied();
                }
                else
                {
                    collidable = true;
                }
                MarioGame.GetInstance.GetMap().Remove(this);
                this.positionInGame = originalPosition;
                this.XSpeed         = 0;
                this.YSpeed         = 0;
                MarioGame.GetInstance.GetMap().Add(this);
            }
        }
        public PortalProjectile(bool left) : base(EffectsFactory.GetInstance(), Mario.GetInstance().GetCenter(), new Vector2())
        {
            Systems.Events.TheInstance.PortalProjectileFiring();
            double angle = MouseController.DetermineAngleFromMouse(Mario.GetInstance().GetCenter());

            this.XSpeed = (int)(SPEED * Math.Cos(angle));
            this.YSpeed = (int)(SPEED * Math.Sin(angle));

            this.left = left;
            if (this.left)
            {
                this.sprite = this.spriteFactory.CreateProduct(EffectTypes.BluePortalProjectile);
            }
            else
            {
                this.sprite = this.spriteFactory.CreateProduct(EffectTypes.OrangePortalProjectile);
            }

            MarioGame.GetInstance.AddNewGameObject(false, this);
        }