Skip to content
Snippets Groups Projects
Commit a456fb7b authored by Erno Lokkila's avatar Erno Lokkila
Browse files

Camera mover script and prefab updates

parent 53a98a24
Branches
No related tags found
No related merge requests found
...@@ -70,7 +70,7 @@ SpriteRenderer: ...@@ -70,7 +70,7 @@ SpriteRenderer:
m_SortingLayerID: 0 m_SortingLayerID: 0
m_SortingLayer: 0 m_SortingLayer: 0
m_SortingOrder: 0 m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: f591b023f317ffb4da566dc4f05efe84, type: 3} m_Sprite: {fileID: 21300000, guid: a69243cd6bee5c34497418b7bbea1e20, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1} m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0 m_FlipX: 0
m_FlipY: 0 m_FlipY: 0
...@@ -119,3 +119,9 @@ MonoBehaviour: ...@@ -119,3 +119,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: dfe928a858872424991e927606dd4bc3, type: 3} m_Script: {fileID: 11500000, guid: dfe928a858872424991e927606dd4bc3, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
worker: {fileID: 0}
population: 0
populationLevel: 0
resourcePoolLevel: 0
roadLevel: 0
collectorLevel: 0
...@@ -57,3 +57,5 @@ MonoBehaviour: ...@@ -57,3 +57,5 @@ MonoBehaviour:
- {fileID: 3917056544714409889, guid: 01c364ebfc67d2c448bff8e94d6a73e4, type: 3} - {fileID: 3917056544714409889, guid: 01c364ebfc67d2c448bff8e94d6a73e4, type: 3}
- {fileID: 7205059401526678128, guid: 8a7319b0cfb1b554a8dd101ad4e060be, type: 3} - {fileID: 7205059401526678128, guid: 8a7319b0cfb1b554a8dd101ad4e060be, type: 3}
- {fileID: 7666959473089792538, guid: 3d8a1dd57f0015c4093d8bfb80c3c303, type: 3} - {fileID: 7666959473089792538, guid: 3d8a1dd57f0015c4093d8bfb80c3c303, type: 3}
homeGO: {fileID: 7607310651946833762, guid: 118ed7528555d45418acb5a87b330000, type: 3}
workerGO: {fileID: 548039319383633024, guid: 7dc194a2047a39340a91ca7636a56290, type: 3}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraMover : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.anyKey) {
float x = transform.position.x;
float y = transform.position.y;
float z = transform.position.z;
if (Input.GetKey(KeyCode.LeftArrow)){
gameObject.transform.position = new Vector3(x - 0.1f, y, z);
}
if (Input.GetKey(KeyCode.RightArrow)){
gameObject.transform.position = new Vector3(x + 0.1f, y, z);
}
if (Input.GetKey(KeyCode.UpArrow)){
gameObject.transform.position = new Vector3(x, y + 0.1f, z);
}
if (Input.GetKey(KeyCode.DownArrow)){
gameObject.transform.position = new Vector3(x, y - 0.1f, z);
}
}
}
}
fileFormatVersion: 2
guid: 1d269887e77657841a2e967e56313d5a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -11,10 +11,15 @@ public class GroundGenerator : MonoBehaviour ...@@ -11,10 +11,15 @@ public class GroundGenerator : MonoBehaviour
private GameObject[] tiles = null; private GameObject[] tiles = null;
[SerializeField] [SerializeField]
private GameObject[] resourceGOs = null; private GameObject[] resourceGOs = null;
[SerializeField]
private GameObject homeGO = null;
[SerializeField]
private GameObject workerGO = null;
private int food = 2; private int food = 2;
private int stone = 3; private int stone = 3;
private int wood = 4; private int wood = 4;
private int home = 5;
/* /*
0,1,2 0,1,2
3,4,5 3,4,5
...@@ -36,6 +41,7 @@ public class GroundGenerator : MonoBehaviour ...@@ -36,6 +41,7 @@ public class GroundGenerator : MonoBehaviour
} }
createGround(); createGround();
createHome();
createResources(); createResources();
Destroy(gameObject); Destroy(gameObject);
...@@ -131,6 +137,11 @@ public class GroundGenerator : MonoBehaviour ...@@ -131,6 +137,11 @@ public class GroundGenerator : MonoBehaviour
} }
} }
private void createHome() {
ground[ground.GetLength(0) / 2, ground.GetLength(1) / 2] = home;
spawn(homeGO, ground.GetLength(0) / 2, ground.GetLength(1) / 2, 0);
spawn(workerGO, ground.GetLength(0) / 2, ground.GetLength(1) / 2, 0);
}
private GameObject spawn(GameObject go, int x, int y, int z = 1) { private GameObject spawn(GameObject go, int x, int y, int z = 1) {
return Instantiate<GameObject>(go, new Vector3(x, y, z), Quaternion.identity); return Instantiate<GameObject>(go, new Vector3(x, y, z), Quaternion.identity);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment