Skip to content

Commit

Permalink
merge with emily's changes to margic carpet and desert
Browse files Browse the repository at this point in the history
  • Loading branch information
ethansr committed Mar 2, 2014
2 parents 83b8686 + dcd0921 commit 6258908
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 157 deletions.
15 changes: 6 additions & 9 deletions Assets/Scripts/DesertExplorer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ void returnToSource ()
{
stopFlashing ();
removeSelfFromDesertState ();
gameObject.GetComponent<Meeple> ().player.GetComponent<Player> ().endTurn ();

reactToMovementEnding ();

gameObject.GetComponent<Meeple> ().endExploration ();

}
Expand All @@ -86,7 +88,7 @@ void OnMouseUpAsButton ()

if (MagicCarpet.waitingForPlayersMagicCarpetSelection) {

MagicCarpet.explorerToMove = gameObject;
MagicCarpet.explorerToMove = gameObject;


} else if (DesertMovementController.inMovementPhase && isMyPlayersTurn () && currentTile && firstExplorerMovedThisTurn ()) {
Expand Down Expand Up @@ -142,11 +144,8 @@ bool moving ()

bool flyingMagicCarpet ()
{
return MagicCarpet.explorerToMove == gameObject;
return MagicCarpet.explorerToMove == gameObject;
}
//called when we run out of water,
//and by the desert generator.


public void reactToMovementEnding ()
{
Expand Down Expand Up @@ -241,7 +240,6 @@ void handleSuccessfulMove (GameObject newLocation)
return;
addGoodToPlayerInventory (newLocation);
if (GameController.testMeeplesSentBackToBazaarAfterFindingGood && !isMercenary ()) {
//closeMovement ();
leaveCurrentTile ();
returnToSource ();
} else
Expand Down Expand Up @@ -271,8 +269,7 @@ void graphicallyIndicateMoveState ()
else
GetComponent<SpriteRenderer> ().color = defaultColor;
flash *= -1;




}

Expand Down
31 changes: 10 additions & 21 deletions Assets/Scripts/DesertMovementController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class DesertMovementController : Event
float sendToSourceDelayStart;
bool waitingOnExplorerReturn = false;

/*
/*
//magic carpet controller variables
public static GameObject playerWithMagicCarpet;
//requires:
Expand Down Expand Up @@ -141,6 +141,7 @@ public void updatePlayer ()
void endDesertMovementPhase ()
{
sendExplorersOnBazaarBackToSource ();
resetAllPlayerMovementVariables ();

eventStartTime = Time.time;
waitingOnExplorerReturn = true;
Expand All @@ -158,7 +159,8 @@ void announceEndOfMovePhaseAfterDelay ()
}

void announceEndOfMovePhase ()
{
{

showingEndOfMovePhaseScreen = true;
initializeEvent ();
waitingOnExplorerReturn = false;
Expand All @@ -168,7 +170,6 @@ void announceEndOfMovePhase ()

public override void activateEvent (GameObject aNullValueUseTheCollection)
{

showingEndOfMovePhaseScreen = false;
showingPlayerMustTradeGoodsForExplorerScreen = true;
initializeEvent ();
Expand All @@ -180,15 +181,6 @@ public override void activateEvent (GameObject aNullValueUseTheCollection)

}

void initializeEvent ()
{
anEventIsHappeningInGeneral = true;
effectOccurring = true;
inControlOfTextBox = true;
tookEffect = false;
eventStartTime = Time.time;
}

void Update ()
{
if (waitingOnExplorerReturn) {
Expand All @@ -202,24 +194,21 @@ void Update ()
}

} else if (inControlOfTextBox) {
disableEventTextBox ();
inControlOfTextBox = false;
anEventIsHappeningInGeneral = true;
closeEvent ();


closeMovementPhase ();
closeMovementPhase ();
}



}


protected override void takeEffect ()
{

if (showingEndOfMovePhaseScreen) {
resetAllPlayerMovementVariables ();
//resetAllPlayerMovementVariables ();
checkForPlayersWhoNeedToReturnMeepleToSourceForGood ();


Expand Down Expand Up @@ -301,7 +290,7 @@ bool somePlayersNeedToTradeGoodsForExplorer ()

void closeMovementPhase ()
{
Debug.Log ("called end of move phase");

resetDesertState ();
playersWhoMustTradeGoodsForExplorer.Clear ();

Expand Down Expand Up @@ -350,9 +339,9 @@ void OnGUI ()



}

}

}



Expand Down
24 changes: 16 additions & 8 deletions Assets/Scripts/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public abstract class Event : MonoBehaviour
protected float delayStartTime;
protected float eventTextBoxDisplayDelay = 2.0f;
protected bool inControlOfTextBox;
public bool endPlayersTurn;


public abstract void activateEvent (GameObject desertExplorer);

Expand Down Expand Up @@ -110,15 +110,23 @@ protected void displayResultOfTwoCaseEvent (bool result, string waitingForResult
}

protected abstract void takeEffect ();
/*
protected void tellPlayerToFinishEndTurn ()

protected void initializeEvent ()
{
if (explorer && explorer.GetComponent<Meeple> ().player && endPlayersTurn) {
endPlayersTurn = false;
explorer.GetComponent<Meeple> ().player.GetComponent<Player> ().finishEndTurn ();
}
anEventIsHappeningInGeneral = true;
effectOccurring = true;
inControlOfTextBox = true;
tookEffect = false;
eventStartTime = Time.time;
}

protected void closeEvent ()
{
disableEventTextBox ();
inControlOfTextBox = false;
anEventIsHappeningInGeneral = false;

}
*/


}
27 changes: 11 additions & 16 deletions Assets/Scripts/Invader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,23 @@ public void prepareForInvasion ()

