コード例 #1
0
    public void RemoveOldestPiece()
    {
        LevelPiece oldestPiece = pieces[0];

        pieces.Remove(oldestPiece);
        Destroy(oldestPiece.gameObject);
    }
コード例 #2
0
ファイル: StoreLevel.cs プロジェクト: Scoutzknifez/RampServer
    private void Start()
    {
        if (fallbackLevelMaterial == null)
        {
            Debug.LogError("Fallback Level Material CAN NOT BE NULL!");
            return;
        }

        foreach (Transform child in transform)
        {
            GameObject     go       = child.gameObject;
            ProBuilderMesh mainMesh = go.GetComponent <ProBuilderMesh>();

            ArrayPacker[] faces = new ArrayPacker[mainMesh.faces.Count];
            for (int i = 0; i < faces.Length; i++)
            {
                int[] faceVerts = new int[mainMesh.faces[i].indexes.Count];
                mainMesh.faces[i].indexes.CopyTo(faceVerts, 0);

                faces[i] = new ArrayPacker(faceVerts);
            }

            Vector3[] vertices = new Vector3[mainMesh.positions.Count];
            for (int i = 0; i < mainMesh.positions.Count; i++)
            {
                vertices[i] = mainMesh.positions[i];
            }

            ArrayPacker[] sharedVertices = new ArrayPacker[mainMesh.sharedVertices.Count];
            for (int i = 0; i < mainMesh.sharedVertices.Count; i++)
            {
                int[] sharedVertex = new int[mainMesh.sharedVertices[i].Count];
                mainMesh.sharedVertices[i].CopyTo(sharedVertex, 0);

                sharedVertices[i] = new ArrayPacker(sharedVertex);
            }

            LevelPiece piece = new LevelPiece(go.transform.position, go.transform.rotation, vertices, faces, sharedVertices);

            Renderer        renderer = go.GetComponent <Renderer>();
            MaterialMapping mapping  = MaterialMapping.GetMaterialMappingFromMaterial(levelMaterials, renderer.sharedMaterial);

            if (mapping != null)
            {
                piece.materialName = mapping.materialName;
            }
            else
            {
                piece.materialName = Constants.ERROR_NO_MATERIAL;
            }

            levelPieces.Add(piece);
        }

        // Was for testing to see duplicated data
        if (isTesting)
        {
            StartCoroutine(spawnBack());
        }
    }
コード例 #3
0
ファイル: LevelGenerator.cs プロジェクト: xacap/CubeSurfer
    public void AddPiece()
    {
        LevelPiece piece = new LevelPiece();

        piece = (LevelPiece)Instantiate(levelPrefabs[pieceCount]);
        piece.transform.SetParent(this.transform, false);

        Vector3 spawnPosition = Vector3.zero;
        Vector3 offset        = new Vector3(0, 0, 12);

        if (pieces.Count == 0)
        {
            spawnPosition = levelStartPoint.position;
        }
        else
        {
            spawnPosition = pieces[pieces.Count - 1].exitPoint.position + offset;
        }

        piece.transform.position = spawnPosition;

        pieces.Add(piece);
        pieceCount++;

        if (pieceCount >= 4)
        {
            pieceCount = 0;
        }
    }
コード例 #4
0
    public void AddPiece()
    {
        //pick the random number
        int randomIndex = Random.Range(0, levelPrefabs.Count);

        //Instantiate copy of random level prefab and store it in piece variable
        LevelPiece piece = (LevelPiece)Instantiate(levelPrefabs[randomIndex]);

        piece.transform.SetParent(this.transform, false);

        Vector3 spawnPosition = Vector3.zero;

        //position
        if (pieces.Count == 0)
        {
            //first piece
            spawnPosition = levelStartPoint.position;
        }
        else
        {
            //take exit point from last piece as a spawn point to new piece
            spawnPosition = pieces[pieces.Count - 1].exitPoint.position;
        }

        piece.transform.position = spawnPosition;
        pieces.Add(piece);
    }
