예제 #1
0
        public GameManager()
            : base()
        {
            Session = Game.Instance.Session(0);
            AddComponent(GameStateMachine);
            Session.LoadData();

            BestScore = float.Parse(Session.GetData("best", "0"));

            EventRouter.Subscribe(Events.FlippyFlipped, (EventRouter.Event e) => {
                ScoreMultiplier += 1;
            });

            EventRouter.Subscribe(Events.FlippyDied, (EventRouter.Event e) => {
                GameStateMachine.ChangeState(GameState.End);
            });

            EventRouter.Subscribe(Events.UpdateBestScore, (EventRouter.Event e) => {
                Session.Data["best"] = BestScore.ToString();
                Session.SaveData();
            });

            R = Game.Instance.Color.R;
            G = Game.Instance.Color.G;
            B = Game.Instance.Color.B;
        }
예제 #2
0
        public Paddle(Session player)
            : base()
        {
            this.player = player;

            AddComponent(paddleSM);

            paddleSM.AddState("Shortened","Lengthened","SpeedBoosted","SpeedSlowed","Normal");
            paddleSM.ChangeState(stateNormal);

            SetGraphic(imgPaddle);
            imgPaddle.CenterOrigin();

            SetHitbox(10, 100, (int)Tags.Paddle);

            if (player.Id == 0) { // player 1
                X = 50;
                imgHealthBar.X = imgHealthBarBg.X = imgHealthBarFill.X = X + 50;
            }
            else { // player 2
                X = Game.Instance.Width - 50;
                imgHealthBar.X = imgHealthBarBg.X = imgHealthBarFill.X = X - 50;
            }

            imgHealthBar.Y = imgHealthBarBg.Y = imgHealthBarFill.Y = 30;
            imgHealthBarFill.CenterOrigin();
            imgHealthBarBg.CenterOrigin();
            Y = Game.Instance.HalfHeight;
        }
예제 #3
0
파일: Flippy.cs 프로젝트: JOCP9733/tank
        public Flippy(Session session)
            : base()
        {
            Session = session;

            Image.OutlineThickness = 3;
            Image.OutlineColor = Color.Orange;

            Graphic = Image;

            SetHitbox(10, 10);
            Hitbox.CenterOrigin();
            Image.CenterOrigin();

            AddComponent(Movement);
            Movement.Collider = Hitbox;

            Y = Game.Instance.HalfWidth;
            X = 120;
        }
예제 #4
0
        public Player(float x, float y, Session session)
            : base(x, y)
        {
            // Assign session
            this.session = session;

            // Init bounce sounds
            bounce[0] = new Sound("assets/sfx/bounce1.wav");
            bounce[1] = new Sound("assets/sfx/bounce2.wav");
            bounce[2] = new Sound("assets/sfx/bounce3.wav");
            for (int i = 0; i < 3; ++i) {
                bounce[i].Volume = 0.98f;
            }

            // Set up animations
            sprite.Add(AnimType.Go, new Anim(new int[] { 0, 1, 2, 3, 4, }, new float[] { 5.0f }));
            sprite.Add(AnimType.Attack, new Anim(new int[] { 7, 8, 9, 10, 11, 12, 13 }, new float[] { 4.0f }));
            sprite.Play(AnimType.Go);

            // Set up hitboxes
            SetHitbox(sprite.Width - 24, sprite.Height - 24, (int)Tags.PLAYER);
            Hitbox.CenterOrigin();

            // Sprite stuff
            sprite.CenterOrigin();
            Graphic = sprite;

            Layer = -1;

            // Initilize light
            light = new Light();
            light.SetAlpha(0.7f);
            light.SetColor(new Color("879DFF"), new Color("62D8E0"));
            light.SetColorSpan(5.0f);
            light.SetRadius(sprite.Width + 30, sprite.Width + 60);
            light.SetRadiusSpan(5.0f);
            light.entity = this;
            Level.lights.Add(light);

            // TODO: Make ink slow you down
        }