public override void activateEvent (GameObject desertExplorer)
{
anEventIsHappeningInGeneral = true;
effectOccurring = true;
inControlOfTextBox = true;
tookEffect = false;
eventStartTime = Time.time;
initializeEvent ();
explorer = desertExplorer;

}

protected override void takeEffect ()
{
swapLocationsWithVictim ();
moveIntoVictimsTile ();
removePlayersInvaderAbility ();



}

void swapLocationsWithVictim ()
void moveIntoVictimsTile ()
{
GameObject tileOfVictim = explorer.GetComponent<DesertExplorer> ().currentTile;



gameObject.GetComponent<DesertExplorer> ().updateLocation (tileOfVictim);

}
Expand All @@ -62,14 +55,16 @@ void Update ()
displayResultOfTwoCaseEvent (true, invaderMessagePartOne, invaderMessagePartTwo, "");

} else if (inControlOfTextBox) {
disableEventTextBox ();
inControlOfTextBox = false;
anEventIsHappeningInGeneral = false;
explorer.GetComponent<DesertExplorer> ().updateLocation (tileFromWhichInvaderAttacks);
//tellPlayerToFinishEndTurn ();
closeEvent ();
moveVictimToInvadersOldTile ();

}


}


void moveVictimToInvadersOldTile ()
{
explorer.GetComponent<DesertExplorer> ().updateLocation (tileFromWhichInvaderAttacks);
}
}
53 changes: 29 additions & 24 deletions Assets/Scripts/MagicCarpet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ void Update ()
displayResultOfTwoCaseEvent (true, magicCarpetMessage, partTwoMagicCarpet, "");

} else if (inControlOfTextBox) {
disableEventTextBox ();
inControlOfTextBox = false;
anEventIsHappeningInGeneral = false;

//tellPlayerToFinishEndTurn ();
closeEvent ();
}

handleMagicCarpetPlayerSelection ();


Expand All @@ -57,33 +54,49 @@ void handleMagicCarpetPlayerSelection ()

public void setTilePlayerHasChosen (GameObject chosenTile)
{
if (!chosenTile.GetComponent<DesertTile> ().isBazaar () && chosenTile.GetComponent<DesertTile> ().roomForMoreOccupants ())
if (explorerToMove && validTile (chosenTile))
tileToMoveTo = chosenTile;

}

