Exemplo n.º 1
0
 public void ForgetChild(CellInterface c)
 {
     if (c == this._Child)
     {
         this._Child = null;
     }
 }
Exemplo n.º 2
0
 public void Initialize()
 {
     WorldCoordinateFactoryInterface coordinateFactory = createCoordinateFactoryThatCanGenerateMockCoordinates();
     worldStateMock = new Mock<WorldStateInterface>();
     worldState = worldStateMock.Object;
     testWorld = new World(coordinateFactory, worldState);
     testCell = testCellMock.Object;
     worldCoordinates = testWorld.getAvailableWorldCoordinates();
 }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="checkd"></param>
        /// <returns>Should Abandon Parent or Not</returns>
        public bool CheckedClicked(CellInterface sender, bool checkd)
        {
            if (sender != this._Child)
            {
                return(false);
            }

            this.Checked = !checkd;

            return(true);
        }
Exemplo n.º 4
0
 public void HideAll()
 {
     foreach (GameObject cell in CellGrid.Instance.GridCells)
     {
         CellInterface _interface = cell.GetComponent <CellInterface>();
         if (_interface.CurrentTextState != CellInterface.TextState.Changes)
         {
             cell.GetComponent <CellInterface>().ChangeCellDisplay(CellInterface.InterfaceState.Hide);
         }
     }
 }
Exemplo n.º 5
0
 public void ShowDetails()
 {
     foreach (GameObject cell in CellGrid.Instance.GridCells)
     {
         CellInterface _interface = cell.GetComponent <CellInterface>();
         if (_interface.CurrentTextState != CellInterface.TextState.Changes)
         {
             _interface.ChangeCellDisplay(CellInterface.InterfaceState.White);
             _interface.ChangeCellText(CellInterface.TextState.White);
         }
     }
 }
 void Start()
 {
     _interface         = GetComponent <CellInterface>();
     _renderer          = GetComponent <Renderer>();
     _renderer.material = colors[0];
     EventDispatcher.StartListening("Grey", Default);
     EventDispatcher.StartListening("SocialMap", SocialMap);
     EventDispatcher.StartListening("EnvironmentMap", EnvironmentMap);
     EventDispatcher.StartListening("FinanceMap", FinanceMap);
     float _cubeX = ValueManager.Instance.MapWidth / CellGrid.Instance.Columns;
     float _cubeZ = ValueManager.Instance.MapHeight / CellGrid.Instance.Rows;
     // CellRepresentation.transform.localScale = new Vector3(_cubeX, .1f, _cubeZ);
     //GetComponent<BoxCollider>().size = new Vector3(_cubeX, 1f, _cubeZ);
 }
Exemplo n.º 7
0
 private void decideFate(CellInterface cell, Dictionary<CellInterface, CoordinateInterface> cellCoordinates)
 {
     //if (hasTheCellMoved(cell, cellCoordinates))
     //{
     //    removeCell(cell); //All is ok, you survive this time around and is removed from the monitoring
     //    return;
     //}
     //if (hasCellBeenDoingTheSameThingToLong(cell))
     //{
     //    world.deleteCell(cell);
     //    removeCell(cell);
     //}
     if (!hasTheCellEnergy(cell))
     {
         world.deleteCell(cell);
     }
 }
Exemplo n.º 8
0
        private void updateCurrentOldestPacman()
        {
            if (cellCoordinates.Count > 0)
            {
                currentOldestPacman = cellCoordinates.First().Key;
            }
            if (currentOldestPacman == null)
            {
                throw new Exception();
            }
            foreach (CellInterface cell in cellCoordinates.Keys.ToArray())
            {

                if (cell.getAge() > currentOldestPacman.getAge())
                {
                    currentOldestPacman = cell;
                }
            }
        }
Exemplo n.º 9
0
 public bool moveUp(CellInterface cell)
 {
     int movement = getMovementUp();
     return moveCell(cell, movement);
 }
Exemplo n.º 10
0
 private void updateCellPosition(CellInterface cell, int newCoordinate)
 {
     cellCoordinates[cell] = getCoordinateAtPosition(newCoordinate);
 }
Exemplo n.º 11
0
 public NoMovement(World world, CellInterface cell)
     : base(world, cell)
 {
 }
Exemplo n.º 12
0
 private bool moveSideways(CellInterface cell, int movement)
 {
     Stopwatch stopwatch = Stopwatch.StartNew();
     int currentPos = getCoordinate(cell).getPosition();
     int newPosition = currentPos + movement;
     bool ret;
     if (isPositionOnCurrentRow(cell, newPosition))
     {
         ret = moveCell(cell, movement);
     }
     else
     {
         ret = false;
     }
     stopwatch.Stop();
     long time = stopwatch.ElapsedMilliseconds;
     if (time > 1)
     {
         long timex = time; //DUMMY
     }
     return ret;
 }
Exemplo n.º 13
0
 private bool moveToNewCoordinate(CellInterface cell, int newCoordinate)
 {
     CoordinateInterface coordinate = getCoordinate(cell);
     int currentPosition = coordinate.getPosition();
     if (isPositionAdjecent(coordinate, newCoordinate))
     {
         updateCellPosition(cell, newCoordinate);
         return true;
     }
     else
     {
         return false;
     }
 }