コード例 #5
0
ファイル: PiecesEditor.cs プロジェクト: Demy/CosmoCats
        public void AddNew()
        {
            LevelPiece newPiece = new LevelPiece("Piece" + (pieces.Count + 1));

            pieces.Add(newPiece);
            UpdateView();
        }
コード例 #6
0
    private void spawnPrefab(LevelPiece type, int x, int y)
    {
        GameObject prefab = getPrefab(type);

        if (prefab == null) {
            return;
        }

        GameObject piece = (GameObject) Instantiate(
            prefab,
            LevelPositioner.PositionPiece(x, y),
            Quaternion.identity
        );

        setParent(piece);

        if (type == LevelPiece.Ground) {
            LevelController.Instance.GroundHeight = piece.transform.position.y;
        } else if (type == LevelPiece.Collectible) {
            Debug.Log("Setting this phrase to something");
            Phrase phraseController = piece.GetComponent<Phrase>();
            phraseController.Initialize();
            int index = phraseController.GetIndex();
            phraseController.SetPhrase(PhraseController.Instance.GetPhrase(index));
        }
    }
コード例 #7
0
ファイル: LevelInspector.cs プロジェクト: YSpadin/RunAndJump
 private void UpdateCurrentPieceInstance(PaletteItem item, Texture2D preview)
 {
     _itemSelected  = item;
     _itemPreview   = preview;
     _pieceSelected = (LevelPiece)item.GetComponent <LevelPiece>();
     Repaint();
 }
コード例 #8
0
    public void AddPiece()
    {
        //pick the random number
        int randomIndex = Random.Range(0, levelPrefabs.Count);
        //Instantiate copy of random level prefab and store it in piece variable
        LevelPiece piece = (LevelPiece)Instantiate(levelPrefabs[randomIndex]);

        piece.transform.SetParent(this.transform, false);

        Vector3 spawnPosition = Vector3.zero;

        /*
         * //Generate Coins
         * //get all collectables in piece and put into an array
         * Collectable[] c = piece.GetComponentsInChildren<Collectable>();
         *
         * //Hides all coins
         * foreach (var cx in c) {
         *      cx.Hide();
         * }
         * //shows some coins. Freq controls frequency of coins.
         * foreach (var cx in c) {
         *      float freq = 0.65f;
         *      bool boolean  = (Random.value > freq);
         *      if(boolean)
         *              cx.Show();
         * }*/

        if (pieces.Count == 0)
        {
            //first piece
            spawnPosition = levelStartPoint.position;
        }
        else
        {
            //take exit point from last piece as a spawn point to new piece
            spawnPosition = pieces[pieces.Count - 1].exitPoint.position;
        }

        piece.transform.position = spawnPosition;

        /*
         * int coins = GameManager.instance.collectedCoins;
         *
         * if (coins >= 10) {
         *      Debug.Log ("LEVEL OFFICIALLY OVER.");
         *      //Call UI here
         *
         *      PlayerController.instance.animator.SetBool("isAlive", false);
         *
         *      //If a killtrigger exists, turn it off.
         *      if(piece.GetComponentInChildren<KillTrigger>())
         *              piece.GetComponentInChildren<KillTrigger>().turnOffTrigger();
         *
         *      GameManager.instance.newLevel();
         *      Time.timeScale = 0.0f;
         * }
         */
        pieces.Add(piece);
    }
コード例 #9
0
    public void AddPiece()
    {
        // Picks a random number for the level piece prefab array
        int randomIndex = Random.Range(0, levelPrefabs.Count);

        // Instantiate a random copy of a level prefab and stores it in piece variable
        LevelPiece piece = (LevelPiece)Instantiate(levelPrefabs[randomIndex]);

        piece.transform.SetParent(this.transform, false);

        Vector3 spawnPosition = Vector3.zero;

        if (pieces.Count == 0)
        {
            spawnPosition = levelStartPoint.position;
        }
        else
        {
            // Takes exit point from last piece as a spawn point for the new piece
            spawnPosition = pieces[pieces.Count - 1].exitPoint.position;
        }

        piece.transform.position = spawnPosition;
        pieces.Add(piece);
    }
