Exemplo n.º 1
0
    public void LoadBoard(List <CellData> cells)
    {
        if (slotList != null)
        {
            for (int i = 0; i < cells.Count; i++)
            {
                if ((cells[i] != null) && (slotList.Count > i))
                {
                    CombatantCell combatCell = SpawnCombatCell(cells[i], slotList[i]);
                    slotList[i].LoadCell(combatCell, combatCell.GetCellData(), false);
                }
            }
        }

        if (health != null)
        {
            int cellCount = slotList.Count;
            health.InitHealth(cellCount);
        }

        BoardEditor be = FindObjectOfType <BoardEditor>();

        if (be != null)
        {
            be.LoadSlots();
        }
    }
Exemplo n.º 2
0
    void InitBoard()
    {
        grid                 = boardRect.GetComponent <GridLayoutGroup>();
        grid.constraint      = GridLayoutGroup.Constraint.FixedColumnCount;
        grid.constraintCount = boardColumnCount;

        boardWidth  = boardRect.sizeDelta.x;
        boardHeight = boardRect.sizeDelta.y;

        int numCells = boardColumnCount * boardRowCount;

        for (int i = 0; i < numCells; i++)
        {
            CellSlot cellSlot = Instantiate(cellSlotPrefab, boardRect);
            slotList.Add(cellSlot);
        }

        BoardEditor be = FindObjectOfType <BoardEditor>();

        if (be != null)
        {
            be.LoadSlots();
        }

        BoardGenerator bg = GetComponent <BoardGenerator>();

        if (bg != null)
        {
            bg.GenerateBoard();
        }
    }
Exemplo n.º 3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            var gamePage = new GamePage
            {
                DataContext = new GamePageViewModel()
            };

            var boardEditor = new BoardEditor
            {
                DataContext = new BoardEditorViewModel(Board.DefaultBoard(Variant.AmericanCheckers))
            };

            var rules = new Rules
            {
                DataContext = new RulesViewModel()
            };

            var board = new MainPage(gamePage, boardEditor, rules);

            MainWindow = new NavigationWindow
            {
                Content           = board,
                ShowsNavigationUI = false
            };

            MainWindow.Show();
        }
Exemplo n.º 4
0
 private void ScriptsMenu()
 {
     _showScriptsMenu = EditorGUILayout.Foldout(_showScriptsMenu, "Script");
     if (_showScriptsMenu)
     {
         _gridEditor  = EditorGUILayout.ObjectField(_gridEditor, typeof(GridEditor), true) as GridEditor;
         _boardEditor = EditorGUILayout.ObjectField(_boardEditor, typeof(BoardEditor), true) as BoardEditor;
         _floorEditor = EditorGUILayout.ObjectField(_floorEditor, typeof(FloorEditor), true) as FloorEditor;
         _tileEditor  = EditorGUILayout.ObjectField(_tileEditor, typeof(TileEditor), true) as TileEditor;
     }
 }
Exemplo n.º 5
0
 void Awake()
 {
     colorBlinker = GetComponent <ColorBlinker>();
     boardEditor  = FindObjectOfType <BoardEditor>();
     cam          = Camera.main;
     button       = GetComponent <Button>();
     slotSprite   = image.sprite;
     slotColor    = image.color;
     ShowHighlight(false);
     board = transform.parent.parent.GetComponent <CombatantBoard>();
     SetInteractible(false);
 }
Exemplo n.º 6
0
 public void OnEnable()
 {
     if (OnGUIActive)
     {
         GameObject editor = GameObject.Find("EditorManager");
         _gridEditor   = editor.GetComponent <GridEditor>();
         _boardEditor  = editor.GetComponent <BoardEditor>();
         _floorEditor  = editor.GetComponent <FloorEditor>();
         _tileEditor   = editor.GetComponent <TileEditor>();
         _defaultPath  = $"{Application.dataPath}/Resources/Text/";
         _savePath     = _defaultPath;
         ScriptsLoaded = true;
     }
 }
Exemplo n.º 7
0
    public override void OnInspectorGUI()
    {
        BoardEditor        boardEditor        = target as BoardEditor;
        BoardTilemap       tilemap            = boardEditor.Tilemap;
        TileContentButtons tileContentButtons = boardEditor.TileContentButtons;

        if (tileContentButtons)
        {
            if (tileContentButtons.Textures == null)
            {
                tileContentButtons.AssignButtonTextures();
            }
            Texture[] buttonTextures = tileContentButtons.Textures;
            GUILayout.BeginVertical("Box");
            int prevTileContentButtonIndex = boardEditor.SelectedTileContentButtonIndex;
            boardEditor.SelectedTileContentButtonIndex = GUILayout.SelectionGrid(boardEditor.SelectedTileContentButtonIndex, buttonTextures, 4);
            if (prevTileContentButtonIndex != boardEditor.SelectedTileContentButtonIndex)
            {
                Debug.Log("You chose " + tileContentButtons.GetTileContentType(boardEditor.SelectedTileContentButtonIndex));
            }
            if (GUILayout.Button("Assign buttons"))
            {
                tileContentButtons.AssignButtonTextures();
            }
            GUILayout.EndVertical();
        }
        Board board = boardEditor.GetComponent <Board>();

        board.LevelIndex        = EditorGUILayout.IntField("Level Index:", board.LevelIndex);
        board.PlayerMovesInTurn = EditorGUILayout.IntField("Player Moves In Turn:", board.PlayerMovesInTurn);
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Save board level"))
        {
            board.SaveLevelToJson();
            AssetDatabase.Refresh();
        }
        if (GUILayout.Button("Load board level"))
        {
            board.LoadLevelFromJson(board.LevelIndex);
        }
        GUILayout.EndHorizontal();
        _defaultInspectorEnabled = GUILayout.Toggle(_defaultInspectorEnabled, "Default Inspector");
        if (_defaultInspectorEnabled)
        {
            DrawDefaultInspector();
        }
    }
Exemplo n.º 8
0
    void Start()
    {
        if (FindObjectOfType <BoardEditor>() != null)
        {
            cellOptionList         = new List <CellOption>();
            optionSort             = GetComponent <LibraryOptionSort>();
            libraryCanvasGroup     = libraryTransform.GetComponent <CanvasGroup>();
            informationCanvasGroup = informationTransform.GetComponent <CanvasGroup>();
            informationPanel       = GetComponentInChildren <InformationPanel>();
            boardEditor            = GetComponent <BoardEditor>();
            EnableInformation(false);

            int numCells = allCells.Length;
            for (int i = 0; i < numCells; i++)
            {
                CellOption cellOption = Instantiate(optionPrefab, libraryTransform);
                if ((allCells.Length > i) && (allCells[i] != null))
                {
                    CellData cellData = allCells[i];
                    cellOption.LoadCell(cellData);
                    cellOptionList.Add(cellOption);
                }
            }

            /// sort options by cell value
            if (optionSort != null)
            {
                List <CellOption> sortedOptionList = new List <CellOption>();
                sortedOptionList = optionSort.GetSortedList(cellOptionList);

                foreach (CellOption co in cellOptionList)
                {
                    co.transform.SetParent(null);
                }

                foreach (CellOption sortedOption in sortedOptionList)
                {
                    sortedOption.transform.SetParent(libraryTransform);
                }

                cellOptionList = sortedOptionList;
            }
        }
    }
Exemplo n.º 9
0
 void Start()
 {
     cellLibrary = transform.root.GetComponent <CellLibrary>();
     boardEditor = FindObjectOfType <BoardEditor>();
 }