Monday, May 20, 2013

Building a Prototype - Part 1

We have an idea locked down for our first commercial release.  Design Doc follows:


Project Serious
A top down turn based tactical dungeon crawler, targeted to mobile platforms.

Gameplay:
Hub Screen: services to buy/sell, craft, access stash, recruit heroes and obtain jobs(quests)
Player is offered a selection of quests from a random quest list and must pick only one.  Dungeon areas for quest are randomly generated.
Player manages a party of up to 4 characters, chosen from a roster of heroes.  Heroes can be customised via points earned from levelling them up.
After picking heroes and equiping them, Player can enter quest area and embark on quest and main game begins.
Main Game:
Exploration phase: Player explores randomly generated dungeon. All non-combat actions take place in this phase. Can move each hero up to a maximum of 12 squares.  If enemy is spotted, exploration phase immediately ends and combat phase begins.
Combat Phase: All combatants(heroes and enemies) take turns to act.  Each unit has 'action points' they can spend on moving, attacking and performing special skills.
Combat Phase runs until either all heroes are dead, or all enemies are dead or subdued.  If all heroes die, player is returned to the hub screen.  He can recruit new adventurers to continue the quest, they can also loot the bodies of fallen heroes if they can make it back to the scene and defeat what killed them.
Death is permanent but Resurrection exists, for a price.  To return a life, a life must be given.
These phases run as needed until the victory conditions for the quest are completed and player receives quest reward + dungeon loot and is returned to the hub screen.
Player can upgrade his guild hall to attract more powerful heroes and to better equip new recruits.  Player can add apothecary, enchanters, blacksmiths, leather-workers, etc
CO-OP Mode.
Up to 3 other players can sub in their own heroes from their own rosters in your game, while maintaining the maximum of 4 heroes per adventure. 

Its one thing to write down an idea, and quite another thing to bring it to life.  Before we dive in and start seriously investing our time and resources to this idea, we need to make sure it's actually fun to play.  It sure sounds it on paper (at least to me), but the game execution may not be.  A prototype is needed.

To start we need something to look at.  I can reuse my grid code to store the level layout and the cube creation code from my Maze project to create the actual walls and floor.

In the maze game I used a 2D Int array to store the layout.  The values were always either 0 or 1.  0 denoted an open space (no cube), 1 denoted impassible space(create cube).  If I used this structure as is, it would work, but leave me no flexibility to add anything interesting to the dungeon - right now each 'grid cell' only contains enough information to know if they should be a wall or not.  What if there is a trap in this cell?  Or a chest full of loot?  Or the mysterious glowing well?  A secret doorway? We can create a new structure to store as much information as we need, and store that in a 2D array instead of using Int's. I made Code a read only property because I really don't want this variable being changed once set, but it will be often checked against.

public class GridCell : MonoBehaviour
{
public bool IsPassable; //If false, will be a wall.
private string code; //Will be used to determine any cell features
public string Code
{ get { return code;}}
public void SetData(bool isPassable, string code)
{
IsPassable = isPassable;
this.code = code;
}
}

The GridCell class.  I dont need to attach this script to an object - instances are created through code and stored directly in an array.  I created the following loop for a test run.  As each cell in the level is created, it randomly sets the IsPassable flag to either true or false.

for(int x = 0; x < Width; x++)
{
for(int y = 0; y < Height; y++)
{
       GridCell cell = new GridCell();
int i = Random.Range(0,2);
if(i == 0)
{
cell.SetData(true, string.Empty);
}
else
{
cell.SetData(false, string.Empty);
}
LevelLayout[x,y] = cell;
}
}

And the result with a structure that is 20 cubes high and 40 cubes wide...note the upside down cross in the top right middle of the layout... a sign?


Not much to look at, but it's proves my structure is functioning.  Next - applying some algorithms to make this an actual playable dungeon.


No comments:

Post a Comment