コード例 #1
0
        public _Panel(bool dark)
        {
            Background = new Rectangle
            {
                Fill = dark ? "#343a40" : "#FFFFFF"
            };

            var color = dark ? "#464950" : "#cccccc";

            Grid = new _Grid
            {
                Major = new _Grid._GridXY
                {
                    X = new Line
                    {
                        Width    = 0.43,
                        Fill     = color,
                        Alpha    = 1.0,
                        LineType = Solid
                    },
                    Y = new Line
                    {
                        Width    = 0.43,
                        Fill     = color,
                        Alpha    = 1.0,
                        LineType = Solid
                    }
                },
                Minor = new _Grid._GridXY
                {
                    X = new Line
                    {
                        Width    = 0.32,
                        Fill     = color,
                        Alpha    = 1.0,
                        LineType = Solid
                    },
                    Y = new Line
                    {
                        Width    = 0.32,
                        Fill     = color,
                        Alpha    = 1.0,
                        LineType = Solid
                    }
                },
            };

            Spacing = new _Spacing
            {
                X = 8,
                Y = 8
            };
        }
コード例 #2
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        _Grid grid = (_Grid)target;

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Redraw Grid"))
        {
            grid.RefreshGrid();
        }
        if (GUILayout.Button("Clear Level"))
        {
            grid.ResetIndexGrid();
        }
        EditorGUILayout.EndHorizontal();
    }
コード例 #3
0
ファイル: Panel.cs プロジェクト: zyhong/GGNet
        public _Panel(bool dark)
        {
            var color = dark ? "#464950" : "#cccccc";

            Grid = new _Grid
            {
                Major = new _Grid._GridXY
                {
                    X = new Line
                    {
                        Width = 0.43,
                        Color = color
                    },
                    Y = new Line
                    {
                        Width = 0.43,
                        Color = color
                    }
                },
                Minor = new _Grid._GridXY
                {
                    X = new Line
                    {
                        Width = 0.32,
                        Color = color
                    },
                    Y = new Line
                    {
                        Width = 0.32,
                        Color = color
                    }
                },
            };

            Spacing = new _Spacing
            {
                X = 8,
                Y = 8
            };
        }
