Exemplo n.º 1
0
		public HUDElementClass( Scene scene_current, short wizard = 0 )
			: base()
		{
			CurrentScene = scene_current;
			Parent = this;
			Wizard = wizard;
		}
Exemplo n.º 2
0
		// Constructor for this HUD element, hold a reference to the scene and setup positioning
		// IN: (scene_current) Reference to the current scene, (x) The x position of the element,
		//     (y) The y position of the element
		// OUT: N/A
		public HUDElement_TeamClass( Scene scene_current, float x = 0, float y = 0 )
			: base( scene_current )
		{
			// Position
			X = x;
			Y = y;

			// Team Member display objects
			HUDElement_Child = new HUDElementClass[TEAM_MEMBERS];

			// Initialize Team Member information
			TeamMember = new TeamMemberStruct[TEAM_MEMBERS];
			{
				short member = 0;

				// Matthew
				TeamMember[member].Name = "Matthew Cormack";
				TeamMember[member].Username = "******";
				TeamMember[member].Role = "Programmer";
				TeamMember[member].Website = "www.johnjoemcbob.com";
				member++;

				// Jordan
				TeamMember[member].Name = "Jordan Brown";
				TeamMember[member].Username = "******";
				TeamMember[member].Role = "Programmer";
				TeamMember[member].Website = "www.doctor-melon.com";
				member++;

				// Sean
				TeamMember[member].Name = "Sean Thurmond";
				TeamMember[member].Username = "******";
				TeamMember[member].Role = "Programmer";
				TeamMember[member].Website = "www.carpevenatus.com";
				member++;

				// Max
				TeamMember[member].Name = "Max Wrighton";
				TeamMember[member].Username = "******";
				TeamMember[member].Role = "Engineer";
				TeamMember[member].Website = "www.maxwrighton.com";
				member++;

				// Pip
				TeamMember[member].Name = "Pip Snaith";
				TeamMember[member].Username = "******";
				TeamMember[member].Role = "Artist";
				TeamMember[member].Website = "";
				member++;
			}

			// Initialize as parent to TeamMember elements
			IsParent = true;
		}
Exemplo n.º 3
0
		// After the HUDElement has been added to the scene, rotate & translate appropriately
		// IN: (entity) The entity representing the HUD element
		// OUT: N/A
		public void OnEntityAdded( HUDElementClass entity )
		{
			// Draw HUD on top of all else
			Layer = 10;

			// Is parent and has children, add logic to rotate and transform them too
			if ( entity.IsParent && ( entity.HUDElement_Child.Length > 0 ) )
			{
				foreach ( HUDElementClass element in entity.HUDElement_Child )
				{
					// Check that this element exists (there may be gaps in the array)
					if ( element != null )
					{
						element.OnAdded = new Action( () => OnEntityAdded( element ) ); // Wait for graphics to be added to the scene
					}
				}
			}

			// Move each graphic in relation to where this HUD is positioned
			float x = entity.X;
			float y = entity.Y;
			{
				if ( Rotation < 0 ) // Invert x/y & place on other side of screen
				{
					entity.X = Game.Instance.HalfWidth - y;
					entity.Y = Game.Instance.HalfHeight - x;
				}
				else // Invert x/y
				{
					entity.X = y;
					entity.Y = x;
				}
			}
			foreach ( Graphic graphic in entity.Graphics ) // Update each graphic
			{
				float offx = graphic.X - x;
				float offy = graphic.Y - y;
				{
					if ( Rotation < 0 ) // Place on other side of screen
					{
						offx *= -1;
						offy *= -1;
					}
				}
				graphic.SetPosition( entity.X + offx, entity.Y + offy );
				graphic.Angle += -Rotation;
			}
		}
Exemplo n.º 4
0
		// Remove an entity from both HUDs
		// IN: (entity1) The entity representing the first HUD element, (entity2) The entity representing the second HUD element
		// OUT: N/A
		private void Remove( HUDElementClass entity1, HUDElementClass entity2 )
		{
			HUD[0].Remove( entity1 );
			HUD[1].Remove( entity2 );
		}
Exemplo n.º 5
0
		// Add an entity to both HUDs
		// IN: (entity1) The entity representing the first HUD element, (entity2) The entity representing the second HUD element
		// OUT: N/A
		private void Add( HUDElementClass entity1, HUDElementClass entity2 )
		{
			HUD[0].Add( entity1 );
			HUD[1].Add( entity2 );
		}
		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;
		}
Exemplo n.º 7
0
		// Add an entity to this HUD, with rotation and translation offsets
		// IN: (entity) The entity representing the HUD element
		// OUT: N/A
		public void Add( HUDElementClass entity )
		{
			// Must be added to the scene before the graphics exist
			CurrentScene.Add( entity );
			entity.OnAdded = new Action( () => OnEntityAdded( entity ) ); // Wait for graphics to be added to the scene
		}
Exemplo n.º 8
0
		// Remove an entity from this HUD
		// IN: (entity) The entity representing the HUD element
		// OUT: N/A
		public void Remove( HUDElementClass entity )
		{
			bool removenow = entity.Remove(); // Perform individual element preremove functionality
			if ( removenow )
			{
				CurrentScene.Remove( entity );
			}
		}