diff --git a/Assets/BasicUtility/TileMap/TileMap.cs b/Assets/BasicUtility/TileMap/TileMap.cs index bf11b24..fc4aeda 100644 --- a/Assets/BasicUtility/TileMap/TileMap.cs +++ b/Assets/BasicUtility/TileMap/TileMap.cs @@ -392,14 +392,22 @@ public bool HasTileOn(TileVector cor) /// public TileTransform GetTileOn(int x, int y) { - return tiles[x, y]; + if (Inside(x, y)) + { + return tiles[x, y]; + } + else + { + Debug.LogError("x:" + x + ", y:" + y + "Is not inside the map"); + return null; + } } /// /// Returns the TileTransform of the tile on coordinates /// - /// Coordinates in TileVector + /// Coordinates in TileVector /// public TileTransform GetTileOn(TileVector v) { diff --git a/Assets/CivMars/Buildings/Chest.cs b/Assets/CivMars/Buildings/Chest.cs index 83bc99b..5f99ec6 100644 --- a/Assets/CivMars/Buildings/Chest.cs +++ b/Assets/CivMars/Buildings/Chest.cs @@ -26,8 +26,6 @@ public class Chest : BuildingWGUI, IInventory, IBuildable, IRegystratabe, IHasGu public override void Awake() { base.Awake(); - Graphicks.SetActive(false); - this.Graphicks.transform.position = Vector3.zero; } public void OpenInventory() diff --git a/Assets/CivMars/Buildings/Furnace.cs b/Assets/CivMars/Buildings/Furnace.cs index fa82917..ca6b70b 100644 --- a/Assets/CivMars/Buildings/Furnace.cs +++ b/Assets/CivMars/Buildings/Furnace.cs @@ -88,8 +88,6 @@ void Update() public override void Awake() { base.Awake(); - Graphicks.SetActive(false); - this.Graphicks.transform.position = Vector3.zero; } public void OpenInventory() diff --git a/Assets/CivMars/Buildings/MainBuilding.cs b/Assets/CivMars/Buildings/MainBuilding.cs index be26f44..0765dab 100644 --- a/Assets/CivMars/Buildings/MainBuilding.cs +++ b/Assets/CivMars/Buildings/MainBuilding.cs @@ -32,8 +32,6 @@ enum States public override void Awake() { base.Awake(); - Graphicks.SetActive(false); - //this.Graphicks.transform.position = Vector3.zero; } public void OpenInventory() diff --git a/Assets/CivMars/Buildings/Miner.cs b/Assets/CivMars/Buildings/Miner.cs index d2ebd2d..a97c38f 100644 --- a/Assets/CivMars/Buildings/Miner.cs +++ b/Assets/CivMars/Buildings/Miner.cs @@ -27,8 +27,6 @@ public class Miner : BuildingWGUI, IInventory, IHasGui, IRegystratabe, IBuildabl public override void Awake() { base.Awake(); - Graphicks.SetActive(false); - this.Graphicks.transform.position = Vector3.zero; } public void OpenInventory() diff --git a/Assets/CivMars/Buildings/PlanedBuilding.cs b/Assets/CivMars/Buildings/PlanedBuilding.cs index a6b3686..2a32339 100644 --- a/Assets/CivMars/Buildings/PlanedBuilding.cs +++ b/Assets/CivMars/Buildings/PlanedBuilding.cs @@ -31,8 +31,6 @@ public class PlanedBuilding : BuildingWGUI, ISaveble, IRegystratabe public override void Awake() { base.Awake(); - Graphicks.SetActive(false); - this.Graphicks.transform.position = Vector3.zero; } void Start() diff --git a/Assets/CivMars/Buildings/Press.cs b/Assets/CivMars/Buildings/Press.cs index 3dc5f99..0d77eed 100644 --- a/Assets/CivMars/Buildings/Press.cs +++ b/Assets/CivMars/Buildings/Press.cs @@ -88,8 +88,6 @@ void Update() public override void Awake() { base.Awake(); - Graphicks.SetActive(false); - this.Graphicks.transform.position = Vector3.zero; } public void OpenInventory() diff --git a/Assets/CivMars/Items/IronPipe.cs b/Assets/CivMars/Items/IronPipe.cs index 411f383..01212f1 100644 --- a/Assets/CivMars/Items/IronPipe.cs +++ b/Assets/CivMars/Items/IronPipe.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using CivMarsEngine; -using UnityEngine; +using CivMarsEngine; namespace CivMars { diff --git a/Assets/CivMars/Items/Item.cs b/Assets/CivMars/Items/Item.cs deleted file mode 100644 index 860e2e5..0000000 --- a/Assets/CivMars/Items/Item.cs +++ /dev/null @@ -1,71 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using UnityEngine; - -public class Item -{ - public string name; - public int amount; - public int maxStackSize; - public Sprite texture; - - - public Item(int setAmount) - { - amount = setAmount; - } - - public Item(int setAmount, int SetMaxStackSize) - { - amount = setAmount; - maxStackSize = SetMaxStackSize; - } - - public Item() - { - } - - - public int Add(int addAmount) - { - if ((amount + addAmount) > (maxStackSize)) - { - int reamaining = (amount + addAmount) - maxStackSize; - amount = maxStackSize; - //Debug.Log(amount); - return reamaining; - } - else - { - amount = amount + addAmount; - //Debug.Log(i.amount); - return -1; - } - } - - /// - /// Remove amonunt fron the item - /// - /// amount to remove - /// Returns the remaining amount or -1 if completed - public int Remove(int remAmount) - { - if ((amount - remAmount) < 0) - { - int reamaining = remAmount - amount; - amount = 0; - //Debug.Log(amount); - return reamaining; - } - else - { - amount = amount - remAmount; - //Debug.Log(i.amount); - return -1; - } - } - -} - diff --git a/Assets/CivMars/Items/Ore/CoalOre.cs b/Assets/CivMars/Items/Ore/CoalOre.cs index 4b6e377..a3b961c 100644 --- a/Assets/CivMars/Items/Ore/CoalOre.cs +++ b/Assets/CivMars/Items/Ore/CoalOre.cs @@ -1,4 +1,6 @@ -namespace CivMars +using CivMarsEngine; + +namespace CivMars { public class CoalOre : Item { diff --git a/Assets/CivMars/Items/Ore/IronOre.cs b/Assets/CivMars/Items/Ore/IronOre.cs index f1e6926..e0ab1f4 100644 --- a/Assets/CivMars/Items/Ore/IronOre.cs +++ b/Assets/CivMars/Items/Ore/IronOre.cs @@ -1,4 +1,6 @@ -namespace CivMars +using CivMarsEngine; + +namespace CivMars { public class IronOre : Item { diff --git a/Assets/CivMars/Items/Ore/SandOre.cs b/Assets/CivMars/Items/Ore/SandOre.cs index b9d5532..d944dd3 100644 --- a/Assets/CivMars/Items/Ore/SandOre.cs +++ b/Assets/CivMars/Items/Ore/SandOre.cs @@ -1,4 +1,6 @@ -namespace CivMars +using CivMarsEngine; + +namespace CivMars { public class SandOre : Item { diff --git a/Assets/CivMars/Items/Ore/StoneOre.cs b/Assets/CivMars/Items/Ore/StoneOre.cs index 8fafc81..a0cb559 100644 --- a/Assets/CivMars/Items/Ore/StoneOre.cs +++ b/Assets/CivMars/Items/Ore/StoneOre.cs @@ -1,4 +1,6 @@ -namespace CivMars +using CivMarsEngine; + +namespace CivMars { public class StoneOre : Item { diff --git a/Assets/CivMars/Items/Ore/UraniumOre.cs b/Assets/CivMars/Items/Ore/UraniumOre.cs index 46547af..ae34fdc 100644 --- a/Assets/CivMars/Items/Ore/UraniumOre.cs +++ b/Assets/CivMars/Items/Ore/UraniumOre.cs @@ -1,4 +1,6 @@ -namespace CivMars +using CivMarsEngine; + +namespace CivMars { public class UraniumOre : Item { diff --git a/Assets/CivMars/NeedToBeImplemented/Food.cs b/Assets/CivMars/NeedToBeImplemented/Food.cs index 39d2ec2..5221d3e 100644 --- a/Assets/CivMars/NeedToBeImplemented/Food.cs +++ b/Assets/CivMars/NeedToBeImplemented/Food.cs @@ -1,10 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using CivMarsEngine; - - public class Food:Item - { - } +namespace CivMars +{ + public class Food : Item + { + } +} diff --git a/Assets/CivMars/NeedToBeImplemented/RefrinedUranium.cs b/Assets/CivMars/NeedToBeImplemented/RefrinedUranium.cs index 0ec460f..d9e8241 100644 --- a/Assets/CivMars/NeedToBeImplemented/RefrinedUranium.cs +++ b/Assets/CivMars/NeedToBeImplemented/RefrinedUranium.cs @@ -1,11 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - - - - public class RefrinedUranium:Item +using CivMarsEngine; +public class RefrinedUranium:Item { public string name = "RefrinedUranium"; diff --git a/Assets/CivMars/NeedToBeImplemented/Resource.cs b/Assets/CivMars/NeedToBeImplemented/Resource.cs index ad279f4..0c3ef76 100644 --- a/Assets/CivMars/NeedToBeImplemented/Resource.cs +++ b/Assets/CivMars/NeedToBeImplemented/Resource.cs @@ -1,11 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using CivMarsEngine; - - - public class Resource:Item - { - } +namespace CivMars +{ + public class Resource : Item + { + } +} \ No newline at end of file diff --git a/Assets/CivMars/NeedToBeImplemented/Tool.cs b/Assets/CivMars/NeedToBeImplemented/Tool.cs index 57577b6..3fc3052 100644 --- a/Assets/CivMars/NeedToBeImplemented/Tool.cs +++ b/Assets/CivMars/NeedToBeImplemented/Tool.cs @@ -1,11 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using CivMarsEngine; - - - public class Tool:Item +public class Tool:Item { } diff --git a/Assets/CivMars/Ores/CoalOreTile.cs b/Assets/CivMars/Ores/CoalOreTile.cs index d481534..296be3c 100644 --- a/Assets/CivMars/Ores/CoalOreTile.cs +++ b/Assets/CivMars/Ores/CoalOreTile.cs @@ -18,12 +18,11 @@ public override void Generate(System.Random r, TileMap map) base.Generate(r, map); } - override public void Regystrate() { base.ID = this.ID; - chanche = 0; + chanche = 100; chanche2 = 250; chancheReduce = 5; distance = -1; diff --git a/Assets/CivMars/Ores/OreTile.cs b/Assets/CivMars/Ores/OreTile.cs index 7b6ab69..8eaea06 100644 --- a/Assets/CivMars/Ores/OreTile.cs +++ b/Assets/CivMars/Ores/OreTile.cs @@ -31,7 +31,7 @@ public virtual void Generate(System.Random r, TileMap map) bool k = map.HasTileOn(pos); - if (r.Next(0,1000) <= chanche && first && k) + if (r.Next(0, 1000) <= chanche && first && k) { first = true; GameObject a = Instantiate(this.gameObject); @@ -41,7 +41,7 @@ public virtual void Generate(System.Random r, TileMap map) a.GetComponent().Spread(r, map, chanche2); } - + } } @@ -57,17 +57,27 @@ public void Spread(System.Random r, TileMap map, float chancheCurrent) for (int j = -1; j < 2; j++) { TileVector pos = transform.position + new TileVector(i, j); - if ((i != 0 || j != 0) && map.Inside(pos) && map.HasTileOn(pos)) + + bool k = !map.HasTileOn(pos); + + if ((i != 0 || j != 0) && map.Inside(pos) && !k) { - if (r.Next(1000) <= chancheCurrent) + if (r.Next(0, 1000) <= chancheCurrent) { - GameObject a = Instantiate(this.gameObject); + if (!k) + { + GameObject a = Instantiate(this.gameObject); - a.name = (int.Parse(this.name[0].ToString()) + 1).ToString() + "a"; + a.name = (int.Parse(this.name[0].ToString()) + 1).ToString() + "a"; - map.SetTile(pos.x, pos.y, a.GetComponent()); + map.SetTile(pos.x, pos.y, a.GetComponent()); - a.GetComponent().Spread(r, map, chancheCurrent - chancheReduce); + a.GetComponent().Spread(r, map, chancheCurrent - chancheReduce); + } + else if(map.GetTileOn(pos.x, pos.y).GetComponent().ID == this.ID) + { + map.GetTileOn(pos.x, pos.y).GetComponent().Spread(r, map, chancheCurrent - chancheReduce); + } } } } diff --git a/Assets/CivMarsEngine/Building.cs b/Assets/CivMarsEngine/Building.cs index 7dd604f..330b595 100644 --- a/Assets/CivMarsEngine/Building.cs +++ b/Assets/CivMarsEngine/Building.cs @@ -13,7 +13,7 @@ public class Building : Tiled, ISaveble //public List buildingMaterials; - public GameObject Graphicks; + public GameObject graphics; public bool guion; public override void Awake() @@ -21,11 +21,7 @@ public override void Awake() base.Awake(); } - public void PositionUpdate() - { - Graphicks.SetActive(false); - this.Graphicks.transform.position = Vector3.zero; - } + diff --git a/Assets/CivMarsEngine/BuildingWGUI.cs b/Assets/CivMarsEngine/BuildingWGUI.cs index 9b93d74..16907f9 100644 --- a/Assets/CivMarsEngine/BuildingWGUI.cs +++ b/Assets/CivMarsEngine/BuildingWGUI.cs @@ -3,13 +3,22 @@ using System.Linq; using System.Text; using CivMarsEngine; +using UnityEngine; using UnityEngine.EventSystems; namespace CivMarsEngine { - public class BuildingWGUI : Building, IHasGui + public class BuildingWGUI : Building, IHasGui, IPointerClickHandler { + public GameObject SideMenu; + + public void PositionUpdate() + { + SideMenu.SetActive(false); + this.SideMenu.transform.position = Vector3.zero; + } + #region IhasGui public void TogelGui() { @@ -30,13 +39,13 @@ public void TogelGui() public virtual void Open() { guion = true; - Graphicks.SetActive(true); + SideMenu.SetActive(true); } public virtual void Close() { guion = false; - Graphicks.SetActive(false); + SideMenu.SetActive(false); } public int ClosingLevel() @@ -46,7 +55,7 @@ public int ClosingLevel() public void OnPointerClick(PointerEventData eventData) { - if (!eventData.rawPointerPress.transform.IsChildOf(Graphicks.transform)) + if (!eventData.rawPointerPress.transform.IsChildOf(graphics.transform)) TogelGui(); } #endregion diff --git a/Assets/CivMarsEngine/GUI/Access Panel/AccesPanel.cs b/Assets/CivMarsEngine/GUI/Access Panel/AccesPanel.cs index 5fc01f6..9b140c6 100644 --- a/Assets/CivMarsEngine/GUI/Access Panel/AccesPanel.cs +++ b/Assets/CivMarsEngine/GUI/Access Panel/AccesPanel.cs @@ -10,7 +10,7 @@ public class AccesPanel : MonoBehaviour, IHasGui public Building OpenBuilding; - public bool open; + public bool on; public GameObject[] AccesTabs; @@ -22,48 +22,53 @@ public void Start() } - public void Update() + void Update() { if (Input.GetButtonUp("Inventory")) { - Debug.Log("Inventory opening"); TogelGui(); } } - - #region IhasGui + #region IHasGUI public void TogelGui() { - if (!open) + if (!on) { - if (GameCon.AlloweGUI(this as IHasGui)) + if (GameCon.HasOpendGui()) + { + GameCon.CloseGUI(null); + } + else { - Open(); + if (GameCon.AlloweGUI(this)) + { + Open(); + } } } else { - GameCon.CloseGUI(this as IHasGui); + GameCon.CloseGUI(this); Close(); } } public void Open() { - open = true; Graphicks.SetActive(true); + on = true; } public void Close() { - open = false; Graphicks.SetActive(false); + on = false; } public int ClosingLevel() { - return 10; + return int.MaxValue; } - #endregion +#endregion } } \ No newline at end of file diff --git a/Assets/CivMarsEngine/GUI/Access Panel/InventoryDesplay/InventoryDesplay.cs b/Assets/CivMarsEngine/GUI/Access Panel/InventoryDesplay/InventoryDesplay.cs index 3b5175c..4b51de7 100644 --- a/Assets/CivMarsEngine/GUI/Access Panel/InventoryDesplay/InventoryDesplay.cs +++ b/Assets/CivMarsEngine/GUI/Access Panel/InventoryDesplay/InventoryDesplay.cs @@ -59,6 +59,7 @@ void UpdateInventorySection(IInventory invThis, IInventory invOthe, GameObject[] actual.transform.SetParent(drawingCanvas.transform); actual.transform.SetSiblingIndex(i); + actual.transform.localScale = Vector3.one; actual.GetComponent().Set(invThis.GetStackInSlot(i), isplayer, invOthe, invThis, i); } //Item element @@ -78,6 +79,7 @@ void UpdateInventorySection(IInventory invThis, IInventory invOthe, GameObject[] actual.transform.SetParent(drawingCanvas.transform); actual.transform.SetSiblingIndex(i); + actual.transform.localScale = Vector3.one; actual.GetComponent().Set(invThis.GetStackInSlot(i), isplayer, invOthe, invThis, i); drawed[i] = actual; } @@ -100,6 +102,8 @@ void UpdateInventorySection(IInventory invThis, IInventory invOthe, GameObject[] actual = Instantiate(InventoryElementBack); actual.transform.SetParent(drawingCanvas.transform); actual.transform.SetSiblingIndex(i); + + actual.transform.localScale = Vector3.one; } } else @@ -109,6 +113,8 @@ void UpdateInventorySection(IInventory invThis, IInventory invOthe, GameObject[] actual = Instantiate(InventoryElementBack); actual.transform.SetParent(drawingCanvas.transform); actual.transform.SetSiblingIndex(i); + + actual.transform.localScale = Vector3.one; } } drawed[i] = actual; diff --git a/Assets/CivMarsEngine/GUI/Access Panel/InventoryDesplay/InventoryDrawedElement.cs b/Assets/CivMarsEngine/GUI/Access Panel/InventoryDesplay/InventoryDrawedElement.cs index c038112..47f0052 100644 --- a/Assets/CivMarsEngine/GUI/Access Panel/InventoryDesplay/InventoryDrawedElement.cs +++ b/Assets/CivMarsEngine/GUI/Access Panel/InventoryDesplay/InventoryDrawedElement.cs @@ -18,8 +18,8 @@ public class InventoryDrawedElement : MonoBehaviour public IInventory thisinv; - public GameObject nameDisplay; - public GameObject amountDisplay; + public Text nameDisplay; + public Text amountDisplay; public Button button; @@ -47,8 +47,7 @@ void Update() public void Set(int setAmount) { this.amount = setAmount; - amountDisplay.GetComponent().text = null; - amountDisplay.GetComponent().text = setAmount.ToString(); + amountDisplay.text = setAmount.ToString(); //Debug.Log("updated drawed inv element: amount: " + amount + " type: " + this.name + " obj: " + this.GetType().ToString()); } @@ -56,9 +55,7 @@ public void Set(int setAmount) public void Set(string setName) { this.drawname_name = setName; - //Debug.Log(setName); - - nameDisplay.GetComponent().text = setName.ToString(); + nameDisplay.text = setName.ToString(); } public void Set(string setName, int setAmount) diff --git a/Assets/CivMarsEngine/GUI/Buildables/BuildingLister.cs b/Assets/CivMarsEngine/GUI/Buildables/BuildingLister.cs index aab8e44..a88346c 100644 --- a/Assets/CivMarsEngine/GUI/Buildables/BuildingLister.cs +++ b/Assets/CivMarsEngine/GUI/Buildables/BuildingLister.cs @@ -1,16 +1,19 @@ using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; +using UnityEngine.EventSystems; +using System; namespace CivMarsEngine { - public class BuildingLister : MonoBehaviour, IHasGui + public class BuildingLister : MonoBehaviour, IHasGui,IPointerClickHandler { public GameObject buildableDrawElement; public GameObject buildingDesplayCanvas; - public GameObject planedBuildingPrefab; + public GraphicRaycaster raycaster; + bool guion; GameController GameCon; @@ -49,6 +52,7 @@ void Start() actual.transform.SetSiblingIndex(i); actual.transform.FindChild("Icon").GetComponent().sprite = ((IBuildable)GameRegystry.buildings[buildingID[i]]).GetImage(); actual.GetComponent().group = toglegroup; + actual.transform.localScale = Vector3.one; } } @@ -57,52 +61,33 @@ void Start() void Update() { - if (state == BuildingListerStates.Idle) + if (Input.GetButtonUp("BuildingList") && (state == BuildingListerStates.Idle|| state == BuildingListerStates.Selecting)) { - inBuilding.SetActive(false); - inSelecting.SetActive(false); - if (Input.GetButtonUp("BuildingList")) - { Debug.Log("Buildning opening"); - TogelGui(); - } } else if (state == BuildingListerStates.Building) { - inBuilding.SetActive(true); - inSelecting.SetActive(false); - } - else if (state == BuildingListerStates.Selecting) - { - inBuilding.SetActive(false); - inSelecting.SetActive(true); - if (Input.GetButtonUp("BuildingList")) + if (Input.GetMouseButtonUp(0) && SelectedBuilding != -1 && !EventSystem.current.IsPointerOverGameObject()) { - Debug.Log("Buildning opening"); - - TogelGui(); - } - } + Vector3 ray = Camera.main.ScreenToWorldPoint(Input.mousePosition); - if (Input.GetMouseButtonDown(0) && SelectedBuilding != -1 && state == BuildingListerStates.Building) - { - Vector3 ray = Camera.main.ScreenToWorldPoint(Input.mousePosition); - - TileVector pos = new TileVector(Mathf.Round(ray.x - 0.5f), -1 * Mathf.Round(ray.y + 0.5f - )); + TileVector pos = new TileVector(Mathf.Round(ray.x - 0.5f), -1* Mathf.Round(ray.y + 0.5f),TileVectorTypes.ySwaped); - if (GameCon.map.Buildings.GetTileOn((int)pos.x, (int)pos.y) == null) - { - PlanedBuilding p = Instantiate(planedBuildingPrefab).GetComponent(); - GameCon.map.Buildings.SetTile(pos.x, pos.y, p.transform); + if (GameCon.map.Buildings.GetTileOn((int)pos.x, (int)pos.y) == null) + { + PlanedBuilding p = Instantiate(planedBuildingPrefab).GetComponent(); + GameCon.map.Buildings.SetTile(pos.x, pos.y, p.transform); - p.SetBuilding(((IBuildable)GameRegystry.buildings[buildingID[SelectedBuilding]])); + p.SetBuilding(((IBuildable)GameRegystry.buildings[buildingID[SelectedBuilding]])); + } + GameCon.CloseGUI(this); + Close(); } - GameCon.CloseGUI(this); - Close(); } + + } public void BuildSelected() @@ -113,6 +98,9 @@ public void BuildSelected() return; } + inBuilding.SetActive(true); + inSelecting.SetActive(false); + state = BuildingListerStates.Building; } @@ -120,6 +108,8 @@ public void CancelBuilding() { SelectedBuilding = -1; state = BuildingListerStates.Selecting; + inBuilding.SetActive(false); + inSelecting.SetActive(true); } #region IhasGui @@ -143,12 +133,17 @@ public void Open() { guion = true; state = BuildingListerStates.Selecting; + inBuilding.SetActive(false); + inSelecting.SetActive(true); } public void Close() { guion = false; state = BuildingListerStates.Idle; + + inBuilding.SetActive(false); + inSelecting.SetActive(false); } public int ClosingLevel() @@ -162,7 +157,14 @@ public int ClosingLevel() return int.MaxValue; } } + + public void OnPointerClick(PointerEventData eventData) + { + throw new NotImplementedException(); + } #endregion + + } public enum BuildingListerStates diff --git a/Assets/CivMarsEngine/GUI/GUIHandler.cs b/Assets/CivMarsEngine/GUI/GUIHandler.cs index 2cdf010..dd76a85 100644 --- a/Assets/CivMarsEngine/GUI/GUIHandler.cs +++ b/Assets/CivMarsEngine/GUI/GUIHandler.cs @@ -6,25 +6,38 @@ public class GUIHandler : MonoBehaviour { + GameController GameCon; + public AccesPanel AccesPanel; public InventoryDesplay defaultInventory; public GasDesplay defaultGas; public CraftingDesplay defaultCrafting; - /* + public Slider miningSlider; + public GameObject miningPlanel; + + // Use this for initialization void Start() { - - + GameCon = GameObject.FindGameObjectWithTag("GameController").GetComponent(); } // Update is called once per frame void Update() { - + if (GameCon.playerclass.miningTime > 0) + { + + miningPlanel.SetActive(true); + miningSlider.maxValue = GameCon.playerclass.fullMiningTime; + miningSlider.value = GameCon.playerclass.miningTime; + } + else + { + miningPlanel.SetActive(false); + } } - */ } diff --git a/Assets/CivMarsEngine/GUI/Inventory/PlayerInventory.cs b/Assets/CivMarsEngine/GUI/Inventory/PlayerInventory.cs index f177605..9cddccd 100644 --- a/Assets/CivMarsEngine/GUI/Inventory/PlayerInventory.cs +++ b/Assets/CivMarsEngine/GUI/Inventory/PlayerInventory.cs @@ -54,7 +54,7 @@ public void UpdateInventory() actual.transform.SetParent(InventoryCanvasPlayer.transform); actual.transform.SetSiblingIndex(i); - + actual.transform.localScale = Vector3.one; actual.GetComponent().Set(player.GetStackInSlot(i), i); @@ -75,7 +75,7 @@ public void UpdateInventory() actual.transform.SetParent(InventoryCanvasPlayer.transform); actual.transform.SetSiblingIndex(i); - + actual.transform.localScale = Vector3.one; actual.GetComponent().Set(player.GetStackInSlot(i), i); } } @@ -102,6 +102,7 @@ public void UpdateInventory() actual = Instantiate(InventoryElementBack); actual.transform.SetParent(InventoryCanvasPlayer.transform); actual.transform.SetSiblingIndex(i); + actual.transform.localScale = Vector3.one; } } else @@ -111,6 +112,7 @@ public void UpdateInventory() actual = Instantiate(InventoryElementBack); actual.transform.SetParent(InventoryCanvasPlayer.transform); actual.transform.SetSiblingIndex(i); + actual.transform.localScale = Vector3.one; } } drawedInvPlayer[i] = actual; diff --git a/Assets/CivMarsEngine/GUI/UITextures/Fonts/Michroma.ttf.meta b/Assets/CivMarsEngine/GUI/UITextures/Fonts/Michroma.ttf.meta index 40eeb31..b8c1d68 100644 --- a/Assets/CivMarsEngine/GUI/UITextures/Fonts/Michroma.ttf.meta +++ b/Assets/CivMarsEngine/GUI/UITextures/Fonts/Michroma.ttf.meta @@ -4,7 +4,7 @@ timeCreated: 1449001620 licenseType: Free TrueTypeFontImporter: serializedVersion: 2 - fontSize: 16 + fontSize: 1 forceTextureCase: -2 characterSpacing: 1 characterPadding: 0 @@ -13,7 +13,7 @@ TrueTypeFontImporter: fontNames: [] fallbackFontReferences: [] customCharacters: - fontRenderingMode: 0 + fontRenderingMode: 1 userData: assetBundleName: assetBundleVariant: diff --git a/Assets/CivMarsEngine/GUI/UITextures/GUI.Button.png b/Assets/CivMarsEngine/GUI/UITextures/GUI.Button.png new file mode 100644 index 0000000..44b7036 Binary files /dev/null and b/Assets/CivMarsEngine/GUI/UITextures/GUI.Button.png differ diff --git a/Assets/CivMarsEngine/GUI/UITextures/GUI.Button.png.meta b/Assets/CivMarsEngine/GUI/UITextures/GUI.Button.png.meta new file mode 100644 index 0000000..d8eda35 --- /dev/null +++ b/Assets/CivMarsEngine/GUI/UITextures/GUI.Button.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 34c0e8673dc93a140985b6d0543c6293 +timeCreated: 1450900767 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: 0 + aniso: 16 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 2, y: 2, z: 2, w: 2} + spritePixelsToUnits: 100 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/CivMarsEngine/GUI/UITextures/GUI.Header.png.meta b/Assets/CivMarsEngine/GUI/UITextures/GUI.Header.png.meta index 54f8ad6..34c98e1 100644 --- a/Assets/CivMarsEngine/GUI/UITextures/GUI.Header.png.meta +++ b/Assets/CivMarsEngine/GUI/UITextures/GUI.Header.png.meta @@ -7,7 +7,7 @@ TextureImporter: serializedVersion: 2 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 linearTexture: 0 correctGamma: 0 fadeOut: 0 @@ -17,7 +17,7 @@ TextureImporter: bumpmap: convertToNormalMap: 0 externalNormalMap: 0 - heightScale: .25 + heightScale: 0.25 normalMapFilter: 0 isReadable: 0 grayScaleToAlpha: 0 @@ -42,14 +42,15 @@ TextureImporter: spriteExtrude: 1 spriteMeshType: 1 alignment: 0 - spritePivot: {x: .5, y: .5} + spritePivot: {x: 0.5, y: 0.5} spriteBorder: {x: 3, y: 3, z: 3, w: 3} - spritePixelsToUnits: 2 + spritePixelsToUnits: 200 alphaIsTransparency: 1 textureType: 8 buildTargetSettings: [] spriteSheet: sprites: [] + outline: [] spritePackingTag: userData: assetBundleName: diff --git a/Assets/CivMarsEngine/GUI/UITextures/GUI.Inverted.png.meta b/Assets/CivMarsEngine/GUI/UITextures/GUI.Inverted.png.meta index 7b3dba9..30f28d5 100644 --- a/Assets/CivMarsEngine/GUI/UITextures/GUI.Inverted.png.meta +++ b/Assets/CivMarsEngine/GUI/UITextures/GUI.Inverted.png.meta @@ -7,7 +7,7 @@ TextureImporter: serializedVersion: 2 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 linearTexture: 0 correctGamma: 0 fadeOut: 0 @@ -17,7 +17,7 @@ TextureImporter: bumpmap: convertToNormalMap: 0 externalNormalMap: 0 - heightScale: .25 + heightScale: 0.25 normalMapFilter: 0 isReadable: 0 grayScaleToAlpha: 0 @@ -42,14 +42,15 @@ TextureImporter: spriteExtrude: 1 spriteMeshType: 1 alignment: 0 - spritePivot: {x: .5, y: .5} + spritePivot: {x: 0.5, y: 0.5} spriteBorder: {x: 3, y: 3, z: 3, w: 3} - spritePixelsToUnits: 2 + spritePixelsToUnits: 200 alphaIsTransparency: 1 textureType: 8 buildTargetSettings: [] spriteSheet: sprites: [] + outline: [] spritePackingTag: userData: assetBundleName: diff --git a/Assets/CivMarsEngine/GUI/UITextures/GUI.Inverted2.png.meta b/Assets/CivMarsEngine/GUI/UITextures/GUI.Inverted2.png.meta index 9f1861d..3ea34aa 100644 --- a/Assets/CivMarsEngine/GUI/UITextures/GUI.Inverted2.png.meta +++ b/Assets/CivMarsEngine/GUI/UITextures/GUI.Inverted2.png.meta @@ -7,7 +7,7 @@ TextureImporter: serializedVersion: 2 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 linearTexture: 0 correctGamma: 0 fadeOut: 0 @@ -17,7 +17,7 @@ TextureImporter: bumpmap: convertToNormalMap: 0 externalNormalMap: 0 - heightScale: .25 + heightScale: 0.25 normalMapFilter: 0 isReadable: 0 grayScaleToAlpha: 0 @@ -42,14 +42,15 @@ TextureImporter: spriteExtrude: 1 spriteMeshType: 1 alignment: 0 - spritePivot: {x: .5, y: .5} + spritePivot: {x: 0.5, y: 0.5} spriteBorder: {x: 3, y: 3, z: 3, w: 3} - spritePixelsToUnits: 2 + spritePixelsToUnits: 200 alphaIsTransparency: 1 textureType: 8 buildTargetSettings: [] spriteSheet: sprites: [] + outline: [] spritePackingTag: userData: assetBundleName: diff --git a/Assets/CivMarsEngine/GUI/UITextures/GUI.base.png.meta b/Assets/CivMarsEngine/GUI/UITextures/GUI.base.png.meta index e99c6a3..d62c8e6 100644 --- a/Assets/CivMarsEngine/GUI/UITextures/GUI.base.png.meta +++ b/Assets/CivMarsEngine/GUI/UITextures/GUI.base.png.meta @@ -7,7 +7,7 @@ TextureImporter: serializedVersion: 2 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 linearTexture: 0 correctGamma: 0 fadeOut: 0 @@ -17,7 +17,7 @@ TextureImporter: bumpmap: convertToNormalMap: 0 externalNormalMap: 0 - heightScale: .25 + heightScale: 0.25 normalMapFilter: 0 isReadable: 0 grayScaleToAlpha: 0 @@ -42,14 +42,15 @@ TextureImporter: spriteExtrude: 1 spriteMeshType: 1 alignment: 0 - spritePivot: {x: .5, y: .5} + spritePivot: {x: 0.5, y: 0.5} spriteBorder: {x: 3, y: 3, z: 3, w: 3} - spritePixelsToUnits: 2 + spritePixelsToUnits: 75 alphaIsTransparency: 1 textureType: 8 buildTargetSettings: [] spriteSheet: sprites: [] + outline: [] spritePackingTag: userData: assetBundleName: diff --git a/Assets/CivMarsEngine/GUI/UITextures/Ring.full.png.meta b/Assets/CivMarsEngine/GUI/UITextures/Ring.full.png.meta index a4087e2..2dfc264 100644 --- a/Assets/CivMarsEngine/GUI/UITextures/Ring.full.png.meta +++ b/Assets/CivMarsEngine/GUI/UITextures/Ring.full.png.meta @@ -7,7 +7,7 @@ TextureImporter: serializedVersion: 2 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 linearTexture: 0 correctGamma: 0 fadeOut: 0 diff --git a/Assets/CivMarsEngine/GUI/UITextures/Ring.png.meta b/Assets/CivMarsEngine/GUI/UITextures/Ring.png.meta index a2d489a..875e154 100644 --- a/Assets/CivMarsEngine/GUI/UITextures/Ring.png.meta +++ b/Assets/CivMarsEngine/GUI/UITextures/Ring.png.meta @@ -7,7 +7,7 @@ TextureImporter: serializedVersion: 2 mipmaps: mipMapMode: 0 - enableMipMap: 0 + enableMipMap: 1 linearTexture: 0 correctGamma: 0 fadeOut: 0 @@ -17,7 +17,7 @@ TextureImporter: bumpmap: convertToNormalMap: 0 externalNormalMap: 0 - heightScale: .25 + heightScale: 0.25 normalMapFilter: 0 isReadable: 0 grayScaleToAlpha: 0 @@ -42,7 +42,7 @@ TextureImporter: spriteExtrude: 1 spriteMeshType: 1 alignment: 0 - spritePivot: {x: .5, y: .5} + spritePivot: {x: 0.5, y: 0.5} spriteBorder: {x: 0, y: 0, z: 0, w: 0} spritePixelsToUnits: 256 alphaIsTransparency: 1 @@ -50,6 +50,7 @@ TextureImporter: buildTargetSettings: [] spriteSheet: sprites: [] + outline: [] spritePackingTag: userData: assetBundleName: diff --git a/Assets/CivMarsEngine/GUI/UITextures/Ring2.png.meta b/Assets/CivMarsEngine/GUI/UITextures/Ring2.png.meta index a9eae88..e669304 100644 --- a/Assets/CivMarsEngine/GUI/UITextures/Ring2.png.meta +++ b/Assets/CivMarsEngine/GUI/UITextures/Ring2.png.meta @@ -7,7 +7,7 @@ TextureImporter: serializedVersion: 2 mipmaps: mipMapMode: 0 - enableMipMap: 1 + enableMipMap: 0 linearTexture: 0 correctGamma: 0 fadeOut: 0 @@ -17,7 +17,7 @@ TextureImporter: bumpmap: convertToNormalMap: 0 externalNormalMap: 0 - heightScale: .25 + heightScale: 0.25 normalMapFilter: 0 isReadable: 0 grayScaleToAlpha: 0 @@ -30,7 +30,7 @@ TextureImporter: maxTextureSize: 2048 textureSettings: filterMode: -1 - aniso: -1 + aniso: 16 mipBias: -1 wrapMode: 1 nPOTScale: 0 @@ -42,7 +42,7 @@ TextureImporter: spriteExtrude: 1 spriteMeshType: 1 alignment: 0 - spritePivot: {x: .5, y: .5} + spritePivot: {x: 0.5, y: 0.5} spriteBorder: {x: 0, y: 0, z: 0, w: 0} spritePixelsToUnits: 100 alphaIsTransparency: 1 @@ -50,6 +50,7 @@ TextureImporter: buildTargetSettings: [] spriteSheet: sprites: [] + outline: [] spritePackingTag: userData: assetBundleName: diff --git a/Assets/CivMarsEngine/Item.cs b/Assets/CivMarsEngine/Item.cs new file mode 100644 index 0000000..cf35034 --- /dev/null +++ b/Assets/CivMarsEngine/Item.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEngine; + +namespace CivMarsEngine +{ + public class Item + { + public string name = ""; + public int amount; + public int maxStackSize; + public Sprite texture; + + + public Item(int setAmount) + { + amount = setAmount; + } + + public Item(int setAmount, int SetMaxStackSize) + { + amount = setAmount; + maxStackSize = SetMaxStackSize; + } + + public Item() + { + } + + + public int Add(int addAmount) + { + if ((amount + addAmount) > (maxStackSize)) + { + int reamaining = (amount + addAmount) - maxStackSize; + amount = maxStackSize; + //Debug.Log(amount); + return reamaining; + } + else + { + amount = amount + addAmount; + //Debug.Log(i.amount); + return -1; + } + } + + /// + /// Remove amonunt fron the item + /// + /// amount to remove + /// Returns the remaining amount or -1 if completed + public int Remove(int remAmount) + { + if ((amount - remAmount) < 0) + { + int reamaining = remAmount - amount; + amount = 0; + //Debug.Log(amount); + return reamaining; + } + else + { + amount = amount - remAmount; + //Debug.Log(i.amount); + return -1; + } + } + + } +} \ No newline at end of file diff --git a/Assets/CivMars/Items/Item.cs.meta b/Assets/CivMarsEngine/Item.cs.meta similarity index 100% rename from Assets/CivMars/Items/Item.cs.meta rename to Assets/CivMarsEngine/Item.cs.meta diff --git a/Assets/CivMarsEngine/Player/Player.cs b/Assets/CivMarsEngine/Player/Player.cs index 48c29af..817e5b9 100644 --- a/Assets/CivMarsEngine/Player/Player.cs +++ b/Assets/CivMarsEngine/Player/Player.cs @@ -22,6 +22,7 @@ public class Player : MonoBehaviour, IGasTank, IInventory public int speed; public float miningTime; + public float fullMiningTime; public void Start() { @@ -62,7 +63,7 @@ void Update() if (Input.GetButtonUp("Mine") && (GameCon.gameS == GameState.InGame) && mining == null) { Debug.Log("Mine"); - MineStar(); + StartMine(); } } @@ -106,7 +107,7 @@ public void Mine() } - public void MineStar() + public void StartMine() { TileVector pos = new TileVector((int)Mathf.Round(transform.position.x - 0.5f), -1 * (int)Mathf.Round(transform.position.y + 0.5f)); @@ -120,7 +121,8 @@ public void MineStar() { mining = ore; //GameCon.guiHandler.actions[0].Action(((OreTile)ore).GetMiningTime(), "Mine"); - miningTime = ((OreTile)ore).GetMiningTime(); + fullMiningTime = ((OreTile)ore).GetMiningTime(); + miningTime = fullMiningTime; } } diff --git a/Assets/Prefabs/Buildables/BuildableGui.prefab b/Assets/Prefabs/Buildables/BuildableGui.prefab index 94c0020..3c503a5 100644 Binary files a/Assets/Prefabs/Buildables/BuildableGui.prefab and b/Assets/Prefabs/Buildables/BuildableGui.prefab differ diff --git a/Assets/Prefabs/Inventory/DoubleInventoryElement.prefab b/Assets/Prefabs/Inventory/DoubleInventoryElement.prefab index 0535b04..b656455 100644 Binary files a/Assets/Prefabs/Inventory/DoubleInventoryElement.prefab and b/Assets/Prefabs/Inventory/DoubleInventoryElement.prefab differ diff --git a/Assets/Prefabs/Inventory/InventoryBack.prefab b/Assets/Prefabs/Inventory/InventoryBack.prefab index 781f3a0..100cee9 100644 Binary files a/Assets/Prefabs/Inventory/InventoryBack.prefab and b/Assets/Prefabs/Inventory/InventoryBack.prefab differ diff --git a/Assets/Prefabs/Inventory/InventoryElement.prefab b/Assets/Prefabs/Inventory/InventoryElement.prefab deleted file mode 100644 index eab19c8..0000000 Binary files a/Assets/Prefabs/Inventory/InventoryElement.prefab and /dev/null differ diff --git a/Assets/Prefabs/Inventory/InventoryElement.prefab.meta b/Assets/Prefabs/Inventory/InventoryElement.prefab.meta deleted file mode 100644 index 4b06bcc..0000000 --- a/Assets/Prefabs/Inventory/InventoryElement.prefab.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e39bc89fe3472e34cb67a768f02f25a8 -timeCreated: 1437832058 -licenseType: Free -NativeFormatImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Prefabs/Inventory/PayerInventoryElement.prefab b/Assets/Prefabs/Inventory/PayerInventoryElement.prefab index 81e5017..66c1145 100644 Binary files a/Assets/Prefabs/Inventory/PayerInventoryElement.prefab and b/Assets/Prefabs/Inventory/PayerInventoryElement.prefab differ diff --git a/Assets/Prefabs/PlanedBuilding.prefab b/Assets/Prefabs/PlanedBuilding.prefab index 6dbf6b2..ad65ab9 100644 Binary files a/Assets/Prefabs/PlanedBuilding.prefab and b/Assets/Prefabs/PlanedBuilding.prefab differ diff --git a/Assets/Resources/Buildings/Chest.prefab b/Assets/Resources/Buildings/Chest.prefab index a776c4c..71fdfb9 100644 Binary files a/Assets/Resources/Buildings/Chest.prefab and b/Assets/Resources/Buildings/Chest.prefab differ diff --git a/Assets/Resources/Buildings/Furnance.prefab b/Assets/Resources/Buildings/Furnance.prefab index ba97e43..de785d7 100644 Binary files a/Assets/Resources/Buildings/Furnance.prefab and b/Assets/Resources/Buildings/Furnance.prefab differ diff --git a/Assets/Resources/Buildings/MainBuilding.prefab b/Assets/Resources/Buildings/MainBuilding.prefab index 0c937aa..6d5432c 100644 Binary files a/Assets/Resources/Buildings/MainBuilding.prefab and b/Assets/Resources/Buildings/MainBuilding.prefab differ diff --git a/Assets/Resources/Buildings/Miner.prefab b/Assets/Resources/Buildings/Miner.prefab index 5bb73bb..7c1c18d 100644 Binary files a/Assets/Resources/Buildings/Miner.prefab and b/Assets/Resources/Buildings/Miner.prefab differ diff --git a/Assets/Resources/Buildings/Press.prefab b/Assets/Resources/Buildings/Press.prefab index 8f32d7f..ecdf329 100644 Binary files a/Assets/Resources/Buildings/Press.prefab and b/Assets/Resources/Buildings/Press.prefab differ diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index f4c12e6..20cac6a 100644 Binary files a/Assets/Scenes/Main.unity and b/Assets/Scenes/Main.unity differ diff --git a/Assets/Scenes/TestSceneMain.unity b/Assets/Scenes/TestSceneMain.unity index 3a8cade..4065b93 100644 Binary files a/Assets/Scenes/TestSceneMain.unity and b/Assets/Scenes/TestSceneMain.unity differ diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 3d72c30..48a07e2 100644 Binary files a/ProjectSettings/EditorBuildSettings.asset and b/ProjectSettings/EditorBuildSettings.asset differ