コード例 #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="achv">Associated achievement</param>
        /// <param name="duration">Duration to stay visible (ms)</param>
        /// <param name="position">Starting position</param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        public AchievementToast(Achievement achv, int duration, Vector2 position, int width, int height)
        {
            title = achv.Name;
            description = achv.Description;
            age = 0;
            lifespan = duration;
            this.position = position;
            this.width = width;
            this.height = height;
            banner = SpriteDatabase.GetAnimation("achievement_banner").Texture;

            // Yellow particles spew out on the left and right in semi-circles away from the banner
            leftSpewer = new ParticleSpewer(
                position.X+53, position.Y + 52,
                10000, 30, MathHelper.ToRadians(90), MathHelper.ToRadians(270),
                0, 500, 2, 120, 60, 60, 0, 1, 1, 1, true, 0.5f);
            leftSpewer.Absolute = true;
            leftSpewer.Start();

            rightSpewer = new ParticleSpewer(
                position.X + width, position.Y + 52,
                10000, 30, MathHelper.ToRadians(-90), MathHelper.ToRadians(90),
                0, 500, 2, 120, 60, 60, 0, 1, 1, 1, true, 0.5f);
            rightSpewer.Absolute = true;
            rightSpewer.Start();
        }
コード例 #2
0
ファイル: HUD.cs プロジェクト: iknowDavenMC/SuperFlash
        /*-------------------------------------------------------------------------*/
        #region Constructor + Load methods

        private HUD()
        {
            //Set window properties
            windowWidth = Game1.SCREEN_WIDTH;
            windowHeight = Game1.SCREEN_HEIGHT;

            hudComponents = new List<SpriteComponent>();
            hudDrawComponents = new List<DrawComponent>();
            //Components
            bannerComponent = new SpriteComponent(new Vector2(windowWidth / 2, windowHeight - 20), new Vector2(800, 45));
            healthBarComponent = new SpriteComponent(new Vector2(bannerComponent.getPosition().X-280, bannerComponent.getPosition().Y), new Vector2(580, 12));
            healthBarComponent.setOriginLeft();
            healthBarContainerComponent = new SpriteComponent(new Vector2(bannerComponent.getPosition().X + -284, bannerComponent.getPosition().Y + 10), new Vector2(590, 19));
            healthBarContainerComponent.setOriginBottomLeft();
            //superFlashIconComponent = new SpriteComponent(new Vector2((bannerComponent.getPosition().X - bannerComponent.getSize().X/2) - 25, bannerComponent.getPosition().Y-2), new Vector2(45.0f, 45.0f));
            powerUpIcon = new PowerUpIcon(new Vector2(100, 50), 0f, false);
            superFlashIcon = new DrawOscillate(SpriteDatabase.GetAnimation("superFlashIcon"), new Vector2(100,150), 0f,true);
            hudDrawComponents.Add(superFlashIcon);
            
            
            
            //Score Positions
            positionScore = new Vector2(bannerComponent.getPosition().X - (bannerComponent.getSize().X / 2) + 10, bannerComponent.getPosition().Y + 4);

            
            
            
            //Initialize current score
            //currentScore = 0;
            scoreScale = 1;
            maxScoreScale = 4.0f;
            scoreIncrement = 10;

            //Set up Timers
            timer = 0;
            timerInterval = 500;

            //Set up current health
            health = 100;
            //healthActual = (int)health;

            //Animate timer 
            timeSoFar = 0;
            TimeToAnimate = 0.4f;
            animationSpeed = 0.005f;

            //Game over initializations 
            isGameOver = false; 
            gameOverTextPosition = new Vector2(windowWidth / 2, windowHeight / 2);
            gameOverTextScale = 5.0f;
            gameOverTextSize = new Rectangle(0, 0, 556, 126);
            gameOverCurrentTime = 0.0f; 

            //Fade To Black initialization 
            fadeToBlackAlpha = 0.0f;
            fadeToBlackDesiredAlpha = 0.8f;
            fadeToBlackPosition = new Vector2(0.0f, 0.0f);
            fadeToBlackCurrentTime = 0.0f;

            playGameOverMusic = true;

            particleBar = new ParticleSpewer(
                healthBarComponent.getPosition().X + health / 100f * healthBarComponent.getSize().X - 1, healthBarComponent.getPosition().Y,
                50, 20, MathHelper.ToRadians(-90), MathHelper.ToRadians(90),
                50, 200, 2, 200, 90, 90, 0.5f, 1, 1, 1, true, 0.75f);
            particleBar.Absolute = true;

            newHighScore = false;

            //Test for a font component
            replayText = new FontComponent(new Vector2(gameOverTextPosition.X-250, gameOverTextPosition.Y + 40), new Vector2(100, 100));
            timerText = new FontComponent(new Vector2(bannerComponent.getPosition().X + 355, bannerComponent.getPosition().Y - 12), new Vector2(100, 100));

            //Button Initializations
            replayButton = new Button(replayText.getPosition(), replayText.getSize());
            replayText.setAlpha(0.0f);

            mainMenuText = new FontComponent(new Vector2(gameOverTextPosition.X + 100, gameOverTextPosition.Y + 40), new Vector2(100, 100));
            mainMenuText.alpha = 0.0f;
            mainMenuButton = new Button(mainMenuText.getPosition(), mainMenuText.getSize());


            scoreDisplayText = new FontComponent(new Vector2(windowWidth / 2-150, windowHeight / 2 + 100), new Vector2(300, 100));
            scoreDisplayText.setFontScale(2.0f);
            scoreDisplayText.alpha = 0.0f;
            scoreDisplayText.setOriginCenter();

            highScoreText = new FontComponent(new Vector2(windowWidth/2-150, windowHeight/2 - 300), new Vector2(300, 300));
            highScoreText.setFontScale(6.0f);
            highScoreText.setOriginCenter();
        }
コード例 #3
0
ファイル: Streaker.cs プロジェクト: iknowDavenMC/SuperFlash
        public Streaker(PhysicsComponent2D phys, DrawComponent draw)
        {
            physics = phys;
            this.draw = draw;
            //Initialize Components using Entitybuilder!

            this.BoundingRectangle = new COMP476Proj.BoundingRectangle(phys.Position, 16, 6);

            inputTimer = 0;
            recoverTimer = 0;
            inputDelay = 100;
            superFlashTimer = 0;
            superFlashDelay = 20000;

            superFlashParticles = new ParticleSpewer(
                phys.Position.X + draw.animation.FrameWidth / 2, phys.Position.Y + draw.animation.FrameHeight / 2,
                10000, 100, 0, MathHelper.TwoPi,
                500, 1000, 2, 600, 30, 60, 0.1f, 0.1f, 1, 1, true, 0.75f);

            danceParticles = new ParticleSpewer(
                phys.Position.X + draw.animation.FrameWidth / 2, phys.Position.Y + draw.animation.FrameHeight / 2,
                10000, 100, 0, MathHelper.TwoPi,
                50, 300, 2, 350, 180, 200, 0.25f, 0.5f, 1, 1, true, 0f);

            powerParticles = new ParticleSpewer(
                phys.Position.X + draw.animation.FrameWidth / 2, phys.Position.Y + draw.animation.FrameHeight / 2,
                10000, 10, 0, MathHelper.TwoPi,
                50, 300, 3, 350, 180, 200, 0.5f, 1f, 0.5f, 1, true, 0f);
            powerParticles.Start();
        }