Example #1
0
        /// <summary>
        /// Sets the screen up (UI components, multimedia content, etc.)
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            SetBackground(ResourceManager.CreateImage("bg_mobile"), Adjustment.CENTER);

            lbl = new Label(ResourceManager.CreateImage("cell_car"));
            AddComponent(lbl, Preferences.Width / 2, Preferences.Height / 2);

            anim = Animation.CreateAnimation(20);

            anim.AnimationType = AnimationType.Relative;
            anim.AddKey(new KeyFrame(0, 0.1f));
            anim.AddKey(new KeyFrame(5, 0.5f));
            anim.AddKey(new KeyFrame(10, 0.9f));
            anim.AddKey(new KeyFrame(15, 0.5f));
            anim.AddKey(new KeyFrame(anim.NumFrames - 1, 0.1f));

            anim.IsLooped = true;

            AddAnimation(anim);
            //  anim.Play(lbl);

            anim.KeyEvent += new Animation.AnimationHandler(anim_KeyEvent);
            playStop = new Button("Play/Stop");
            AddComponent(playStop, 100, 200);
            playStop.Released += new Component.ComponentEventHandler(playStop_Released);

            keyEventLabel = new Label("Event Raised!!");
            AddComponent(keyEventLabel, Preferences.Width / 2, 620);
            keyEventLabel.Visible = false;
        }