コード例 #10
0
        private void ResizeLevel()
        {
            LevelPiece[] newPieces = new LevelPiece[_newTotalColumns * _newTotalRows]; for (int col = 0; col < _level.TotalColumns; ++col)
            {
                for (int row = 0; row < _level.TotalRows; ++row)
                {
                    if (col < _newTotalColumns && row < _newTotalRows)
                    {
                        newPieces[col + row * _newTotalColumns] = _level.Pieces[col + row * _level.TotalColumns];
                    }
                    else
                    {
                        LevelPiece piece = _level.Pieces[col + row * _level.TotalColumns];

                        if (piece != null)
                        {
                            DestroyImmediate(piece.gameObject);
                        }
                    }
                }
            }

            _level.Pieces       = newPieces;
            _level.TotalColumns = _newTotalColumns;
            _level.TotalRows    = _newTotalRows;
        }
コード例 #11
0
        //allows prefab moving in level designer.
        //only works in edit mode
        public void Move()
        {
            Vector3 gridPoint = targetLevel.WorldToGridCoordinates(paletteItemInspected.transform.position);
            int     col       = (int)gridPoint.x;
            int     row       = (int)gridPoint.y;

            //at same positon do nothing
            if (col == originalPosX && row == originalPosY)
            {
                return;
            }
            //continue;
            int        index      = renderedLevelGrid[col][row];
            LevelPiece validPiece = index > -1 ? prefabList [index] : null;

            //if in point or a valid prefab.
            if (!targetLevel.IsInsideGridBounds(col, row) || validPiece != null)
            {
                //return to original location
                paletteItemInspected.transform.position = targetLevel.GridToWorldCoordinates(originalPosX, originalPosY);
            }
            else
            {
                //move the prefab
                paletteItemInspected.transform.position = targetLevel.GridToWorldCoordinates(originalPosX, originalPosY);
                //update the jaggedArray
                renderedLevelGrid [originalPosX] [originalPosY] = -1;
                renderedLevelGrid [col] [row]           = index;
                paletteItemInspected.transform.position = targetLevel.GridToWorldCoordinates(col, row);
            }
        }
コード例 #12
0
    public void AddPiece()
    {
        // 난수를 선택한다.
        int randomIndex = Random.Range(0, levelPrefabs.Count);

        // levelPrefabs에서 임의의 레벨 조각의 복사본을 인스턴스화해서
        // piece 변수에 저장한다
        LevelPiece piece = (LevelPiece)Instantiate(levelPrefabs [randomIndex]);

        piece.transform.SetParent(this.transform, false);

        Vector3 spawnPosition = Vector3.zero;

        if (pieces.Count == 0)
        {
            spawnPosition = levelStartPoint.position;
        }
        else
        {
            spawnPosition = pieces[pieces.Count - 1].exitPoint.position;
        }

        piece.transform.position = spawnPosition;
        pieces.Add(piece);
    }
コード例 #13
0
ファイル: LevelGenerator.cs プロジェクト: marcinwal/Game1
    public void AddPiece()
    {
        int randomIndex = Random.Range(0, levelPrefabs.Count);

        Debug.Log("randomIndex:" + randomIndex);
        Debug.Log("levelPrefabs:" + levelPrefabs.Count);
        float myRandom = Random.value;
//        Debug.Log(myRandom);
//        if(myRandom > holeProbability)
//        {
//            return;
//        }
        // Instantiate -> making a copy od an object
        LevelPiece piece = (LevelPiece)Instantiate(levelPrefabs[randomIndex]);

        piece.transform.SetParent(this.transform, false);

        Vector3 spawnPosition = Vector3.zero;

        if (pieces.Count == 0)
        {
            spawnPosition = levelStartPoint.position;
        }
        else
        {
            spawnPosition = pieces[pieces.Count - 1].exitPoint.position;
        }

        piece.transform.position = spawnPosition;
        pieces.Add(piece);
    }
