private void OnEnable() { _template = (BoardTemplate)target; List <ElementPair> pairs = _template.Tiles; tilesList = CreateList(serializedObject, serializedObject.FindProperty("_tiles"), "tiles", "element", 5); }
// Assigs placed words to LetterCell multidimensional array and sets formatting public void AssignCrosswordDisplayBoard(BoardTemplate <char> board, BoardTemplate <PlacedWordGroup> placedWordBoard) { for (var i = 0; i < board.Height; i++) { for (var j = 0; j < board.Width; j++) { DisplayBoard[i][j].LetterOut = board.Layout[i, j]; DisplayBoard[i][j].LetterIn = '\0'; DisplayBoard[i][j].DefinitionLocation = String.Empty; DisplayBoard[i][j].FontWeight = FontAttributes.None; DisplayBoard[i][j].FontColour = Colours.Font; DisplayBoard[i][j].PlacedWordGroup = placedWordBoard.Layout[i, j]; if (board.Layout[i, j] == board.EmptyChar) { DisplayBoard[i][j].BackgroundCellColour = Colours.BackgroundCell; DisplayBoard[i][j].IsEnabled = false; } else { DisplayBoard[i][j].BackgroundCellColour = Colours.Forground; DisplayBoard[i][j].IsEnabled = true; } } } }
public BoardTemplate SetupBoard(SynthData data) { var board = new BoardTemplate(); board.AddBoard(data.SubBoards["glideSubBoard"]); board.AddBoard(data.SubBoards["pitchWheelSubBoard"]); board.AddBoard(data.SubBoards["volumeControlSubBoard"]); var env1 = new Envelope(30, 240, 0.6f, 40, 3); var o1 = new OscillatorModule(new SawOscillator(), 1); var o2 = new OscillatorModule(new SawOscillator(), 1, 0.08f); var o3 = new OscillatorModule(new SawOscillator(), 1, 11.92f); var d1 = new Distributer(new float[] { 1, 0.7f, 0.0f }, new float[] { 1 }); //var sf1 = new EffectModule(new SimpleFilter(5)); var sf1 = new EffectModule(new Filter(Filter.GenerateSincKernel((float)FilterCutoff.Value, 64, data.SampleRate))); var g1 = new EffectModule(new Boost(0.2f)); var lfo2 = new ConstantOscillatorModule(new SineOscillator(), 1, 0.5f); var p1 = new Pan(); var endLeft = new EndModule(false); var endRight = new EndModule(true); board.Add(endLeft, endRight, sf1, d1, o3, o2, o1, env1, g1, lfo2, p1); //board.AddConnections(glideIn, glideTranslate, glideOut); //board.AddConnection(pitchWheel, pitchShift); //board.AddConnections(volumeControl, volumeTranslate, boardGain); board.AddConnection(env1, o1, destIndex: 0); board.AddConnection(env1, o2, destIndex: 0); board.AddConnection(env1, o3, destIndex: 0); board.AddConnection(o1, d1); board.AddConnection(o2, d1); board.AddConnection(o3, d1); board.AddConnections(d1, g1, sf1, p1); board.AddConnection(p1, endLeft); board.AddConnection(p1, endRight); return(board); }
/// <summary> /// Shows the board and starts the game. /// </summary> public void StartGame() { List <SnakeProfile> snakes = Player.Instance.Snakes.Take(Mathf.Min(Player.Instance.Snakes.Count, 5)).ToList(); BoardTemplate template = DefaultResources.GetRandomTemplate(snakes.Count); HideAllPanels(); Restart(snakes, template); GamePanel.gameObject.SetActive(true); }
public SynthData(string settingsPath = "Assets/Settings") { settings = SettingsLoader.LoadSettings(settingsPath); Root = settings.GetString("paths", "root"); if (!File.GetAttributes(Root).HasFlag(FileAttributes.Directory)) { throw new SettingsException("paths", "key", "root path must be a directory"); } Log = new Logger(new PathList(settings.GetStrings("paths", "log"), Root).Root); SampleRate = settings.GetInt("main", "sampleRate"); DesiredLatency = settings.GetInt("main", "desiredLatency"); PitchWheelRange = settings.GetFloat("main", "pitchWheelChange"); SavedBoardsPaths = new PathList(settings.GetStrings("paths", "savedBoards"), Root); DefaultBoardsPaths = new PathList(settings.GetStrings("paths", "defaultBoards"), Root); MidiPaths = new PathList(settings.GetStrings("paths", "midi"), Root); WavPaths = new PathList(settings.GetStrings("paths", "wav"), Root); ModuleTypePaths = new PathList(settings.GetStrings("paths", "moduleTypes"), Root); OscillatorPaths = new PathList(settings.GetStrings("paths", "oscillatorTypes"), Root); EffectPaths = new PathList(settings.GetStrings("paths", "effectTypes"), Root); ModuleTypes = new LoaderTypes <Module>(ModuleTypePaths, "moduleType", "SynthLib"); OscillatorTypes = new LoaderTypes <Oscillator>(OscillatorPaths, "oscillatorType", "SynthLib"); EffectTypes = new LoaderTypes <Effect>(EffectPaths, "effectType", "SynthLib"); Console.WriteLine(DefaultBoardsPaths); var subBoards = new Dictionary <string, BoardTemplate>(); foreach (var f in DefaultBoardsPaths.Files()) { var element = XDocument.Load(f).Root; var subBoard = new BoardTemplate(element, this); subBoards[Path.GetFileNameWithoutExtension(f)] = subBoard; } SubBoards = subBoards; }
/// <summary> /// Resets board to original conditions. /// </summary> public void Reset(BoardTemplate template) { _template = template; Columns = template.Cells.Count; Rows = template.Cells[0].raw.Count; UpdateTiles(); for (int i = 0; i < Columns; i++) { for (int j = 0; j < Rows; j++) { if (template.Cells[i].raw[j].element == LogicElement.LogicElementType.MyHead || template.Cells[i].raw[j].element == LogicElement.LogicElementType.MyBody) { this[i, j].Init(template.CellsBack[i].raw[j], template.CellsBack[i].raw[j]); } else { this[i, j].Init(template.Cells[i].raw[j], template.CellsBack[i].raw[j]); } } } }
/// <summary> /// Returns game to initial conditions. /// </summary> private void Restart(List <SnakeProfile> snakeProfiles, BoardTemplate template) { snakes = new List <Snake>(); Board.Reset(template); foreach (SnakeProfile sp in snakeProfiles) { Snake snake = new Snake(Board, sp); snakes.Add(snake); } for (int i = 0; i < snakes.Count; i++) { snakes[i].Reset(template.GetSnakeBasePositions(i, snakes[i].Profile.Length)); } time = 0; }
// Calculates updated array position based on previous board and recenelty updated char public Tuple <int, int> GetUpdatePosition(ObservableCollection <ObservableCollection <LetterCell> > displayBoardIn, BoardTemplate <char> compareBoard) { var updatePos = new Tuple <int, int>(0, 0); for (var i = 0; i < displayBoardIn.Count; i++) { for (var j = 0; j < displayBoardIn[i].Count; j++) { if (displayBoardIn[i][j].LetterIn != compareBoard.Layout[i, j]) { //Debug.WriteLine(displayBoardIn[i][j].LetterIn); updatePos = new Tuple <int, int>(j, i); compareBoard.Layout[i, j] = displayBoardIn[i][j].LetterIn; } } } return(updatePos); }
public Board GetRandomBoard(Game game) { _game = game; var template = new BoardTemplate(game.RuleSet.BoardSize); var fleet = game.RuleSet.GetFleet().OrderByDescending(t => t.Size); List <List <Point> > mapped = new List <List <Point> >(); int shipId = 0; int x, y; List <Point> fallback; int fallbackIndex; foreach (var ship in fleet) { for (int i = 0; i < ship.Count; i++) { List <Point> placed = new List <Point>(); IEnumerable <CellTemplate> tmp; int toPlace = ship.Size; int it = 0; do { randomxy(out x, out y); if (++it > 1000000) { return(GetRandomBoard(game)); } } while (template.Cells[x, y].State != CellTemplateState.EMPTY || template.GetZone(x, y).Count(t => t.State == CellTemplateState.EMPTY) < toPlace); template.PlaceCore(x, y, shipId); placed.Add(new Point(x, y)); toPlace--; while (toPlace > 0) { fallback = new List <Point>(placed); do { fallbackIndex = _random.Next(0, fallback.Count); Point item = fallback[fallbackIndex]; fallback.RemoveAt(fallbackIndex); tmp = template.GetSides((int)item.X, (int)item.Y).Where(t => t.State == CellTemplateState.EMPTY || (t.State == CellTemplateState.ZONE && t.ShipID == shipId));//.Where(t => template.GetZone(t.X, t.Y).All(t2 => t2.IsNotColliding(shipId))); }while ((tmp == null || tmp.Count() == 0) && fallback.Count > 0); if (tmp.Count() == 0) { throw new Exception(); } CellTemplate target = tmp.ElementAt(_random.Next(0, tmp.Count())); template.PlaceCore(target.X, target.Y, shipId); placed.Add(new Point(target.X, target.Y)); toPlace--; } mapped.Add(placed); shipId++; } } Board board = new Board(game.RuleSet.BoardSize); for (int i = 0; i < mapped.Count; i++) { var ship = new Ship(mapped[i].Count); foreach (var pt in mapped[i]) { ship.AddCell(new SeaCell((int)pt.X, (int)pt.Y)); } board.AddShip(ship); } //var ship1 = new Ship(5); //ship1.AddCells(new SeaCell[] { new SeaCell(0, 0), new SeaCell(0, 1), new SeaCell(0, 2), new SeaCell(0, 3), new SeaCell(0, 4) }); //board.AddShip(ship1); //var ship2 = new Ship(4); //ship2.AddCells(new SeaCell[] { new SeaCell(2, 0), new SeaCell(2, 1), new SeaCell(2, 2), new SeaCell(2, 3) }); //board.AddShip(ship2); //var ship3 = new Ship(3); //ship3.AddCells(new SeaCell[] { new SeaCell(4, 0), new SeaCell(4, 1), new SeaCell(4, 2) }); //board.AddShip(ship3); //var ship4 = new Ship(2); //ship4.AddCells(new SeaCell[] { new SeaCell(6, 0), new SeaCell(6, 1) }); //board.AddShip(ship4); //var ship5 = new Ship(1); //ship5.AddCells(new SeaCell[] { new SeaCell(8, 0) }); //board.AddShip(ship5); return(board); }