Example #1
0
        private void NextCreate()
        {
            Random rand     = new Random();
            CUBE   nextCube = (CUBE)(rand.Next() % 7 + 1);

            NextCreate(nextCube);
        }
Example #2
0
 public CUBEInfo(string name, int id, CUBE.Types type, CUBE.Subsystems subsystem, CUBE.Brands brand, int grade, float health, float shield, float speed, float damage, Vector3 size, int cost, int rarity, int price)
 {
     // General Stats
     this.name = name;
     ID = id;
     this.type = type;
     // System Stats
     this.subsystem = subsystem;
     this.brand = brand;
     this.grade = grade;
     // Combat Stats
     this.health = health;
     this.shield = shield;
     this.speed = speed;
     this.damage = damage;
     // Part Stats
     this.size = size;
     this.cost = cost;
     this.rarity = rarity;
     this.price = price;
 }
Example #3
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        CUBE = (CUBE)target;
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("^"))
        {
            foreach (var i in Selection.gameObjects)
            {
                i.transform.eulerAngles += new Vector3(0, 0, 90);
            }
        }

        if (GUILayout.Button("<"))
        {
            foreach (var i in Selection.gameObjects)
            {
                i.transform.eulerAngles += new Vector3(0, 90, 0);
            }
        }
        GUILayout.EndHorizontal();
    }
Example #4
0
        public void CubeCreate()
        {
            //you need to change not only block but also nowCubePos
            CUBE Cubetype = CUBE.NONE;

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    nowCubePos[i, j] = -1;
                }
            }
            for (int i = 0; i < nextBlockx; i++)
            {
                for (int j = 0; j < nextBlocky; j++)
                {
                    block[i + 18, j + 3].cube       = nextBlock[i, j].cube;
                    block[i + 18, j + 3].cube_state = nextBlock[i, j].cube_state;
                    if (nextBlock[i, j].cube != CUBE.NONE)
                    {
                        Cubetype = nextBlock[i, j].cube;
                    }
                }
            }
            switch (Cubetype)
            {
            case CUBE.T:
                nowCubePos[0, 0] = 19;
                nowCubePos[0, 1] = 4;
                nowCubePos[1, 0] = 20;
                nowCubePos[1, 1] = 4;
                nowCubePos[2, 0] = 18;
                nowCubePos[2, 1] = 4;
                nowCubePos[3, 0] = 19;
                nowCubePos[3, 1] = 5;
                break;

            case CUBE.I:
                nowCubePos[0, 0] = 20;
                nowCubePos[0, 1] = 4;
                nowCubePos[1, 0] = 21;
                nowCubePos[1, 1] = 4;
                nowCubePos[2, 0] = 19;
                nowCubePos[2, 1] = 4;
                nowCubePos[3, 0] = 18;
                nowCubePos[3, 1] = 4;
                break;

            case CUBE.SQUARE:
                nowCubePos[0, 0] = 20;
                nowCubePos[0, 1] = 4;
                nowCubePos[1, 0] = 20;
                nowCubePos[1, 1] = 5;
                nowCubePos[2, 0] = 19;
                nowCubePos[2, 1] = 4;
                nowCubePos[3, 0] = 19;
                nowCubePos[3, 1] = 5;
                break;

            case CUBE.L:
                nowCubePos[0, 0] = 19;
                nowCubePos[0, 1] = 4;
                nowCubePos[1, 0] = 20;
                nowCubePos[1, 1] = 4;
                nowCubePos[2, 0] = 18;
                nowCubePos[2, 1] = 4;
                nowCubePos[3, 0] = 18;
                nowCubePos[3, 1] = 5;
                break;

            case CUBE.L_RE:
                nowCubePos[0, 0] = 19;
                nowCubePos[0, 1] = 5;
                nowCubePos[1, 0] = 20;
                nowCubePos[1, 1] = 5;
                nowCubePos[2, 0] = 18;
                nowCubePos[2, 1] = 5;
                nowCubePos[3, 0] = 18;
                nowCubePos[3, 1] = 4;
                break;

            case CUBE.S:
                nowCubePos[0, 0] = 19;
                nowCubePos[0, 1] = 4;
                nowCubePos[1, 0] = 20;
                nowCubePos[1, 1] = 4;
                nowCubePos[2, 0] = 19;
                nowCubePos[2, 1] = 5;
                nowCubePos[3, 0] = 18;
                nowCubePos[3, 1] = 5;
                break;

            case CUBE.S_RE:
                nowCubePos[0, 0] = 19;
                nowCubePos[0, 1] = 4;
                nowCubePos[1, 0] = 19;
                nowCubePos[1, 1] = 5;
                nowCubePos[2, 0] = 20;
                nowCubePos[2, 1] = 5;
                nowCubePos[3, 0] = 18;
                nowCubePos[3, 1] = 4;
                break;
            }
        }
