Skip to content

Commit

Permalink
Finished spawn state dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
nthexwn committed Jun 10, 2013
1 parent 0d416f6 commit d0e8922
Show file tree
Hide file tree
Showing 11 changed files with 207 additions and 728 deletions.
76 changes: 76 additions & 0 deletions Haxxit.MonoGame/BoolWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartboyDevelopments.Haxxit.MonoGame
{
public class BoolWrapper
{
private bool status;
public bool Status { get { return status; } set { status = value; } }

public BoolWrapper(bool newStatus)
{
status = newStatus;
}

public bool Equals(bool check)
{
return status == check;
}

public override bool Equals(object obj)
{
// If parameter is null return false.
if (obj == null)
{
return false;
}

// If parameter cannot be cast to Point return false.
BoolWrapper bw = obj as BoolWrapper;
if ((System.Object)bw == null)
{
return false;
}

// Return true if the fields match:
return (status == bw.Status);
}

public override int GetHashCode()
{
if (status)
{
return 1;
}
else
{
return 0;
}
}

public static implicit operator bool(BoolWrapper check)
{
return check.Status;
}

public static implicit operator BoolWrapper(bool newStatus)
{
return new BoolWrapper(newStatus);
}

public static bool operator ==(BoolWrapper checkWrapper, bool checkStatus)
{
bool checkWrapperStatus = checkWrapper.Status;
return checkWrapperStatus == checkStatus;
}

public static bool operator !=(BoolWrapper checkWrapper, bool checkStatus)
{
bool checkWrapperStatus = checkWrapper.Status;
return checkWrapperStatus != checkStatus;
}
}
}
26 changes: 11 additions & 15 deletions Haxxit.MonoGame/GameStates/MapSpawnGameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace SmartboyDevelopments.Haxxit.MonoGame.GameStates
public class MapSpawnGameState : HaxxitGameState
{
const string finished_text = "Finished";
BoolWrapper displayingSpawnDialog;

protected MapDisplayGameState display_map_state;
Texture2D rectangle_texture, rounded_rect_border, finished_texture, leave_map_texture;
Expand All @@ -27,16 +28,19 @@ public class MapSpawnGameState : HaxxitGameState

public MapSpawnGameState()
{
displayingSpawnDialog = false;
}

public MapSpawnGameState(Haxxit.Maps.Map map)
{
display_map_state = new MapDisplayGameState(map);
displayingSpawnDialog = false;
}

public MapSpawnGameState(MapDisplayGameState background_state)
{
display_map_state = background_state;
displayingSpawnDialog = false;
}

public override void NewMediator(SimplePubSub.IMediator mediator)
Expand All @@ -47,21 +51,19 @@ public override void NewMediator(SimplePubSub.IMediator mediator)
public override void Init()
{
display_map_state.Init();
//spawns = new List<DrawableRectangle>();
spawns = new Dictionary<Haxxit.Maps.Point, DrawableRectangle>();
}

public void OnSpawnClick(DrawableRectangle rectangle)
{
Haxxit.Maps.Point haxxit_location = display_map_state.XnaPointToHaxxitPoint(rectangle.Area.Center);
SpawnDialogGameState new_state = new SpawnDialogGameState(this, display_map_state.Map, haxxit_location);
SpawnDialogGameState new_state = new SpawnDialogGameState(this, display_map_state.Map, haxxit_location, displayingSpawnDialog);
_mediator_manager.Notify("haxxit.engine.state.push", this, new ChangeStateEventArgs(new_state));
}

public virtual void OnFinishedClick(DrawableRectangle rectangle)
{
display_map_state.Map.FinishedSpawning();
//UserMapGameState new_state = new UserMapGameState(user_map_state.Map);
MapPlayGameState new_state = new MapPlayGameState(display_map_state);
_mediator_manager.Notify("haxxit.engine.state.change", this, new ChangeStateEventArgs(new_state));
}
Expand Down Expand Up @@ -144,7 +146,6 @@ public override void SubscribeAll()
// being the object that sent the notification, and EventArgs being the
// arguments for the listener. If you need arguments, create a subclass of
// EventArgs with the arguments as properties.

}

public override void Update()
Expand All @@ -169,20 +170,15 @@ public override void Draw(SpriteBatch sprite_batch)
{
display_map_state.Draw(sprite_batch);

finished_button.Draw(sprite_batch);
/*Vector2 finished_text_position = new Vector2(finished_button.Area.X + (finished_button.Area.Width - finished_text_size.X) / 2,
finished_button.Area.Y + (finished_button.Area.Height - finished_text_size.Y) / 2);
sprite_batch.DrawString(arial_16px_regular, finished_text, finished_text_position, Color.White);*/

leave_map_button.Draw(sprite_batch);
/*Vector2 leave_map_text_size = arial_16px_regular.MeasureString("Leave Map");
Vector2 leave_map_text_position = new Vector2(leave_map_button.Area.X + (leave_map_button.Area.Width - leave_map_text_size.X) / 2,
leave_map_button.Area.Y + (leave_map_button.Area.Height - leave_map_text_size.Y) / 2);
sprite_batch.DrawString(arial_16px_regular, "Leave Map", leave_map_text_position, Color.White);*/

if (button_hover != null)
button_hover.Draw(sprite_batch);

if (!displayingSpawnDialog)
{
finished_button.Draw(sprite_batch);
leave_map_button.Draw(sprite_batch);
}

foreach (DrawableRectangle spawn in spawns.Values)
{
spawn.Draw(sprite_batch);
Expand Down
227 changes: 0 additions & 227 deletions Haxxit.MonoGame/GameStates/OLD_MapSpawnGameState.cs

This file was deleted.

Loading

0 comments on commit d0e8922

Please sign in to comment.