예제 #5
0
		// Pass in reference to the GameWands system & setup values unique to each wizard
		// IN: (gamewands) Reference to the Leap tool game state handler, (wizardtype) Light or dark wizard,
		//     (wizard) The ID of this wizard, (angle) The rotation of this wizard from 0 facing upwards
		// OUT: N/A
		public WizardClass( Session playsession, GameWandsClass gamewands, WizardTypeStruct wizardtype, int wizard, float angle )
			: base()
		{
			LinkedSession = playsession;
			GameWands = gamewands;
			WizardType = wizardtype;
			ID = wizard;
			Angle = angle;
		}
		public override void Added()
		{
			base.Added();

			// The number of rows on the keyboard for positioning other elements
			short rows = 0;

			// Initialize entered text display
			Text_UserString = new Text( "@", 48 );
			{
				Text_UserString.CenterOrigin();
				Text_UserString.X = X + ( KEY_SIZE * 2 );
				Text_UserString.Y = Y;
				Text_UserString.OutlineThickness = 4;
				Text_UserString.OutlineQuality = TextOutlineQuality.Absurd;
			}
			AddGraphic( Text_UserString );

			// Initialie the array of key character strings
			KeyCharacter = new string[KEYS];
			{
				// Start key index at 0 to enable key++ in one line
				short key = 0;

				// Row 1
				KeyCharacter[key++] = "1";
				KeyCharacter[key++] = "2";
				KeyCharacter[key++] = "3";
				KeyCharacter[key++] = "4";
				KeyCharacter[key++] = "5";
				KeyCharacter[key++] = "6";
				KeyCharacter[key++] = "7";
				KeyCharacter[key++] = "8";
				KeyCharacter[key++] = "9";
				KeyCharacter[key++] = "0";
				KeyCharacter[key++] = "_";

				// Row 2
				KeyCharacter[key++] = "Q";
				KeyCharacter[key++] = "W";
				KeyCharacter[key++] = "E";
				KeyCharacter[key++] = "R";
				KeyCharacter[key++] = "T";
				KeyCharacter[key++] = "Y";
				KeyCharacter[key++] = "U";
				KeyCharacter[key++] = "I";
				KeyCharacter[key++] = "O";
				KeyCharacter[key++] = "P";
				KeyCharacter[key++] = "";

				// Row 3
				KeyCharacter[key++] = "A";
				KeyCharacter[key++] = "S";
				KeyCharacter[key++] = "D";
				KeyCharacter[key++] = "F";
				KeyCharacter[key++] = "G";
				KeyCharacter[key++] = "H";
				KeyCharacter[key++] = "J";
				KeyCharacter[key++] = "K";
				KeyCharacter[key++] = "L";
				KeyCharacter[key++] = "";
				KeyCharacter[key++] = "";

				// Row 4
				KeyCharacter[key++] = "Z";
				KeyCharacter[key++] = "X";
				KeyCharacter[key++] = "C";
				KeyCharacter[key++] = "V";
				KeyCharacter[key++] = "B";
				KeyCharacter[key++] = "N";
				KeyCharacter[key++] = "M";
				KeyCharacter[key++] = "";
				KeyCharacter[key++] = "";
				KeyCharacter[key++] = "";
				KeyCharacter[key++] = "";
			}

			// Initialize the array of keys
			HUDElement_Child = new HUDElementClass[KEYS];
			{
				// Initialize key positions
				short column = 0;
				short row = 0;

				for ( short key = 0; key < KEYS; key++ )
				{
					// Check if the key exists before drawing it
					if ( KeyCharacter[key] != "" )
					{
						// Center the key row on the keyboard
						float startx = -( ( KEYS_ROW - 1 ) * ( KEY_SIZE + KEY_OFFSET ) / 2 ) + ( row * ( KEY_SIZE + KEY_OFFSET ) / 2 );
						// Offset the key by the current column
						float keyx = ( column * ( KEY_SIZE + KEY_OFFSET ) );
						// Offset the key by the current row
						float keyy = -( row * ( KEY_SIZE + KEY_OFFSET ) );

						HUDElement_Child[key] = new HUDElement_KeyClass(
							CurrentScene, // Reference to the current scene
							startx + keyx + X, // Position X
							keyy + Y, // Position Y
							KeyCharacter[key] // The key string to display
						);
						HUDElement_Child[key].Parent = this;
						HUDElement_Child[key].Layer = 1;
						CurrentScene.Add( HUDElement_Child[key] );
					}

					// Offset the button to the correct row and column
					column++;
					if ( column >= KEYS_ROW )
					{
						row++;
						column = 0;
					}
				}
				rows = row;
			}

			// Initialize instructional graphics
			float offsetx = ( rows * 2 * ( KEY_SIZE + KEY_OFFSET ) ) * 1.1f;

			// Fire, red, enter character
			Button_Fire = new Otter.Image( "../../resources/button.png" );
			{
				Button_Fire.Color = Color.Red;
				Button_Fire.CenterOrigin();
				Button_Fire.X = X - offsetx;
				Button_Fire.Y = Y;
			}
			AddGraphic( Button_Fire );

			Text_Enter = new Text( "Enter the selected character", 32 );
			{
				Text_Enter.OutlineThickness = 4;
				Text_Enter.CenterOrigin();
				Text_Enter.X = X - offsetx;
				Text_Enter.Y = Y;
			}
			AddGraphic( Text_Enter );

			// Move the two elements to be centered together
			{
				Button_Fire.OriginX = Button_Fire.HalfWidth * 1.1f + Text_Enter.HalfWidth;
				Text_Enter.OriginX = -Button_Fire.HalfWidth * 1.1f + Text_Enter.HalfWidth;
				Text_Enter.OriginY = Button_Fire.OriginY / 2;
			}
			offsetx += Button_Fire.Width * 1.1f;

			// Lightning, yellow, remove character
			Button_Lightning = new Otter.Image( "../../resources/button.png" );
			{
				Button_Lightning.Color = Color.Yellow;
				Button_Lightning.CenterOrigin();
				Button_Lightning.X = X - offsetx;
				Button_Lightning.Y = Y;
			}
			AddGraphic( Button_Lightning );

			Text_Remove = new Text( "Remove the last character", 32 );
			{
				Text_Remove.OutlineThickness = 4;
				Text_Remove.CenterOrigin();
				Text_Remove.X = X - offsetx;
				Text_Remove.Y = Y;
			}
			AddGraphic( Text_Remove );

			// Move the two elements to be centered together
			{
				Button_Lightning.OriginX = Button_Lightning.HalfWidth * 1.1f + Text_Remove.HalfWidth;
				Text_Remove.OriginX = -Button_Lightning.HalfWidth * 1.1f + Text_Remove.HalfWidth;
				Text_Remove.OriginY = Button_Lightning.OriginY / 2;
			}
			offsetx += Button_Lightning.Width * 1.1f;

			// Earth, green, toggle ready
			Button_Earth = new Otter.Image( "../../resources/button.png" );
			{
				Button_Earth.Color = Color.Green;
				Button_Earth.CenterOrigin();
				Button_Earth.X = X - offsetx;
				Button_Earth.Y = Y;
			}
			AddGraphic( Button_Earth );

			Text_Ready = new Text( "Ready to tweet", 32 );
			{
				Text_Ready.OutlineThickness = 4;
				Text_Ready.CenterOrigin();
				Text_Ready.X = X - offsetx;
				Text_Ready.Y = Y;
			}
			AddGraphic( Text_Ready );

			// Move the two elements to be centered together
			{
				Button_Earth.OriginX = Button_Earth.HalfWidth * 1.1f + Text_Ready.HalfWidth;
				Text_Ready.OriginX = -Button_Earth.HalfWidth * 1.1f + Text_Ready.HalfWidth;
				Text_Ready.OriginY = Button_Earth.OriginY / 2;
			}
			offsetx += Button_Earth.Width * 1.1f;

			// Initialize as parent to Key elements
			IsParent = true;

			// Initialzie the controller session
			ControllerSession = Game.Instance.Sessions[Player];

			// Flag an update to ensure that the first key is highlighted
			FirstUpdate = true;

			// Initialize unready
			Ready = false;

			// Draw the preview tweet a layer above the keyboard
			Layer = 0;
		}
예제 #7
0
 public Bomberman(Session session, Color color)
 {
     this.Session = session;
     this.Color = color;
     Initialize();
 }
예제 #8
0
 public GameScene(Session player)
 {
     Player = player;
     GenerateNew();
 }