Example #5
0
        /// <summary>
        /// Remove CUBE from grid and all stats.
        /// </summary>
        /// <param name="cube"></param>
        private void RemoveCUBE(CUBE cube)
        {
            // get pivotOffset and rotation
            cursorRotation = Quaternion.Euler(currentBuild[cube].rotation);
            cursorOffset = currentBuild[cube].position - cursor;
            Vector3 pivot = cursor + cursorOffset.Round();
            pivot = pivot.Round();
            cursorOffset = RotateVector(cursorOffset.Round(), true).Round();

            // remove all of CUBE's pieces
            Vector3 bounds = heldInfo.size;
            for (int x = 0; x < bounds.x; x++)
            {
                for (int y = 0; y < bounds.y; y++)
                {
                    for (int z = 0; z < bounds.z; z++)
                    {
                        Vector3 point = pivot + RotateVector(new Vector3(x, y, z)).Round();
                        point = point.Round();
                        grid[(int)point.y][(int)point.z][(int)point.x] = null;
                        cells[(int)point.y][(int)point.z][(int)point.x].SetActive(true);
                        cells[(int)point.y][(int)point.z][(int)point.x].renderer.material = CellOpen_Mat;
                    }
                }
            }

            // remove weapon if applicable
            if (heldInfo.type == CUBE.Types.Weapon && weapons.Contains(((Weapon)heldCUBE.GetComponent(typeof(Weapon)))))
            {
                int index = currentBuild[heldCUBE].weaponMap;
                if (index < weaponSlots)
                {
                    // replace with extra
                    if (weapons.Count > weaponSlots)
                    {
                        weapons[index] = weapons[weaponSlots];
                        weapons.RemoveAt(weaponSlots);
                    }
                    else
                    {
                        weapons[index] = null;
                    }
                }
                else
                {
                    weapons.RemoveAt(index);
                }
            }

            // remove augmentation if applicable
            if (heldInfo.type == CUBE.Types.Augmentation && augmentations.Contains((Augmentation)heldCUBE.GetComponent(typeof(Augmentation))))
            {
                int index = currentBuild[heldCUBE].augmentationMap;
                if (index < augmentationSlots)
                {
                    // replace with extra
                    if (augmentations.Count > augmentationSlots)
                    {
                        augmentations[index] = augmentations[augmentationSlots];
                        augmentations.RemoveAt(augmentationSlots);
                    }
                    else
                    {
                        augmentations[index] = null;
                    }
                }
                else
                {
                    augmentations.RemoveAt(index);
                }
            }

            // remove CUBE from current build
            currentBuild.Remove(cube);

            // remove stats
            CUBEInfo cubeInfo = CUBE.AllCUBES[cube.ID];
            CurrentStats.health -= cubeInfo.health;
            CurrentStats.shield -= cubeInfo.shield;
            CurrentStats.speed -= cubeInfo.speed;
            CurrentStats.damage -= cubeInfo.damage;
            CorePointsAvailable += cubeInfo.cost;

            cells[(int)cursor.y][(int)cursor.z][(int)cursor.x].renderer.material = CellCursor_Mat;
        }
Example #6
0
 /// <summary>
 /// Pick up a CUBE from the grid.
 /// </summary>
 /// <param name="cube">CUBE to pick up.</param>
 private void PickupCUBE(CUBE cube)
 {
     // grab CUBE
     heldCUBE = cube;
     heldInfo = CUBE.AllCUBES[heldCUBE.ID];
     StartBlink(heldCUBE.renderer);
     // stock inventory
     inventory[heldCUBE.ID]++;
     // remove CUBE from build
     RemoveCUBE(cube);
     // set status
     SetStatus(CursorStatuses.Holding);
 }
Example #7
0
        /// <summary>
        /// Create and initialize grid, cells, ship, and cursor.
        /// </summary>
        /// <param name="size">Size of the grid's dimensions.</param>
        /// <param name="weaponCount">How many weapons allowed.</param>
        /// <param name="augmentationCount">How many augmentations alloed.</param>
        /// <param name="cubeMaterial">Material to apply to new CUBEs.</param>
        public void CreateGrid(int size, int weaponCount, int augmentationCount, Material cubeMaterial = null)
        {
            // cache material
            if (cubeMaterial != null)
            {
                cubeMat = cubeMaterial;
            }
            else if (cubeMat == null)
            {
                cubeMat = Singleton<GameResources>.Main.VertexColorLerp_Mat;
            }

            // clear any previous data
            Clear();
            if (cells != null)
            {
                for (int i = 0; i < size; i++)
                {
                    for (int j = 0; j < size; j++)
                    {
                        for (int k = 0; k < size; k++)
                        {
                            Destroy(cells[i][j][k]);
                        }
                    }
                }
            }

            // get player inventory
            inventory = CUBE.GetInventory();

            // set start cursor rotation
            cursorRotation = new Quaternion(0, 0, 0, 1);

            // initialize
            this.size = size;
            grid = new CUBE[size][][];
            cells = new GameObject[size][][];
            var cursorPosition = new Vector3(-size / 2f + 0.5f, 0f, -size / 2f + 0.5f);

            // create grid and cells
            for (int i = 0; i < size; i++)
            {
                grid[i] = new CUBE[size][];
                cells[i] = new GameObject[size][];
                cursorPosition.z = -size / 2f + 0.5f;

                for (int j = 0; j < size; j++)
                {
                    grid[i][j] = new CUBE[size];
                    cells[i][j] = new GameObject[size];
                    cursorPosition.x = -size / 2f + 0.5f;

                    for (int k = 0; k < size; k++)
                    {
                        cells[i][j][k] = (GameObject)Instantiate(Cell_Prefab);
                        cells[i][j][k].transform.parent = transform;
                        cells[i][j][k].transform.localPosition = cursorPosition;
                        cursorPosition.x++;
                    }
                    cursorPosition.z++;
                }
                cursorPosition.y++;
            }

            // set current layer and cursor
            cursor = StartCursorPosition;

            // create ship
            if (ship == null)
            {
                ship = new GameObject("Ship");
            }
            ship.transform.position = transform.position + Vector3.up * (size / 2f - 0.5f);
            CurrentStats = new ShipStats();

            // build points
            CorePointsMax = BuildStats.GetCoreCapacity();
            CorePointsAvailable = CorePointsMax;

            // set up weapons
            weaponSlots = weaponCount;
            weapons = new List<Weapon>();

            // set up augmentations
            augmentationSlots = augmentationCount;
            augmentations = new List<Augmentation>();

            // create grid center
            Center = ((GameObject)Instantiate(Center_Prefab, ship.transform.position, Quaternion.identity)).transform;
        }