public void setExplorerPlayerHasChosen (GameObject explorer)
{
if (explorer.tag.Equals ("explorer") && explorer.GetComponent<Meeple> ().player == playerWithMagicCarpet)
if (validExplorer (explorer))
explorerToMove = explorer;

}

bool playerHasMadeValidSelectionOfTileAndExplorer ()
{

if (explorerToMove && tileToMoveTo) {
if (tileToMoveTo.GetComponent<DesertTile> ().getNumOccupants () > 0)
return tileToMoveTo.GetComponent<DesertTile> ().handleOccupiedTile (explorerToMove, tileToMoveTo);

return true;
}
return false;
return (explorerToMove && tileToMoveTo);

}

bool validExplorer (GameObject explorer)
{
return explorer.tag.Equals ("explorer") && explorer.GetComponent<Meeple> ().player == playerWithMagicCarpet && !explorer.GetComponent<DesertExplorer> ().hasMovedThisRound;

}

bool validTile (GameObject tile)
{
return !tile.GetComponent<DesertTile> ().isBazaar () && tile.GetComponent<DesertTile> ().roomForMoreOccupants () && explorerCanMoveToTile (tile);
}

bool explorerCanMoveToTile (GameObject tile)
{
if (tile.GetComponent<DesertTile> ().getNumOccupants () > 0)
return tile.GetComponent<DesertTile> ().handleOccupiedTile (explorerToMove, tile);

return true;

}

void moveChosenExplorerToChosenTile ()
{
explorerToMove.GetComponent<DesertExplorer> ().updateLocation (tileToMoveTo);
explorerToMove.GetComponent<DesertExplorer> ().reactToMovementEnding ();
}

void closeMagicCarpetEvent ()
Expand Down Expand Up @@ -127,14 +140,6 @@ public override void activateEvent (GameObject dummy)
showingMagicCarpetScreen = true;

}

void initializeEvent ()
{
anEventIsHappeningInGeneral = true;
effectOccurring = true;
inControlOfTextBox = true;
tookEffect = false;
eventStartTime = Time.time;
}


}
17 changes: 5 additions & 12 deletions Assets/Scripts/Mercenary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,16 @@ public override void activateEvent (GameObject desertExplorer)
void Update ()
{
price = requiredNumberOfGood + " " + desiredGoodType.ToString ();
canHireMessage = "You may hire the mercenary for " + price + System.Environment.NewLine + ". Do you wish to?";
canHireMessage = "You may hire the mercenary for " + price + System.Environment.NewLine + ". Do you wish to?";
insufficientFundsMessage = "you cannot pay my price of " + price;
cannotHireMessage = "Either " + insufficientFundsMessage + System.Environment.NewLine + " or " + noRoomMessage;

if (effectOccurring) {
displayResultOfTwoCaseEvent (mercenaryCanBeHired, foundMercenaryMessage, canHireMessage, cannotHireMessage);
} else if (!showingButtons ()) {
if (inControlOfTextBox) {
disableEventTextBox ();
inControlOfTextBox = false;
anEventIsHappeningInGeneral = false;
//tellPlayerToFinishEndTurn ();
closeEvent ();

}

}
Expand Down Expand Up @@ -211,16 +209,11 @@ public void pickDesiredGoodTypeGivenCurrentLocation (GameObject currentLocation)
//assume that whenever this event has been called the new desired good type has been updated
public void reActivateEvent (GameObject desertExplorer)
{
anEventIsHappeningInGeneral = true;
inControlOfTextBox = true;


initializeEvent ();
mercenaryCanBeHired = roomAtTileWhereLocated () && checkIfPlayerHasSufficientFunds (desertExplorer.GetComponent<Meeple> ().player);
if (mercenaryCanBeHired)
getGoodItemsPlayerCanPay (desertExplorer.GetComponent<Meeple> ().player);
effectOccurring = true;
tookEffect = false;
eventStartTime = Time.time;

explorer = desertExplorer;

}
Expand Down
Loading

0 comments on commit 6258908

Please sign in to comment.