コード例 #14
0
 private void ResizeLevel()
 {
     LevelPiece[] newPieces = new LevelPiece[_newTotalColumns * _newTotalRows];
     for (int col = 0; col < _myTarget.TotalColumns; ++col)
     {
         for (int row = 0; row < _myTarget.TotalRows; ++row)
         {
             if (col < _newTotalColumns && row < _newTotalRows)
             {
                 newPieces[col + row * _newTotalColumns] = _myTarget.Pieces[col + row * _myTarget.TotalColumns];
             }
             else
             {
                 LevelPiece piece = _myTarget.Pieces[col + row * _myTarget.TotalColumns];
                 if (piece != null)
                 {
                     // we must to use DestroyImmediate in a Editor context
                     Object.DestroyImmediate(piece.gameObject);
                 }
             }
         }
     }
     _myTarget.Pieces       = newPieces;
     _myTarget.TotalColumns = _newTotalColumns;
     _myTarget.TotalRows    = _newTotalRows;
 }
コード例 #15
0
ファイル: ServerSend.cs プロジェクト: Scoutzknifez/RampServer
    public static void SpawnLevelPiece(int toClient, LevelPiece levelPiece)
    {
        using (Packet packet = new Packet((int)ServerPackets.levelPieceSpawned))
        {
            packet.Write(levelPiece.position);
            packet.Write(levelPiece.rotation);

            // Write the amount of vectors, then the vertices
            packet.Write(levelPiece.vertices.Length);
            foreach (Vector3 vector in levelPiece.vertices)
            {
                packet.Write(vector);
            }

            packet.Write(levelPiece.faces.Length);
            foreach (ArrayPacker packer in levelPiece.faces)
            {
                packet.Write(packer);
            }

            packet.Write(levelPiece.sharedVertices.Length);
            foreach (ArrayPacker packer in levelPiece.sharedVertices)
            {
                packet.Write(packer);
            }

            packet.Write(levelPiece.materialName);

            SendTCPData(toClient, packet);
        }
    }
コード例 #16
0
 private void LevelPieceOnHidden(LevelPiece levelPiece)
 {
     if (this.levelPiece == levelPiece)
     {
         //TODO: Return it to pool instead of destruction
         Destroy(gameObject);
     }
 }
コード例 #17
0
    public override bool Equals(DesignElement other)
    {
        LevelPiece otherLP = (LevelPiece)other;

        return( //position == otherLP.position
            rotation == otherLP.rotation &&
            type == otherLP.type);
    }
コード例 #18
0
        private void LevelPieceOnHidden(LevelPiece levelPiece)
        {
            if (this.levelPiece != levelPiece)
            {
                return;
            }

            bonusesController.ReturnToPool(this);
        }
コード例 #19
0
ファイル: LevelPieceManager.cs プロジェクト: aytona/GAME2011
	// Check if LevelPiece
	// is already used.
	private bool isActivePiece(LevelPiece Piece)
	{
		for (int i = 0; i < ActiveLevelPieces.Length; i++)
		{
			if (Piece == ActiveLevelPieces[ i ])
			{
				return true;
			}
		}
		return false;
	}
コード例 #20
0
ファイル: LevelPieceManager.cs プロジェクト: aytona/GAME2011
	private LevelPiece FindOtherLevelPiece(LevelPiece CurrentLevelPiece)
	{
		for (int i = 0; i < ActiveLevelPieces.Length; i++)
		{
			if (ActiveLevelPieces[ i ] != CurrentLevelPiece)
			{
				return ActiveLevelPieces[ i ];
			}
		}
		return null;
	}
