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:
2016-11-12 14:17:00 +02:00
parent 294fd6e2ac
commit 914ae0de0d
74 changed files with 14937 additions and 304 deletions

View File

@ -0,0 +1,36 @@
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public Camera CameraObject;
public float MovementDelta;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
// Center camera on player
var playerCoords = gameObject.transform.position;
CameraObject.transform.position = new Vector3(playerCoords.x, playerCoords.y, CameraObject.transform.position.z);
// Handle movement keys
float deltaX = 0, deltaY = 0;
if (Input.GetKey(KeyCode.DownArrow))
deltaY -= MovementDelta * Time.deltaTime;
if (Input.GetKey(KeyCode.UpArrow))
deltaY += MovementDelta * Time.deltaTime;
if (Input.GetKey(KeyCode.LeftArrow))
deltaX -= MovementDelta * Time.deltaTime;
if (Input.GetKey(KeyCode.RightArrow))
deltaX += MovementDelta * Time.deltaTime;
gameObject.transform.Translate(deltaX, deltaY, 0);
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1fbc71aa16ba11f4ca78672f45b0fa09
timeCreated: 1477769903
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,56 @@
using UnityEngine;
using System.Collections;
using System.Xml.Linq;
using Model;
using Storage;
using System.IO;
public class SceneLoaderController : MonoBehaviour {
public TextAsset BackgroundLayer;
public Sprite[] BackgroundTileSet;
private Map map;
private void LoadScene(Map map)
{
// Spawn objects
foreach (var layer in map.Layers)
{
GameObject layerObject = new GameObject(layer.Name);
for (int y = 0; y < layer.Height; y++)
for (int x = 0; x < layer.Width; x++)
{
// Obtain tile
int tileId = layer.Cells[y, x];
if (tileId >= 0)
{
// Spawn tile
GameObject tileObject = new GameObject(string.Format("{0}{1}{2}", layer.Name, x, y));
tileObject.transform.parent = layerObject.transform;
tileObject.transform.localPosition = new Vector3(x, -y, 0);
var spriteRenderer = tileObject.AddComponent<SpriteRenderer>();
spriteRenderer.sprite = BackgroundTileSet[tileId];
spriteRenderer.sortingLayerName = layer.Name;
}
}
}
}
// Use this for initialization
void Start ()
{
// Load map
map = new Map();
MapLoader.LoadLayer(map, "Background", BackgroundLayer.text);
LoadScene(map);
}
// Update is called once per frame
void Update () {
}
}

View File

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 598014e699a25e841916d55cd9e865ba
timeCreated: 1477757088
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: