Mirror intergrated, WIP on Client Prediction v1

This commit is contained in:
Sewmina
2022-06-14 01:57:42 +05:30
parent 4435d769a6
commit cdaa627f52
14571 changed files with 4207871 additions and 4127496 deletions

View File

@@ -1,51 +1,51 @@
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class CollectBtn : MonoBehaviour
{
public DateTime lastCollected;
public string buildingId;
public float productionRate;
public double collectableAmount;
public Button btn;
public TMP_Text txt;
public CollectablesData.ResourceType resourceType;
void Start(){
btn.onClick.AddListener(OnClick);
}
void Update()
{
collectableAmount=((DateTime.UtcNow - lastCollected).TotalSeconds * productionRate);
txt.text = ((int)collectableAmount).ToString();
btn.interactable = collectableAmount > 1;
}
public void Set(string id,DateTime _lastCollected, float _productionRate, CollectablesData.ResourceType _resourceType){
buildingId = id;
lastCollected = _lastCollected;
productionRate=_productionRate;
resourceType = _resourceType;
}
async void OnClick(){
collectableAmount=((DateTime.Now - lastCollected).TotalSeconds * productionRate);
lastCollected = await DBmanager.GetNetworkTime();
switch (resourceType){
case CollectablesData.ResourceType.Metal:
DBmanager.SetMetal(DBmanager.Metal + (int)collectableAmount);
break;
case CollectablesData.ResourceType.Oxygen:
DBmanager.SetOxygen(DBmanager.Oxygen + (int)collectableAmount);
break;
}
DBmanager.CollectBuilding(buildingId);
}
}
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class CollectBtn : MonoBehaviour
{
public DateTime lastCollected;
public string buildingId;
public float productionRate;
public double collectableAmount;
public Button btn;
public TMP_Text txt;
public CollectablesData.ResourceType resourceType;
void Start(){
btn.onClick.AddListener(OnClick);
}
void Update()
{
collectableAmount=((DateTime.UtcNow - lastCollected).TotalSeconds * productionRate);
txt.text = ((int)collectableAmount).ToString();
btn.interactable = collectableAmount > 1;
}
public void Set(string id,DateTime _lastCollected, float _productionRate, CollectablesData.ResourceType _resourceType){
buildingId = id;
lastCollected = _lastCollected;
productionRate=_productionRate;
resourceType = _resourceType;
}
async void OnClick(){
collectableAmount=((DateTime.Now - lastCollected).TotalSeconds * productionRate);
lastCollected = await DBmanager.GetNetworkTime();
switch (resourceType){
case CollectablesData.ResourceType.Metal:
DBmanager.SetMetal(DBmanager.Metal + (int)collectableAmount);
break;
case CollectablesData.ResourceType.Oxygen:
DBmanager.SetOxygen(DBmanager.Oxygen + (int)collectableAmount);
break;
}
DBmanager.CollectBuilding(buildingId);
}
}