public void setPosition(TrainUnit newObject) { //change hashmap of bandit-position GameManager gm = GameManager.getInstance(); gm.banditPositions[this.characterAsString] = newObject; }
//position public TrainUnit getPosition() { GameManager gm = GameManager.getInstance(); TrainUnit pos = (TrainUnit)gm.banditPositions[this.characterAsString]; return((TrainUnit)pos); }
/*public void setLeft(TrainUnit otherTrainUnit) { * this.left = otherTrainUnit; * otherTrainUnit.right = this; * }*/ /*public TrainUnit getBeside() { * GameManager gm = GameManager.getInstance(); * TrainUnit beside = * return beside; * }*/ //similar logic as above, below, left right public bool isAdjacentTo(TrainUnit otherTrainUnit) { if (otherTrainUnit == this.getAbove() || otherTrainUnit == this.getBelow() || otherTrainUnit == this.getLeft() || otherTrainUnit == this.getRight()) { return(true); } return(false); }
// // trainLength // public static int getTrainLength() { // return TrainUnit.trainLength; // } // public static void setTrainLength(int length) { // TrainUnit.trainLength = length; // } // // train // public ArrayList getTrain() { // return train; // } // // stagecoach // public static TrainUnit[] getStagecoach() { // return TrainUnit.stagecoach; // } public TrainUnit getAbove() { GameManager gm = GameManager.getInstance(); int index = gm.trainCabin.IndexOf(this); if (index == -1) { return(null); } TrainUnit above = (TrainUnit)gm.trainRoof[index]; return(above); }
// get above/get below logic: query the hashtable, find the element in the roof or cabin arraylists in the GM, and treat as 2D array /*public void setAbove(TrainUnit otherTrainUnit) { * this.above = otherTrainUnit; * otherTrainUnit.below = this; * }*/ public TrainUnit getBelow() { GameManager gm = GameManager.getInstance(); int index = gm.trainRoof.IndexOf(this); if (index == -1) { return(null); } TrainUnit below = (TrainUnit)gm.trainCabin[index]; return(below); }
public ArrayList getBanditsHere() { GameManager gm = GameManager.getInstance(); ArrayList banditsArr = new ArrayList(); foreach (Bandit b in gm.bandits) { foreach (DictionaryEntry de in gm.banditPositions) { TrainUnit t = (TrainUnit)de.Value; if (b.characterAsString.Equals(de.Key) && de.Value.Equals(this)) { banditsArr.Add(b); break; } } } return(banditsArr); }
public void setAdjacentTo(TrainUnit adjacentTo) { this.adjacentTo = adjacentTo; }
public Horse(TrainUnit adjacentTo) { this.adjacentTo = adjacentTo; }
public void setMarshalPosition(TrainUnit pos) { this.marshalPosition = pos; }