public void ForgetChild(CellInterface c) { if (c == this._Child) { this._Child = null; } }
public void Initialize() { WorldCoordinateFactoryInterface coordinateFactory = createCoordinateFactoryThatCanGenerateMockCoordinates(); worldStateMock = new Mock<WorldStateInterface>(); worldState = worldStateMock.Object; testWorld = new World(coordinateFactory, worldState); testCell = testCellMock.Object; worldCoordinates = testWorld.getAvailableWorldCoordinates(); }
/// <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); }
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); } } }
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); }
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); } }
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; } } }
public bool moveUp(CellInterface cell) { int movement = getMovementUp(); return moveCell(cell, movement); }
private void updateCellPosition(CellInterface cell, int newCoordinate) { cellCoordinates[cell] = getCoordinateAtPosition(newCoordinate); }
public NoMovement(World world, CellInterface cell) : base(world, cell) { }
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; }
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; } }
public MoveDown(World world, CellInterface cell) : base(world, cell) { }
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; }
//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; }
private void updateOldestPacmanEver() { if (oldestPacmanEver == null) { oldestPacmanEver = currentOldestPacman; } else { if (oldestPacmanEver.getAge() < currentOldestPacman.getAge()) { oldestPacmanEver = currentOldestPacman; } } }
private bool hasCellBeenDoingTheSameThingToLong(CellInterface cell) { int time = cell.getTimeSinceLastChangeInBehavior(); return time > maxTimePeriodInSeconds; }
public bool moveToRight(CellInterface cell) { int movement = +1; return moveSideways(cell, movement); }
public bool moveToLeft(CellInterface cell) { int movement = -1; return moveSideways(cell, movement); }
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; }
public ActionBase(World world, CellInterface cell) { this.world = world; this.cell = cell; }
private bool hasTheCellEnergy(CellInterface cell) { return cell.getEnergy(); }
/// <summary> /// My version of dealloc. Clear all references so things can be GC'd /// </summary> internal void Clear() { this.Dependants.Clear(); this._Child = null; }
private CoordinateInterface getCoordinate(CellInterface cell) { CoordinateInterface currentCoordinate; if (!cellCoordinates.TryGetValue(cell, out currentCoordinate)) { throw new CellNotInWorldException("Could not find cell"); } return currentCoordinate; }
public Eat(World world, CellInterface cell) : base(world, cell) { }
private int getCurrentPosition(CellInterface cell) { CoordinateInterface currentCoordinate = getCoordinate(cell); int currentPosition = currentCoordinate.getPosition(); return currentPosition; }
private bool isPositionOnCurrentRow(CellInterface cell, int newCoordinate) { int currentPosition = getCoordinate(cell).getPosition(); int currentRow = getRow(currentPosition); int compareRow = getRow(newCoordinate); return compareRow == currentRow; }
public MoveLeft(World world, CellInterface cell) : base(world, cell) { }
public Cell(CellInterface cell) { this.network = cell.getCopyOfNetwork(); setBirthDate(); }