From a456fb7b5179add079838d499dcc816983b12347 Mon Sep 17 00:00:00 2001
From: Erno Lokkila <eolokk@utu.fi>
Date: Sat, 2 Mar 2019 22:48:01 +0200
Subject: [PATCH] Camera mover script and prefab updates

---
 Assets/Prefab/City.prefab                     |  8 ++++-
 Assets/Prefab/ground/GroundGenerator.prefab   |  2 ++
 Assets/Scripts/CameraMover.cs                 | 34 +++++++++++++++++++
 Assets/Scripts/CameraMover.cs.meta            | 11 ++++++
 .../GroundGenerator/GroundGenerator.cs        | 11 ++++++
 5 files changed, 65 insertions(+), 1 deletion(-)
 create mode 100644 Assets/Scripts/CameraMover.cs
 create mode 100644 Assets/Scripts/CameraMover.cs.meta

diff --git a/Assets/Prefab/City.prefab b/Assets/Prefab/City.prefab
index 75ad318..bd359c7 100644
--- a/Assets/Prefab/City.prefab
+++ b/Assets/Prefab/City.prefab
@@ -70,7 +70,7 @@ SpriteRenderer:
   m_SortingLayerID: 0
   m_SortingLayer: 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_FlipX: 0
   m_FlipY: 0
@@ -119,3 +119,9 @@ MonoBehaviour:
   m_Script: {fileID: 11500000, guid: dfe928a858872424991e927606dd4bc3, type: 3}
   m_Name: 
   m_EditorClassIdentifier: 
+  worker: {fileID: 0}
+  population: 0
+  populationLevel: 0
+  resourcePoolLevel: 0
+  roadLevel: 0
+  collectorLevel: 0
diff --git a/Assets/Prefab/ground/GroundGenerator.prefab b/Assets/Prefab/ground/GroundGenerator.prefab
index b2def8a..032267c 100644
--- a/Assets/Prefab/ground/GroundGenerator.prefab
+++ b/Assets/Prefab/ground/GroundGenerator.prefab
@@ -57,3 +57,5 @@ MonoBehaviour:
   - {fileID: 3917056544714409889, guid: 01c364ebfc67d2c448bff8e94d6a73e4, type: 3}
   - {fileID: 7205059401526678128, guid: 8a7319b0cfb1b554a8dd101ad4e060be, type: 3}
   - {fileID: 7666959473089792538, guid: 3d8a1dd57f0015c4093d8bfb80c3c303, type: 3}
+  homeGO: {fileID: 7607310651946833762, guid: 118ed7528555d45418acb5a87b330000, type: 3}
+  workerGO: {fileID: 548039319383633024, guid: 7dc194a2047a39340a91ca7636a56290, type: 3}
diff --git a/Assets/Scripts/CameraMover.cs b/Assets/Scripts/CameraMover.cs
new file mode 100644
index 0000000..555d1b4
--- /dev/null
+++ b/Assets/Scripts/CameraMover.cs
@@ -0,0 +1,34 @@
+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);
+            }
+        }
+    }
+}
diff --git a/Assets/Scripts/CameraMover.cs.meta b/Assets/Scripts/CameraMover.cs.meta
new file mode 100644
index 0000000..3738470
--- /dev/null
+++ b/Assets/Scripts/CameraMover.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1d269887e77657841a2e967e56313d5a
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 
diff --git a/Assets/Scripts/GroundGenerator/GroundGenerator.cs b/Assets/Scripts/GroundGenerator/GroundGenerator.cs
index 900f696..659461e 100644
--- a/Assets/Scripts/GroundGenerator/GroundGenerator.cs
+++ b/Assets/Scripts/GroundGenerator/GroundGenerator.cs
@@ -11,10 +11,15 @@ public class GroundGenerator : MonoBehaviour
     private GameObject[] tiles = null;
     [SerializeField]
     private GameObject[] resourceGOs = null;
+    [SerializeField]
+    private GameObject homeGO = null;
+    [SerializeField]
+    private GameObject workerGO = null;
 
     private int food = 2;
     private int stone = 3;
     private int wood = 4;
+    private int home = 5;
     /*
      0,1,2
      3,4,5
@@ -36,6 +41,7 @@ public class GroundGenerator : MonoBehaviour
         }
 
         createGround();
+        createHome();
         createResources();
 
         Destroy(gameObject);
@@ -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) {
         return Instantiate<GameObject>(go, new Vector3(x, y, z), Quaternion.identity);
     }
-- 
GitLab