コード例 #21
0
 private bool IsActivePiece(LevelPiece piece)
 {
     for (int i = 0; i < activeLevelPieces.Length; i++)
     {
         if (piece == activeLevelPieces [i])
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #22
0
 // get the other LevelPiece from the levelPieces array
 private LevelPiece FindOtherLevelPiece(LevelPiece currentLevelPiece)
 {
     for (int i = 0; i < activeLevelPieces.Length; i++)
     {
         if (activeLevelPieces [i] != currentLevelPiece)
         {
             return(activeLevelPieces [i]);
         }
     }
     return(null);
 }
コード例 #23
0
    public void PlaceAnoterPiece(string name, bool forward)
    {
        bool continuePlacement = !false;
        int  temp = 0;


        if (pieces.Count > 1)
        {
            if (pieces.ContainsKey(name))
            {
                pieces[name].Conected(forward);

                while (continuePlacement)
                {
                    temp = Random.Range(0, pieces.Count);

                    upcoming = pieces[pieces.Keys.ElementAt(temp)];

                    if (upcoming != pieces[name])
                    {
                        continuePlacement = !true;
                    }
                    else
                    {
                        continuePlacement = !false;
                    }
                }



                if (forward)
                {
                    pieces[name].Conected(forward);
                    upcoming.Conected(!forward);
                    upcoming.PlacePiece(pieces[name].outPoint.position, forward);
                }
                else
                {
                    pieces[name].Conected(!forward);
                    upcoming.Conected(forward);
                    upcoming.PlacePiece(pieces[name].inPoint.position, forward);
                }
            }
            else
            {
                Debug.LogWarning("Attempting to place a unregistered level piece");
            }
        }
        else
        {
            Debug.LogWarning("Not enough level pieces!!!");
        }
    }
コード例 #24
0
        //array to store all prefabs in the level.
        public LevelPiece setLevelPiece(int col = -1, int row = -1, LevelPiece value = null)
        {
            //do not process
            if (col == -1 || row == -1 || value == null)
            {
                return(null);
            }
            levelPieces.Add(value);
            //store index
            int index = levelPieces.IndexOf(value);

            LevelPieceGridPositions [col] [row] = index;
            return(levelPieces[index]);
        }
コード例 #25
0
        private void LevelPieceOnEntered(LevelPiece levelPiece)
        {
            var moveBackValue = player.transform.position.x;

            if (moveBackValue < _maxX)
            {
                return;
            }

            gameplayController.level.MovePiecesBack(moveBackValue);
            player.CheckDistance();
            player.transform.position -= new Vector3(moveBackValue, 0, 0);
            player.ResetAfterRollback();
        }
コード例 #26
0
    public static LevelPiece[,] ParseLevel(string [][] levelAsStrings)
    {
        int height = Util.MatrixHeight(levelAsStrings);

        LevelPiece [,] level = new LevelPiece[levelAsStrings.Length,height];

        for (int x = 0; x < levelAsStrings.Length; x++) {
            for (int y = 0; y < height; y++) {

                level[x,y] = ParsePiece(levelAsStrings[x][y]);
            }
        }

        return level;
    }
コード例 #27
0
    // get random LevelPiece from levelPieces array
    private LevelPiece GetRandomLevelPiece()
    {
        LevelPiece returnPiece = null;

        while (returnPiece == null)
        {
            int randomIndex = Mathf.RoundToInt(Random.Range(0, levelPieces.Length));

            if (!IsActivePiece(levelPieces[randomIndex]))
            {
                returnPiece = levelPieces [randomIndex];
                Debug.Log("Level Piece " + randomIndex);
            }
        }
        return(returnPiece);
    }
コード例 #28
0
    public void ReloadLevelPiecesList()
    {
        levelPiecesDict = new Dictionary <string, GameObject>();
        string[] assetsPaths = AssetDatabase.FindAssets("t:GameObject");

        for (int assetIdx = 0; assetIdx < assetsPaths.Length; ++assetIdx)
        {
            GameObject newObject  = AssetDatabase.LoadAssetAtPath <GameObject>(AssetDatabase.GUIDToAssetPath(assetsPaths[assetIdx]));
            LevelPiece levelPiece = newObject.GetComponentInChildren <LevelPiece>();
            if (levelPiece != null)
            {
                levelPiecesList.Add(newObject);
                levelPiecesDict.Add(levelPiece.GetPieceName(), newObject);
            }
        }
    }
コード例 #29
0
 private GameObject getPrefab(LevelPiece type)
 {
     switch (type) {
     case LevelPiece.Collectible:
         return CollectiblePrefab;
     case LevelPiece.Player:
         return PlayerPrefab;
     case LevelPiece.Finish:
         return FinishPrefab;
     case LevelPiece.Ground:
         return GroundPrefab;
     case LevelPiece.Platform:
         return PlatformPrefab;
     default:
         return null;
     }
 }
コード例 #30
0
        private void LevelPieceOnPlaced(LevelPiece levelPiece)
        {
            if (!levelPiece.bonusPoint.IsAssigned())
            {
                return;
            }

            var chance = Random.Range(0f, 1f);

            if (chance > settings.bonusChance)
            {
                return;
            }

            var bonusPickable = GetPickableFromPool(bonusesDBEntries.RandomItem());

            bonusPickable.AttackToLevelPiece(levelPiece);
        }
コード例 #31
0
 ///<summary>
 ///For the given column erase the rows
 ///</summary>
 public void unsetRowsForColumn(int colIndex = -1)
 {
     //TODO removeAt from list, and remove from LevelPieceGridPositions
     if (colIndex != -1)
     {
         for (int r = 0; r < TotalRows; r++)
         {
             int        index = LevelPieceGridPositions [colIndex] [r];
             LevelPiece piece = levelPieces[index];
             if (piece)
             {
                 UnityEngine.Object.DestroyImmediate(piece.gameObject);
                 levelPieces[index] = null;
                 LevelPieceGridPositions [colIndex] [r] = -1;
             }
         }
     }
 }
コード例 #32
0
    void MutateLevelPiece(LevelPiece levelPiece, int i)
    {
        // Select random room type
        int roomType = Random.Range(0, 16);

        // Keep changing piece until it's different
        while ((LevelPiece.Type)roomType == levelPiece.type)
        {
            roomType = Random.Range(0, 16);
        }
        // No traps allowed on start and end of level
        if (i == 0 || i == genomeLength - 1)
        {
            roomType = Random.Range(0, 8);
        }

        levelPiece.type = (LevelPiece.Type)roomType;
    }
コード例 #33
0
        public void Load(LevelPiece level)
        {
            FillGrid(COLS, ROWS);
            data = level;
            List <LevelPiece.Item> items = level.GetItems();
            int size = items.Count;

            LevelPiece.Item item;
            Button          cell;

            for (int i = 0; i < size; i++)
            {
                item = items[i];
                cell = grid.GetChild(item.x + item.y * COLS).GetComponent <Button>();
                AddItemToCell(cell.transform, item.type, item.rotation);
            }
            currentCell = grid.GetChild(0);
        }
コード例 #34
0
    // Update is called once per frame
    void Update()
    {
        // loops through both active level pieces to move them together
        for (int i = 0; i < activeLevelPieces.Length; i++)
        {
            // adjust piece x location according to the move rate

            // get piece current location
            Vector3 newLocation = activeLevelPieces [i].transform.position;
            // update location based on time elapsed since last frame
            newLocation.x -= levelPiecesMoveRate * Time.deltaTime;
            // move to updated location
            activeLevelPieces [i].transform.position = newLocation;

            // if it has passed the bounds of the LevelPieceManager
            if (activeLevelPieces [i].endLocation.transform.position.x
                < transform.position.x)
            {
                if (isGameRunning)
                {
                    // and it's the beginning piece
                    if (activeLevelPieces [i] == startingLevelPiece)
                    {
                        // remove it from our reusable pieces
                        activeLevelPieces [i].gameObject.SetActive(false);
                    }
                    // reset used piece location to initial spawn location
                    activeLevelPieces [i].transform.position = activeLevelPieces [i].GetInitialLocation();
                    // get a new level piece that is not currently in use
                    activeLevelPieces [i] = GetRandomLevelPiece();
                    // set its location to the end location of the other active piece
                    activeLevelPieces [i].transform.position =
                        FindOtherLevelPiece(activeLevelPieces [i]).endLocation.position;
                    activeLevelPieces [i].ResetAllChildrenCoins();
                }
                else
                {
                    // if game is paused, recycle the two level pieces over and over
                    LevelPiece nextLevelPiece = (i == 0) ? activeLevelPieces [1] : activeLevelPieces [0];
                    activeLevelPieces [i].transform.position = nextLevelPiece.endLocation.position;
                }
            }
        }
    }
コード例 #35
0
 public void Edit(int col, int row)
 {
     // we were general to get to this function, but don't want to handle drag when editing.
     if (targetLevel.IsInsideGridBounds(col, row))
     {
         //in bounds..
         int        cacheIndex = renderedLevelGrid [col] [row];
         LevelPiece validPiece = cacheIndex > -1 ? prefabList [cacheIndex] : null;
         if (validPiece != null)
         {
             paletteItemInspected = prefabList [cacheIndex].GetComponent <PaletteItem> () as PaletteItem;
         }
     }
     else
     {
         paletteItemInspected = null;
     }
     Repaint();
 }
コード例 #36
0
ファイル: LevelCreator.cs プロジェクト: YourMocho/GravJump
    private void LoadPossibleLevelPieces()
    {
        GameObject[] p;
        // p = Resources.LoadAll<LevelPiece>("Prefabs/LevelPieces/");
        //allPossibleLevelPieces = p.ToList<LevelPiece>();

        levelPiecesParent.SetActive(true);

        p = GameObject.FindGameObjectsWithTag("LevelPiece");

        foreach(GameObject piece in p)
        {
            allPossibleLevelPieces.Add(piece.GetComponent<LevelPiece>());
            piece.gameObject.SetActive(false);
        }

        //startingPiece = Resources.Load<LevelPiece>("Prefabs/StartPiece");
        startingPiece = GameObject.FindGameObjectWithTag("StartPiece").GetComponent<LevelPiece>();
        startingPiece.gameObject.SetActive(false);

        tutorialPiece = GameObject.FindGameObjectWithTag("TutorialPiece").GetComponent<LevelPiece>();
        tutorialPiece.gameObject.SetActive(false);
    }   
コード例 #37
0
ファイル: Level.cs プロジェクト: imann24/peace-superheroes
 // Sets an individual piece
 public void SetLevelPiece(int x, int y, LevelPiece type)
 {
     this.levelPieces[x,y] = type;
 }
コード例 #38
0
ファイル: LevelInspector.cs プロジェクト: Randhall/RunAndJump
        private void ResizeLevel()
        {
            LevelPiece[] newPieces = new LevelPiece[_newTotalColumns * _newTotalRows];

            for (int column = 0; column < _myTarget.TotalColumns; ++column)
            {
                for (int row = 0; row < _myTarget.TotalRows; ++row)
                {
                    if (column < _newTotalColumns && row < _newTotalRows)
                    {
                        newPieces[column + row*_newTotalColumns] = _myTarget.Pieces[column + row*_myTarget.TotalColumns];
                    }
                    else
                    {
                        LevelPiece piece = _myTarget.Pieces[column + row*_myTarget.TotalColumns];
                        if (piece != null)
                        {
                            DestroyImmediate(piece.gameObject);
                        }
                    }
                }
            }

            _myTarget.Pieces = newPieces;
            _myTarget.TotalColumns = _newTotalColumns;
            _myTarget.TotalRows = _newTotalRows;
        }
コード例 #39
0
ファイル: LevelInspector.cs プロジェクト: Randhall/RunAndJump
 private void UpdateCurrentPieceInstance(PaletteWindow.PaletteItemSelection itemSelectionEvent)
 {
     _itemSelected = itemSelectionEvent.Item;
     _itemPreview = itemSelectionEvent.Preview;
     _pieceSelected = (LevelPiece) _itemSelected.GetComponent<LevelPiece>();
     Repaint();
 }
コード例 #40
0
ファイル: Level.cs プロジェクト: imann24/peace-superheroes
 // Creates level from the pieces
 public Level(LevelPiece[,] levelPieces)
 {
     this.levelPieces = levelPieces;
 }