コード例 #4
0
        public void ExtractAndRebuildLevel(LevelEditorData recoveredData)
        {
            finishedBuilding = false;

            grid = _Grid.instance;

            // start by resetting the grid's nodes to their base states
            grid.ResetIndexGrid();

            foreach (Node recoveredNode in recoveredData.nodesToSave)
            {
                // EXTREMELY IMPORTANT -> CONVERTS THE CUBE'S TYPE FROM STRING TO ENUM
                recoveredNode.cubeType = Node.ConvertStringToCubeType(recoveredNode.savedCubeType);

                //Set the universe textures
                _MaterialCentral.instance.ChangeUniverse(recoveredData.biome);

                currentNode = recoveredNode;

                GameObject newCube = Instantiate(cubePrefab);

                _Grid.instance.placedObjects.Add(newCube);

                // get the kuboGrid and set the information on each of the nodes
                SetNodeInfo(newCube, recoveredNode.nodeIndex, recoveredNode.worldPosition, recoveredNode.worldRotation, recoveredNode.facingDirection, recoveredNode.cubeLayers, recoveredNode.cubeType);

                // check the node's cube type and setup the relevant cube and its transform + individual information
                switch (recoveredNode.cubeType)
                {
                case CubeTypes.FullStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube fullStaticCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(fullStaticCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.FullStaticCube, true);
                    break;

                case CubeTypes.EmptyStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube emptyCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(emptyCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.EmptyStaticCube, true);
                    break;

                case CubeTypes.TopStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube topStaticCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(topStaticCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.TopStaticCube, true);
                    break;

                case CubeTypes.CornerStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube cornerStaticCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(cornerStaticCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.CornerStaticCube, true);
                    break;

                case CubeTypes.TripleStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube tripleStaticCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(tripleStaticCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.TripleStaticCube, true);
                    break;

                case CubeTypes.QuadStaticCube:
                    newCube.AddComponent(typeof(StaticCube));
                    StaticCube quadStaticCube = newCube.GetComponent <StaticCube>();
                    SetCubeInfo(quadStaticCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.QuadStaticCube, true);
                    break;

                case CubeTypes.MoveableCube:
                    newCube.AddComponent(typeof(MoveableCube));
                    MoveableCube moveableCube = newCube.GetComponent <MoveableCube>();
                    SetCubeInfo(moveableCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.MoveableCube, false);
                    break;

                case CubeTypes.BaseVictoryCube:
                    newCube.AddComponent(typeof(BaseVictoryCube));
                    BaseVictoryCube baseVictoryCube = newCube.GetComponent <BaseVictoryCube>();
                    SetCubeInfo(baseVictoryCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.BaseVictoryCube, false);
                    break;

                case CubeTypes.ConcreteVictoryCube:
                    newCube.AddComponent(typeof(ConcreteVictoryCube));
                    ConcreteVictoryCube concreteVictoryCube = newCube.GetComponent <ConcreteVictoryCube>();
                    SetCubeInfo(concreteVictoryCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.ConcreteVictoryCube, false);
                    break;

                case CubeTypes.BombVictoryCube:
                    newCube.AddComponent(typeof(BombVictoryCube));
                    BombVictoryCube bombVictoryCube = newCube.GetComponent <BombVictoryCube>();
                    SetCubeInfo(bombVictoryCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.BombVictoryCube, false);
                    break;

                case CubeTypes.SwitchVictoryCube:
                    newCube.AddComponent(typeof(SwitchVictoryCube));
                    SwitchVictoryCube switchVictoryCube = newCube.GetComponent <SwitchVictoryCube>();
                    SetCubeInfo(switchVictoryCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.SwitchVictoryCube, true);
                    break;

                case CubeTypes.DeliveryCube:
                    newCube.AddComponent(typeof(DeliveryCube));
                    DeliveryCube deliveryCube = newCube.GetComponent <DeliveryCube>();
                    SetCubeInfo(deliveryCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.DeliveryCube, true);
                    break;

                case CubeTypes.BlueElevatorCube:
                    newCube.AddComponent(typeof(ElevatorCube));
                    ElevatorCube blueElevatorCube = newCube.GetComponent <ElevatorCube>();
                    blueElevatorCube.isGreen = false;
                    SetCubeInfo(blueElevatorCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.BlueElevatorCube, false);
                    break;

                case CubeTypes.GreenElevatorCube:
                    newCube.AddComponent(typeof(ElevatorCube));
                    ElevatorCube greenElevatorCube = newCube.GetComponent <ElevatorCube>();
                    greenElevatorCube.isGreen = true;
                    SetCubeInfo(greenElevatorCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.GreenElevatorCube, false);
                    break;

                case CubeTypes.ConcreteCube:
                    newCube.AddComponent(typeof(ConcreteCube));
                    ConcreteCube concreteCube = newCube.GetComponent <ConcreteCube>();
                    SetCubeInfo(concreteCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.ConcreteCube, false);
                    break;

                case CubeTypes.BombCube:
                    newCube.AddComponent(typeof(BombCube));
                    BombCube bombCube = newCube.GetComponent <BombCube>();
                    SetCubeInfo(bombCube as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.BombCube, false);
                    break;

                case CubeTypes.TimerCube:
                    newCube.AddComponent(typeof(TimerCube));
                    TimerCube timerCube = newCube.GetComponent <TimerCube>();
                    SetCubeInfo(timerCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.TimerCube, true);
                    break;

                case CubeTypes.SwitchButton:
                    newCube.AddComponent(typeof(SwitchButton));
                    SwitchButton switchButton = newCube.GetComponent <SwitchButton>();
                    SetCubeInfo(switchButton as _CubeBase, CubeLayers.cubeFull, CubeTypes.SwitchButton, true);
                    break;

                case CubeTypes.SwitchCube:
                    newCube.AddComponent(typeof(SwitchCube));
                    SwitchCube switchCube = newCube.GetComponent <SwitchCube>();
                    SetCubeInfo(switchCube as _CubeBase, CubeLayers.cubeFull, CubeTypes.SwitchCube, true);
                    break;

                case CubeTypes.RotatorRightTurner:
                    newCube.AddComponent(typeof(RotateRightCube));
                    RotateRightCube rotatorRightTurn = newCube.GetComponent <RotateRightCube>();
                    SetCubeInfo(rotatorRightTurn as _CubeBase, CubeLayers.cubeFull, CubeTypes.RotatorRightTurner, true);
                    break;

                case CubeTypes.RotatorLeftTurner:
                    newCube.AddComponent(typeof(RotateLeftCube));
                    RotateLeftCube rotatorLeftTurn = newCube.GetComponent <RotateLeftCube>();
                    SetCubeInfo(rotatorLeftTurn as _CubeBase, CubeLayers.cubeFull, CubeTypes.RotatorLeftTurner, true);
                    break;

                case CubeTypes.RotatorLocker:
                    newCube.AddComponent(typeof(RotatorLocker));
                    RotatorLocker rotatorLocker = newCube.GetComponent <RotatorLocker>();
                    SetCubeInfo(rotatorLocker as _CubeBase, CubeLayers.cubeFull, CubeTypes.RotatorLocker, true);
                    break;

                case CubeTypes.ChaosBall:
                    newCube.AddComponent(typeof(ChaosBall));
                    ChaosBall chaosBall = newCube.GetComponent <ChaosBall>();
                    SetCubeInfo(chaosBall as _CubeBase, CubeLayers.cubeMoveable, CubeTypes.ChaosBall, false);
                    break;

                default:
                    //set epmty cubes as cubeEmpty
                    grid.kuboGrid[recoveredNode.nodeIndex - 1].cubeLayers = CubeLayers.cubeEmpty;
                    grid.kuboGrid[recoveredNode.nodeIndex - 1].cubeType   = CubeTypes.None;
                    break;
                }
            }

            finishedBuilding = true;
        }