Example #2
0
        /// <summary>
        /// Sets the screen up (UI components, multimedia content, etc.)
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            random = new Random();

            SetBackground(ResourceManager.CreateImage(imagePath + "bg"), Adjustment.CENTER);

            //Rope
            rope = new Label(ResourceManager.CreateImage(imagePath + "rope"));
            rope.Released += new Component.ComponentEventHandler(rope_Released);
            rope.Draggable = false;
            rope.BringToFront = false;
            AddComponent(rope, 422, 384);

            //Doll
            doll = new Label(ResourceManager.CreateImage(imagePath + "doll"));
            doll.BringToFront = false;
            doll.Draggable = false;
            doll.Touchable = false;
            AddComponent(doll, 446, 223);

            //Ball
            AnimatedImage img = ResourceManager.CreateAnimatedImage(imagePath + "animated_ball");
            anim_ball = new StripAnimation(1505, 687, 215, 229, 19);
            anim_ball.FramesPerSecond = 40;
            anim_ball.IsLooped = false;
            img.AddAnimation("ball", anim_ball);
            ball = new Label(img);
            ball.BringToFront = false;
            ball.Released += new Component.ComponentEventHandler(ball_Released);
            AddComponent(ball, 252, 148);

            //Inked Balls
            orangeBall = new Label(ResourceManager.CreateImage(imagePath + "yellow_ball"));
            orangeBall.Released += new Component.ComponentEventHandler(Ball_Released);
            orangeBall.Draggable = false;
            AddComponent(orangeBall, -23, 125);

            blueBall = new Label(ResourceManager.CreateImage(imagePath + "blue_ball"));
            blueBall.Released += new Component.ComponentEventHandler(Ball_Released);
            blueBall.Draggable = false;
            AddComponent(blueBall, 77, 57);

            purpleBall = new Label(ResourceManager.CreateImage(imagePath + "purpel_ball"));
            purpleBall.Released += new Component.ComponentEventHandler(Ball_Released);
            purpleBall.Draggable = false;
            AddComponent(purpleBall, 0, 4);

            redBall = new Label(ResourceManager.CreateImage(imagePath + "red_ball"));
            redBall.Released += new Component.ComponentEventHandler(Ball_Released);
            redBall.Draggable = false;
            AddComponent(redBall, 8, 205);

            greenBall = new Label(ResourceManager.CreateImage(imagePath + "green_ball"));
            greenBall.Released += new Component.ComponentEventHandler(Ball_Released);
            greenBall.Draggable = false;
            AddComponent(greenBall, 50, 100);

            //Bird
            AnimatedImage pipin = ResourceManager.CreateAnimatedImage(imagePath + "animated_bird");
            anim_pipin = new StripAnimation(288, 106, 48, 106, 6);
            anim_pipin.IsLooped = false;
            anim_pipin.FramesPerSecond = 4;
            pipin.AddAnimation("bird", anim_pipin);
            lpipin = new Label(pipin);
            lpipin.Draggable = false;
            lpipin.Released += new Component.ComponentEventHandler(lpipin_Released);
            AddComponent(lpipin, 490, 42);

            //Train
            itrain_off = ResourceManager.CreateImage(imagePath + "train_off");
            itrain_on = ResourceManager.CreateImage(imagePath + "train_on");
            train = new Label(itrain_off);
            train.Released += new Component.ComponentEventHandler(train_Released);
            train.Draggable = false;
            AddComponent(train, 125, 314);

            //Animations
            //- > Ball
            aball = Animation.CreateAnimation(12);
            aball.AnimationType = AnimationType.Relative;
            int quakeoffset = 10;
            aball.AddKey(new KeyFrame(0, Vector2.Zero));
            aball.AddKey(new KeyFrame(3, new Vector2(-quakeoffset, 0)));
            aball.AddKey(new KeyFrame(6, new Vector2(quakeoffset, 0)));
            aball.AddKey(new KeyFrame(9, new Vector2(-quakeoffset, 0)));
            aball.AddKey(new KeyFrame(aball.NumFrames - 1, Vector2.Zero));
            AddAnimation(aball);

            //-> Train
            atrain = Animation.CreateAnimation(250);
            atrain.AnimationType = AnimationType.Relative;
            atrain.AddKey(new KeyFrame(0, Vector2.Zero, 0, 1, 1));
            atrain.AddKey(new KeyFrame(49, new Vector2( 320, 170), 0, 1.5f, 1));
            atrain.AddKey(new KeyFrame(50, new Vector2(-562, -213), 0, 0.8f, 1));
            atrain.AddKey(new KeyFrame(150, new Vector2(-562, -213), 0, 0.8f, 1));
            atrain.AddKey(new KeyFrame(atrain.NumFrames - 1, Vector2.Zero, 0, 1, 1));
            atrain.EndEvent += new Animation.AnimationHandler(atrain_EndEvent);
            AddAnimation(atrain);

            //-> Rope
            arope = Animation.CreateAnimation(75);
            arope.AnimationType = AnimationType.Relative;
            arope.AddKey(new KeyFrame(0, Vector2.Zero));
            arope.AddKey(new KeyFrame(10, new Vector2(-40, 0), true));
            arope.AddKey(new KeyFrame(arope.NumFrames - 1, Vector2.Zero));
            arope.KeyEvent += new Animation.AnimationHandler(arope_KeyEvent);
            AddAnimation(arope);

            //Initialize sound library
            AudioLibrary.Instance.Initialize();
        }
Example #3
0
        /// <summary>
        /// Sets the screen up (UI components, multimedia content, etc.)
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            // Background
            SetBackground(ResourceManager.CreateImage("Images/background_ios"), Screen.Adjustment.CENTER);

            // Sprite sheet image
            SpriteSheet iSpriteSheet = ResourceManager.CreateSpriteSheet("Images/PigeonsAttackSpriteSheet");

            // Pigeons
            Sprite[] lPigeons = new Sprite[5];
            Image iPigeonLookingAtLeft = iSpriteSheet["pigeon_1"];
            Image iPigeonLookingAtRight = iSpriteSheet["pigeon_2"];
            random = new Random();

            lPigeons[0] = new Sprite("pigeon", iPigeonLookingAtLeft);
            lPigeons[1] = new Sprite("pigeon", iPigeonLookingAtLeft);
            lPigeons[2] = new Sprite("pigeon", iPigeonLookingAtRight);
            lPigeons[3] = new Sprite("pigeon", iPigeonLookingAtLeft);
            lPigeons[4] = new Sprite("pigeon", iPigeonLookingAtRight);

            AddComponent(lPigeons[0], 79, 12);
            AddComponent(lPigeons[1], 207, 15);
            AddComponent(lPigeons[2], 345, 16);
            AddComponent(lPigeons[3], 495, 16);
            AddComponent(lPigeons[4], 634, 7);

            // Car
            cCar = new Sprite("cCar", Image.CreateImage(Color.Transparent, 238, 164));

            // Car itself
            lCar = new Sprite("car", iSpriteSheet["car"]);
            cCar.AddChild(lCar);

            // Tires
            Image iTire = iSpriteSheet["steel"];
            lLeftTire = new Sprite("lLeftTire", iTire) { Position = new Vector2(70, 138), Pivot = Vector2.One / 2};
            cCar.AddChild(lLeftTire);

            lRightTire = new Sprite("lRightTire", iTire) { Position = new Vector2(162, 138), Pivot = Vector2.One / 2 };
            cCar.AddChild(lRightTire);

            AddComponent(cCar, 11, 480 - 164 - 24);

            if (AccelerometerSensor.Instance.IsConnected)
            {
                accelerometerDetected = true;
                AccelerometerSensor.Instance.Start();
            }

            #region Shits
            Image iShit = iSpriteSheet["shit"];
            lShit = new Sprite("shit", iShit) { Pivot = Vector2.One / 2};
            // The shit will be hidden since the very begining, so doesn't matter where to place it
            AddComponent(lShit, -100, -100);
            lShit.Visible = false;

            shitPositions = new Vector2[5];
            shitPositions[0] = new Vector2(135, 63);
            shitPositions[1] = new Vector2(267, 70);
            shitPositions[2] = new Vector2(367, 70);
            shitPositions[3] = new Vector2(553, 70);
            shitPositions[4] = new Vector2(657, 63);

            elapsedTimeBetweenShits = TimeSpan.Zero;

            // 60 will cause the animation to take 1 s to complete
            aShitFalling = Animation.CreateAnimation(75);
            aShitFalling.AnimationType = AnimationType.Relative;
            aShitFalling.AddKey(new KeyFrame(0, Vector2.Zero));
            aShitFalling.AddKey(new KeyFrame(aShitFalling.NumFrames - 1, new Vector2(0, 400)));
            // Once the shit touches the road it must dissapear
            aShitFalling.EndEvent += delegate { lShit.Visible = false; };
            AddAnimation(aShitFalling);
            #endregion Shits

            // Semaphore lights
            lRed = new Sprite("red", iSpriteSheet["red"]);
            AddComponent(lRed, 716, 187);
            lAmber = new Sprite("amber", iSpriteSheet["amber"]);
            AddComponent(lAmber, 715, 215);
            lGreen = new Sprite("green", iSpriteSheet["green"]);
            AddComponent(lGreen, 717, 241);
            lAmber.Visible = lGreen.Visible = false;

            // This var will hold the playing time
            elapsedGameTime = TimeSpan.Zero;

            #if DEBUG
            lLog = new Label("N/A", Color.Black, Color.White);
            AddComponent(lLog, Preferences.ViewportManager.TopLeftAnchor);
            #endif

            impacts = 0;
            minClamp = 11;
            // The car won't overpass the semaphore until it turns green
            maxClamp = 545;

            Font fImpacts = ResourceManager.CreateFont("Fonts/spritefont_0_9");
            lImpacts = new Label("0", Color.White, Color.Transparent) { Font = fImpacts};
            AddComponent(lImpacts, 107, 155);
            lImpacts.Visible = false;
            lImpactsBrand = new Sprite("impacts", iSpriteSheet["impacts"]);
            AddComponent(lImpactsBrand, 197, 160);
            lImpactsBrand.Visible = false;
        }