void HandleCellMove(ICell cell) { int x1 = cell.GetX(), y1 = cell.GetY(), x2, y2; cell.CalcMoveDirectionAspiration(this); MoveDirection md = cell.GetMoveDisperation(); switch (md) { case MoveDirection.up: x2 = x1; y2 = y1 - 1; break; case MoveDirection.down: x2 = x1; y2 = y1 + 1; break; case MoveDirection.left: x2 = x1 - 1; y2 = y1; break; case MoveDirection.right: x2 = x1 + 1; y2 = y1; break; default: return; } if (!ValidateCords(x2, y2)) { return; } IUniverseObject unObj = GetMatrixElement(x2, y2); int desc = unObj.GetDescriptor(); if (unObj.isDisposed()) { RelocateUniverseObject(x1, y1, x2, y2); } else if (desc == -2 || desc == -1) { cell.AddEnergy((unObj as IFood).GetEnergyLevel()); RelocateUniverseObject(x1, y1, x2, y2); } else if (GetMatrixElement(x1, y1).GetDescriptor() == unObj.GetDescriptor()) { cell.AddEnergy(ConstsUniverse.EnergyLevel_MovesFriendly); (unObj as ICell).AddEnergy(ConstsUniverse.EnergyLevel_MovesFriendly); } else { cell.AddEnergy((float)(ConstsUniverse.EnergyLevel_MovesAggression * 0.8)); (unObj as ICell).AddEnergy(-ConstsUniverse.EnergyLevel_MovesAggression); } }