trade & sell UI added

This commit is contained in:
Sewmina Dilshan 2022-05-17 11:36:24 +05:30
parent 58f7212434
commit a3aba776a5
25 changed files with 22513 additions and 635 deletions

File diff suppressed because it is too large Load Diff

View File

@ -46619,7 +46619,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 50, y: 190}
m_AnchoredPosition: {x: 49.99994, y: 190}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &386684401
@ -64207,11 +64207,11 @@ RectTransform:
m_Father: {fileID: 1840047501}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -610.64, y: 20.799866}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: -85, y: 20.799843}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 1, y: 1}
m_Pivot: {x: 0, y: 1}
--- !u!114 &546537820
MonoBehaviour:
m_ObjectHideFlags: 0
@ -64243,7 +64243,7 @@ MonoBehaviour:
m_Right: 0
m_Top: 0
m_Bottom: 0
m_ChildAlignment: 4
m_ChildAlignment: 3
m_Spacing: 27.89
m_ChildForceExpandWidth: 0
m_ChildForceExpandHeight: 0
@ -212563,7 +212563,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -85}
m_AnchoredPosition: {x: 0.00018310547, y: -85}
m_SizeDelta: {x: 1920, y: 65.05449}
m_Pivot: {x: 0, y: 0.5}
--- !u!114 &1840047502

View File

@ -21,7 +21,7 @@ public class CollectBtn : MonoBehaviour
void Update()
{
collectableAmount=((DateTime.Now - lastCollected).TotalSeconds * productionRate);
collectableAmount=((DateTime.UtcNow - lastCollected).TotalSeconds * productionRate);
txt.text = ((int)collectableAmount).ToString();
btn.interactable = collectableAmount > 1;
@ -34,9 +34,9 @@ public class CollectBtn : MonoBehaviour
resourceType = _resourceType;
}
void OnClick(){
async void OnClick(){
collectableAmount=((DateTime.Now - lastCollected).TotalSeconds * productionRate);
lastCollected = DBmanager.GetNetworkTime();
lastCollected = await DBmanager.GetNetworkTime();
switch (resourceType){
case CollectablesData.ResourceType.Metal:
DBmanager.SetMetal(DBmanager.Metal + (int)collectableAmount);

View File

@ -40,8 +40,27 @@ public class DBmanager : MonoBehaviour
username = null;
}
public static DateTime GetNetworkTime()
public static async Task<DateTime> GetNetworkTime()
{
int unixTime = 0;
using (UnityWebRequest www = UnityWebRequest.Get(phpRoot + "get_time.php"))
{
var operation = www.SendWebRequest();
while (!operation.isDone)
{
await Task.Yield();
}
try{
unixTime = int.Parse(www.downloadHandler.text);
}catch{
Debug.Log("Invalid response from server : " + www.downloadHandler.text);
}
}
if(unixTime> 0){
return DateTimeOffset.FromUnixTimeSeconds(unixTime).UtcDateTime;
}
//default Windows time server
const string ntpServer = "time.windows.com";
@ -352,7 +371,7 @@ public class DBmanager : MonoBehaviour
}
}
Debug.Log("adding new building " + buildingData.buildingName);
buildingStates.Add(new BuildingState(buildingData.buildingName, 0, Vector3.zero, GetNetworkTime()));
buildingStates.Add(new BuildingState(buildingData.buildingName, 0, Vector3.zero,await GetNetworkTime()));
Debug.Log("Added new building " + buildingData.buildingName);
await UpdateBuildingsToServer();
OnStateChanged.Invoke();
@ -383,7 +402,7 @@ public class DBmanager : MonoBehaviour
{
if (buildingStates[i].id == id)
{
buildingStates[i].lastCollectedTimestamp = GetNetworkTime();
buildingStates[i].lastCollectedTimestamp = await GetNetworkTime();
Debug.Log("Setting " + id + " last collected to " + buildingStates[i].lastCollectedTimestamp);
break;
}

View File

@ -12,35 +12,16 @@ public class LevelScriptEditor : Editor
DrawDefaultInspector();
OptimizeMesh myTarget = (OptimizeMesh)target;
if (GUILayout.Button("Optimize Mesh!"))
{
myTarget.DecimateMesh();
}
if (GUILayout.Button("Save Mesh!"))
{
myTarget.SaveMesh();
}
if(GUILayout.Button("! Optimize All !")){
OptimizeMesh[] targets = FindObjectsOfType<OptimizeMesh>();
int passed = 0;
foreach(OptimizeMesh target in targets){
target.DecimateMesh();
passed++;
}
Debug.Log("Optimized " + passed + " meshes");
}
if(GUILayout.Button("! RESET ALL !")){
OptimizeMesh[] targets = FindObjectsOfType<OptimizeMesh>();
foreach(OptimizeMesh target in targets){
target._quality = 1;
target.DecimateMesh();
}
if (GUILayout.Button("Optimize Mesh!"))
{
myTarget.DecimateMesh();
}
if (GUILayout.Button("Save Mesh!"))
{
myTarget.SaveMesh();
}
}
}
#endif
@ -48,7 +29,7 @@ public class LevelScriptEditor : Editor
public class OptimizeMesh : MonoBehaviour
{
[Range(0.0f, 1.0f)]
[SerializeField]public float _quality = 0.5f;
[SerializeField] float _quality = 0.5f;
MeshFilter _renderer;
Mesh _mesh;
void Start()

View File

@ -0,0 +1 @@
{"androidStore":"GooglePlay"}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 111e76e8746773d4ea6f6187c9799149
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/Scenes.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 546380dace381864da4b30b5110c470f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: aa2c4b95443ede4459b55e825ec55423
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: cc829113ef4933442981e1f9d7c7c050
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: aa41ce05b046aad47b997268ff730a86
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 00be8b17ed8cd3a4d8111c5d4641b1d7
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 77dcbfc5948a10749b20c0084a9f7cab
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -19,16 +19,23 @@
"dependencies": {
"com.consulo.ide": "https://github.com/consulo/UnityEditorConsuloPlugin.git#2.6.0",
"com.madsbangh.easybuttons": "1.3.0",
"com.unity.2d.sprite": "1.0.0",
"com.unity.2d.tilemap": "1.0.0",
"com.unity.ads": "3.7.5",
"com.unity.analytics": "3.6.12",
"com.unity.collab-proxy": "1.15.16",
"com.unity.ide.rider": "2.0.7",
"com.unity.ide.visualstudio": "2.0.14",
"com.unity.ide.vscode": "1.2.5",
"com.unity.performance.profile-analyzer": "1.1.1",
"com.unity.purchasing": "4.1.3",
"com.unity.render-pipelines.universal": "10.9.0",
"com.unity.test-framework": "1.1.31",
"com.unity.textmeshpro": "3.0.6",
"com.unity.timeline": "1.4.8",
"com.unity.toolchain.linux-x86_64": "2.0.1",
"com.unity.ugui": "1.0.0",
"com.unity.xr.legacyinputhelpers": "2.1.9",
"com.whinarn.unitymeshsimplifier": "https://github.com/Whinarn/UnityMeshSimplifier.git",
"jillejr.newtonsoft.json-for-unity": "12.0.302",
"jillejr.newtonsoft.json-for-unity.converters": "1.3.0",

View File

@ -14,6 +14,36 @@
"dependencies": {},
"url": "https://package.openupm.com"
},
"com.unity.2d.sprite": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.2d.tilemap": {
"version": "1.0.0",
"depth": 0,
"source": "builtin",
"dependencies": {}
},
"com.unity.ads": {
"version": "3.7.5",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.ugui": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.analytics": {
"version": "3.6.12",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.ugui": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.collab-proxy": {
"version": "1.15.16",
"depth": 0,
@ -30,6 +60,15 @@
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.ide.rider": {
"version": "2.0.7",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.test-framework": "1.1.1"
},
"url": "https://packages.unity.com"
},
"com.unity.ide.visualstudio": {
"version": "2.0.14",
"depth": 0,
@ -60,6 +99,20 @@
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.purchasing": {
"version": "4.1.3",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.ugui": "1.0.0",
"com.unity.modules.unityanalytics": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.services.core": "1.0.1"
},
"url": "https://packages.unity.com"
},
"com.unity.render-pipelines.core": {
"version": "10.9.0",
"depth": 1,
@ -175,6 +228,16 @@
"com.unity.modules.imgui": "1.0.0"
}
},
"com.unity.xr.legacyinputhelpers": {
"version": "2.1.9",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.modules.vr": "1.0.0",
"com.unity.modules.xr": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.whinarn.unitymeshsimplifier": {
"version": "https://github.com/Whinarn/UnityMeshSimplifier.git",
"depth": 0,

View File

@ -0,0 +1,15 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &1
MonoBehaviour:
m_ObjectHideFlags: 61
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a287be6c49135cd4f9b2b8666c39d999, type: 3}
m_Name:
m_EditorClassIdentifier:
assetDefaultFramerate: 60

24
UPF.sln
View File

@ -1,31 +1,19 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "Assembly-CSharp.csproj", "{f8f3d981-3ac9-a8b7-ea43-2868619efe2a}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "Assembly-CSharp.csproj", "{d2fa7125-b336-b292-eceb-bf1e731b3f48}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Whinarn.UnityMeshSimplifier.Runtime", "Whinarn.UnityMeshSimplifier.Runtime.csproj", "{b99ffb8c-f6f2-f646-802e-7cb2e62d8c0c}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.com.consulo.ide.Editor", "Unity.com.consulo.ide.Editor.csproj", "{f3918ae7-b834-5fa8-e000-01833c449c8e}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Whinarn.UnityMeshSimplifier.Editor", "Whinarn.UnityMeshSimplifier.Editor.csproj", "{9c3e4793-780d-e333-1ec5-d5e17feec6f2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-Editor", "Assembly-CSharp-Editor.csproj", "{20764e99-32a2-613b-c7bd-2b420a48759f}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-Editor", "Assembly-CSharp-Editor.csproj", "{11a3099b-b691-e713-f90d-1e4ea21c7a4c}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{f8f3d981-3ac9-a8b7-ea43-2868619efe2a}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{f8f3d981-3ac9-a8b7-ea43-2868619efe2a}.Debug|Any CPU.Build.0 = Debug|Any CPU
{b99ffb8c-f6f2-f646-802e-7cb2e62d8c0c}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{b99ffb8c-f6f2-f646-802e-7cb2e62d8c0c}.Debug|Any CPU.Build.0 = Debug|Any CPU
{f3918ae7-b834-5fa8-e000-01833c449c8e}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{f3918ae7-b834-5fa8-e000-01833c449c8e}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9c3e4793-780d-e333-1ec5-d5e17feec6f2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9c3e4793-780d-e333-1ec5-d5e17feec6f2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{20764e99-32a2-613b-c7bd-2b420a48759f}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{20764e99-32a2-613b-c7bd-2b420a48759f}.Debug|Any CPU.Build.0 = Debug|Any CPU
{d2fa7125-b336-b292-eceb-bf1e731b3f48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{d2fa7125-b336-b292-eceb-bf1e731b3f48}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11a3099b-b691-e713-f90d-1e4ea21c7a4c}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{11a3099b-b691-e713-f90d-1e4ea21c7a4c}.Debug|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -1,4 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]