Example #1
0
        public void setPosition(TrainUnit newObject)
        {
            //change hashmap of bandit-position
            GameManager gm = GameManager.getInstance();

            gm.banditPositions[this.characterAsString] = newObject;
        }
Example #2
0
        //position
        public TrainUnit getPosition()
        {
            GameManager gm  = GameManager.getInstance();
            TrainUnit   pos = (TrainUnit)gm.banditPositions[this.characterAsString];

            return((TrainUnit)pos);
        }
Example #3
0
        /*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);
        }
Example #4
0
        // // 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);
        }
Example #5
0
        // 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);
        }
Example #6
0
        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);
        }
Example #7
0
 public void setAdjacentTo(TrainUnit adjacentTo)
 {
     this.adjacentTo = adjacentTo;
 }
Example #8
0
 public Horse(TrainUnit adjacentTo)
 {
     this.adjacentTo = adjacentTo;
 }
Example #9
0
 public void setMarshalPosition(TrainUnit pos)
 {
     this.marshalPosition = pos;
 }