Exemplo n.º 14
0
 public MoveDown(World world, CellInterface cell)
     : base(world, cell)
 {
 }
Exemplo n.º 15
0
 private bool moveCell(CellInterface cell, int movement)
 {
     Stopwatch stopwatch = Stopwatch.StartNew();
     CoordinateInterface currentCoordinate = getCoordinate(cell);
     int newCoordinate = currentCoordinate.getPosition() + movement;
     stopwatch.Stop();
     Stopwatch stopwatch2 = Stopwatch.StartNew();
     long time = stopwatch.ElapsedMilliseconds;
     bool ret = moveToNewCoordinate(cell, newCoordinate);
     stopwatch2.Stop();
     long time2 = stopwatch.ElapsedMilliseconds;
     if (time > 1 || time2 > 1)
     {
         long timex = time; //DUMMY
     }
     return ret;
 }
Exemplo n.º 16
0
 //private void removeCell(CellInterface cell)
 //{
 //    if (cellDictionaryWithTimeStamps.Keys.Contains(cell))
 //    {
 //        cellDictionaryWithTimeStamps.Remove(cell);
 //    }
 //}
 private bool hasTheCellMoved(CellInterface cell, Dictionary<CellInterface, CoordinateInterface> cellCoordinates)
 {
     CoordinateInterface coordinate = cellCoordinates[cell];
     if (cellDictionaryWithCoordinates.Keys.Contains(cell))
     {
         if (cellDictionaryWithCoordinates[cell].getPosition() == coordinate.getPosition())
         {
             return false;
         }
         else
         {
             cellDictionaryWithCoordinates[cell] = coordinate;
         }
     }
     else
     {
         cellDictionaryWithCoordinates.Add(cell, coordinate);
     }
     return true;
 }
Exemplo n.º 17
0
 private void updateOldestPacmanEver()
 {
     if (oldestPacmanEver == null)
     {
         oldestPacmanEver = currentOldestPacman;
     }
     else
     {
         if (oldestPacmanEver.getAge() < currentOldestPacman.getAge())
         {
             oldestPacmanEver = currentOldestPacman;
         }
     }
 }
Exemplo n.º 18
0
 private bool hasCellBeenDoingTheSameThingToLong(CellInterface cell)
 {
     int time = cell.getTimeSinceLastChangeInBehavior();
     return time > maxTimePeriodInSeconds;
 }
Exemplo n.º 19
0
 public bool moveToRight(CellInterface cell)
 {
     int movement = +1;
     return moveSideways(cell, movement);
 }
Exemplo n.º 20
0
 public bool moveToLeft(CellInterface cell)
 {
     int movement = -1;
     return moveSideways(cell, movement);
 }
Exemplo n.º 21
0
 public void makeRandomMove(CellInterface cell)
 {
     CoordinateInterface currentCoordinate = getCoordinate(cell);
     List<CoordinateInterface> adjecentCoordinates = get2DAdjecentCoordinates(currentCoordinate);
     int randomPos = rnd.Next(0, adjecentCoordinates.Count - 1);
     CoordinateInterface newCoordinate = adjecentCoordinates.ElementAt(randomPos);
     cellCoordinates[cell] = newCoordinate;
 }
Exemplo n.º 22
0
 public ActionBase(World world, CellInterface cell)
 {
     this.world = world;
     this.cell = cell;
 }
Exemplo n.º 23
0
 private bool hasTheCellEnergy(CellInterface cell)
 {
     return cell.getEnergy();
 }
Exemplo n.º 24
0
 /// <summary>
 /// My version of dealloc.  Clear all references so things can be GC'd
 /// </summary>
 internal void Clear()
 {
     this.Dependants.Clear();
     this._Child = null;
 }
Exemplo n.º 25
0
 private CoordinateInterface getCoordinate(CellInterface cell)
 {
     CoordinateInterface currentCoordinate;
     if (!cellCoordinates.TryGetValue(cell, out currentCoordinate))
     {
         throw new CellNotInWorldException("Could not find cell");
     }
     return currentCoordinate;
 }
Exemplo n.º 26
0
 public Eat(World world, CellInterface cell)
     : base(world, cell)
 {
 }
Exemplo n.º 27
0
 private int getCurrentPosition(CellInterface cell)
 {
     CoordinateInterface currentCoordinate = getCoordinate(cell);
     int currentPosition = currentCoordinate.getPosition();
     return currentPosition;
 }
Exemplo n.º 28
0
 private bool isPositionOnCurrentRow(CellInterface cell, int newCoordinate)
 {
     int currentPosition = getCoordinate(cell).getPosition();
     int currentRow = getRow(currentPosition);
     int compareRow = getRow(newCoordinate);
     return compareRow == currentRow;
 }
Exemplo n.º 29
0
 public MoveLeft(World world, CellInterface cell)
     : base(world, cell)
 {
 }
Exemplo n.º 30
0
 public Cell(CellInterface cell)
 {
     this.network = cell.getCopyOfNetwork();
     setBirthDate();
 }