Implemented resource manager which can load textures and levels.
Implemented script to generate Resources.g.h file linking assets to code. Added assets from old project.
This commit is contained in:
43
oldproject/Assets/Scripts/Storage/MapLoader.cs
Executable file
43
oldproject/Assets/Scripts/Storage/MapLoader.cs
Executable file
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
using Model;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Storage
|
||||
{
|
||||
public static class MapLoader
|
||||
{
|
||||
public static void LoadLayer(Map map, string layerName, string dataCsv)
|
||||
{
|
||||
// Process layer attributes
|
||||
Layer layer = new Layer();
|
||||
layer.Name = layerName;
|
||||
|
||||
// Split into substrings
|
||||
string[] dataRows = dataCsv.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
for (int y = 0; y < dataRows.Length; y++)
|
||||
{
|
||||
string[] dataRowItems = dataRows[y].Trim().Split(',');
|
||||
|
||||
// Allocate cells
|
||||
if (y == 0)
|
||||
{
|
||||
layer.Cells = new int[dataRows.Length, dataRowItems.Length];
|
||||
layer.Width = dataRowItems.Length;
|
||||
layer.Height = dataRows.Length;
|
||||
}
|
||||
|
||||
// Set cells
|
||||
for (int x = 0; x < layer.Width; x++)
|
||||
layer.Cells[y, x] = Int32.Parse(dataRowItems[x]);
|
||||
}
|
||||
|
||||
// Add layer
|
||||
map.Layers.Add(layer);
|
||||
}
|
||||
}
|
||||
}
|
12
oldproject/Assets/Scripts/Storage/MapLoader.cs.meta
Executable file
12
oldproject/Assets/Scripts/Storage/MapLoader.cs.meta
Executable file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c11a44a1418f7c4bbfbd9f82893e900
|
||||
timeCreated: 1477767546
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user