예제 #1
0
    public override void OnInspectorGUI()
    {
        GUIStyle style     = new GUIStyle();
        bool     showClose = true;

        base.OnInspectorGUI();
        //test = false;
        ScriptableObjectGridStructure origin = (ScriptableObjectGridStructure)target;
        BattleTileInfo bti;
        GridTileInfo   gti = null;

        if (origin.GridInfo.Count > 0)
        {
            EditorGUILayout.Space();
            for (int x = 0; x < 6; x++)
            {
                EditorGUILayout.BeginHorizontal();
                for (int y = 0; y < 12; y++)
                {
                    //Debug.Log(x + "   " + y);
                    bti      = origin.GridInfo.Where(r => r.Pos == new Vector2Int(x, y)).First();
                    bti.name = x + "," + y;
                    if (firstOpen)
                    {
                        gti = new GridTileInfo(new Vector2Int(x, y), bti);
                        TilesInfo.Add(gti, bti.BattleTileState == BattleTileStateType.Empty ? true : false);
                    }
                    else
                    {
                        gti = TilesInfo.Where(r => r.Key.Pos == new Vector2Int(x, y)).First().Key;
                    }

                    showClose = EditorGUILayout.ToggleLeft(x + "," + y, TilesInfo.Where(r => r.Key.Pos == new Vector2Int(x, y)).First().Value, GUILayout.Width(40));
                    if (showClose != TilesInfo[gti])
                    {
                        if (showClose)
                        {
                            differentGti = gti;
                        }
                        else
                        {
                            differentGti = null;
                        }
                    }
                    TilesInfo[gti]      = showClose;
                    bti.BattleTileState = showClose ? BattleTileStateType.Empty : BattleTileStateType.Blocked;
                    //Debug.Log(showClose);
                }
                EditorGUILayout.EndHorizontal();
            }

            if (differentGti != null)
            {
                ShowTileObject(ref differentGti.Tile);
            }
            firstOpen = false;
        }

        EditorUtility.SetDirty(origin);
    }
예제 #2
0
 //Setting up the camera position and new grid stuff
 public void ChangeGridStructure(ScriptableObjectGridStructure gridStructure, int stageIndex, bool moveCameraInternally, float cameraChangeDuration = 0f)
 {
     GridManagerScript.Instance.ResetGrid();
     isChangeGridStructure = false;
     CameraManagerScript.Instance.ChangeFocusToNewGrid(CameraStage.CameraInfo.Where(r => r.StageIndex == (stageIndex != -1 ? stageIndex : currentGridIndex)).First(), cameraChangeDuration, moveCameraInternally);
     GridManagerScript.Instance.SetupGrid(gridStructure);
 }
예제 #3
0
    //Setup each single tiles of the grid
    public void SetupGrid(ScriptableObjectGridStructure gridStructure)
    {
        if (currentGridStructureObject != gridStructure)
        {
            foreach (BattleTileInfo tile in gridStructure.GridInfo)
            {
                //Debug.Log(tile.Pos + "   " + tile.BattleTileState.ToString());
                BattleTiles.Where(r => r.Pos == tile.Pos).First().SetupTileFromBattleTileInfo(tile);
            }
            YGridSeparator = gridStructure.YGridSeparator;

            currentGridStructureObject = gridStructure;

            InitializationCompleteEvent?.Invoke();
        }
    }