Exemplo n.º 1
0
    private void CreateItem(Vector2 position)
    {
        //if (!mapLayoutDictionary.ContainsKey(position.ToString()))
        bool cursorPlaceable = cursor.GetComponent <CursorCollisionCheck>().Placeable;

        if (cursorPlaceable)
        {
            // Instantiate gameobject
            Vector3 positionVector3 = new Vector3();
            positionVector3.x = position.x;
            positionVector3.y = 0f;
            positionVector3.z = position.y;
            GameObject item = Instantiate(Resources.Load(editorPrefabString), cursor.transform.position, cursor.transform.rotation) as GameObject;

            // Create maplayoutelement
            MapLayoutElement newElement = new MapLayoutElement();
            newElement.prefabPath       = itemPrefabString;
            newElement.prefabPathEditor = editorPrefabString;
            newElement.position.x       = (int)position.x;
            newElement.position.y       = (int)position.y;

            // Create gridspace list for new maplayoutelement
            SerializableVector2Int gridSpace = new SerializableVector2Int();
            gridSpace.x = (int)position.x;
            gridSpace.y = (int)position.y;
            newElement.gridSpaces.Add(gridSpace);

            // Add the new element to the current save & maplayoutdictionary
            currentSave.mapLayout.Add(position.ToString(), newElement);
            mapLayoutDictionary.Add(position.ToString(), item);
        }
    }
        /// <summary>
        /// Save block data
        /// </summary>
        private void SaveDataInWorldDictionary()
        {
            return;

            if (isTerrainModified && blocks.IsCreated)
            {
                // TODO: save parameters
                //NativeArray<BlockParameter> blockParameterKeys = blockParameters.GetKeyArray(Allocator.Temp);
                //NativeArray<short> blockParameterValues = blockParameters.GetValueArray(Allocator.Temp);
                ChunkSaveData data = new ChunkSaveData(blocks.ToArray());

                SerializableVector2Int serializableChunkPos = SerializableVector2Int.FromVector2Int(ChunkPosition);
                // add new key or update existing data
                if (World.WorldSave.savedChunks.ContainsKey(serializableChunkPos))
                {
                    World.WorldSave.savedChunks[serializableChunkPos] = data;
                }
                else
                {
                    World.WorldSave.savedChunks.Add(serializableChunkPos, data);
                }

                //blockParameterKeys.Dispose();
                //blockParameterValues.Dispose();
            }
        }
 public Player(string name, Item[] inventory, SerializableVector2Int location)
 {
     this.name      = name;
     this.inventory = inventory;
     this.location  = location;
 }