Exp Pass done

This commit is contained in:
Sewmina
2022-04-28 02:19:09 +05:30
parent a6ee80997b
commit e89a44d8a1
43 changed files with 1000 additions and 20917 deletions

View File

@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.45073426, g: 0.50068, b: 0.57484144, a: 1}
m_IndirectSpecularColor: {r: 0.45073473, g: 0.500681, b: 0.57484215, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@@ -1688,9 +1688,9 @@ RectTransform:
m_Father: {fileID: 546537819}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 1005.7601, y: -45}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 1005.75995, y: 0}
m_SizeDelta: {x: 0, y: 90}
m_Pivot: {x: 1, y: 0.5}
--- !u!114 &16466549
@@ -13207,14 +13207,14 @@ MonoBehaviour:
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_DisabledColor: {r: 0.31132078, g: 0.31132078, b: 0.31132078, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 21300000, guid: 4983ad09a53d24b98a0b366db3b337d5, type: 3}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_DisabledSprite: {fileID: 21300000, guid: cdcfcaf49f12e4f7e802bcd27badfe23, type: 3}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
@@ -19823,9 +19823,9 @@ RectTransform:
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0.7, y: 1}
m_AnchoredPosition: {x: -109.084, y: 0}
m_SizeDelta: {x: -218.168, y: 0}
m_AnchorMax: {x: 0.59499997, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &179098868
MonoBehaviour:
@@ -24788,7 +24788,7 @@ RectTransform:
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: 0, y: 431.3}
m_SizeDelta: {x: -2237.1208, y: 90.01}
m_SizeDelta: {x: -1557.2, y: 90.01}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &220161863
MonoBehaviour:
@@ -38758,14 +38758,14 @@ MonoBehaviour:
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_DisabledColor: {r: 0.31132078, g: 0.31132078, b: 0.31132078, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 21300000, guid: 4983ad09a53d24b98a0b366db3b337d5, type: 3}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_DisabledSprite: {fileID: 21300000, guid: cdcfcaf49f12e4f7e802bcd27badfe23, type: 3}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
@@ -60053,7 +60053,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: 70, y: 983.3}
m_AnchoredPosition: {x: -662, y: 20.799866}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 1, y: 1}
--- !u!114 &546537820
@@ -61058,8 +61058,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0.7, y: 1}
m_AnchoredPosition: {x: -183.536, y: 0}
m_SizeDelta: {x: -367.071, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &555693600
MonoBehaviour:
@@ -66895,14 +66895,14 @@ MonoBehaviour:
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_DisabledColor: {r: 0.31132078, g: 0.31132078, b: 0.31132078, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 21300000, guid: 4983ad09a53d24b98a0b366db3b337d5, type: 3}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_DisabledSprite: {fileID: 21300000, guid: cdcfcaf49f12e4f7e802bcd27badfe23, type: 3}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
@@ -125638,8 +125638,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0.7, y: 1}
m_AnchoredPosition: {x: -157.535, y: 0}
m_SizeDelta: {x: -315.069, y: 0}
m_AnchoredPosition: {x: -0.00024414062, y: 0}
m_SizeDelta: {x: 0.00048828125, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1145476926
MonoBehaviour:
@@ -128321,14 +128321,14 @@ MonoBehaviour:
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_DisabledColor: {r: 0.31132078, g: 0.31132078, b: 0.31132078, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 21300000, guid: 4983ad09a53d24b98a0b366db3b337d5, type: 3}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_DisabledSprite: {fileID: 21300000, guid: cdcfcaf49f12e4f7e802bcd27badfe23, type: 3}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
@@ -135299,9 +135299,9 @@ RectTransform:
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0.7, y: 1}
m_AnchoredPosition: {x: -66.600006, y: 0}
m_SizeDelta: {x: -133.2, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0.000015258789, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1231816438
MonoBehaviour:
@@ -136391,6 +136391,7 @@ GameObject:
m_Component:
- component: {fileID: 1241721086}
- component: {fileID: 1241721087}
- component: {fileID: 1241721088}
m_Layer: 5
m_Name: Popup_Pass
m_TagString: Untagged
@@ -136432,6 +136433,25 @@ MonoBehaviour:
m_EditorClassIdentifier:
otherPanels:
- {fileID: 1534737055}
--- !u!114 &1241721088
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1241721085}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dbc3a35dffa376ad89b61f8432a8e5a8, type: 3}
m_Name:
m_EditorClassIdentifier:
items:
- {fileID: 1496189945}
- {fileID: 1511044081}
- {fileID: 1211416779}
- {fileID: 370562460}
- {fileID: 623030356}
itemsParent: {fileID: 1166544503}
--- !u!1001 &1242132769
PrefabInstance:
m_ObjectHideFlags: 0
@@ -140255,7 +140275,7 @@ MonoBehaviour:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 21300000, guid: 4983ad09a53d24b98a0b366db3b337d5, type: 3}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_DisabledSprite: {fileID: 21300000, guid: 3c25340b8d13b41da8f115d95f88f43d, type: 3}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
@@ -141113,7 +141133,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchoredPosition: {x: 560.06, y: 0}
m_SizeDelta: {x: 0, y: 90}
m_Pivot: {x: 1, y: 0.5}
--- !u!114 &1293333286
@@ -167401,7 +167421,7 @@ MonoBehaviour:
m_MinValue: 0
m_MaxValue: 10
m_WholeNumbers: 0
m_Value: 7
m_Value: 5.95
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
@@ -178693,7 +178713,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchoredPosition: {x: 313.03, y: 0}
m_SizeDelta: {x: 0, y: 90}
m_Pivot: {x: 1, y: 0.5}
--- !u!114 &1665232126
@@ -194845,7 +194865,7 @@ MonoBehaviour:
m_MinValue: 0
m_MaxValue: 10
m_WholeNumbers: 0
m_Value: 7
m_Value: 10
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
@@ -197782,9 +197802,9 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 300.8, y: -1047.5}
m_AnchoredPosition: {x: 0, y: -85}
m_SizeDelta: {x: 1920, y: 65.05449}
m_Pivot: {x: 0.5, y: 0.5}
m_Pivot: {x: 0, y: 0.5}
--- !u!114 &1840047502
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -207202,7 +207222,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchoredPosition: {x: 1343.7899, y: 0}
m_SizeDelta: {x: 0, y: 90}
m_Pivot: {x: 1, y: 0.5}
--- !u!114 &1934658493

View File

@@ -20,6 +20,7 @@ public class DBmanager : MonoBehaviour
private static int gems = 0;
private static int metal = 0;
private static int oxygen = 0;
private static List<int> expPassCollected = new List<int>();
public static List<BuildingState> buildingStates = new List<BuildingState>();
public static UnityEvent OnStateChanged = new UnityEvent();
@@ -29,6 +30,8 @@ public class DBmanager : MonoBehaviour
public static int Metal => metal;
public static int Oxygen => oxygen;
public static float Level => level;
public static int LevelInt => Mathf.CeilToInt(level);
public static List<int> ExpPassCollected => expPassCollected;
public static bool LoggedIn { get { return username != null; } }
@@ -252,6 +255,60 @@ public class DBmanager : MonoBehaviour
OnStateChanged.Invoke();
}
public static void SetExpPassCollected(string rawData, bool justOffline = false)
{
string[] data = rawData.Split(',');
expPassCollected = new List<int>();
foreach(string item in data){
try{
int itemVal = int.Parse(item);
expPassCollected.Add(itemVal);
}catch {
}
}
GameManagerInstance.gameManager.RefreshData();
OnStateChanged.Invoke();
}
public async static void AddCollectedExpPass(int newPassLevel)
{
expPassCollected.Add(newPassLevel);
string output = "";
for(int i =0;i < expPassCollected.Count;i++){
output += expPassCollected[i].ToString();
if(i < expPassCollected.Count -1){
output += ",";
}
}
WWWForm form = new WWWForm();
form.AddField("name", username);
form.AddField("expPass", output);
using (UnityWebRequest www = UnityWebRequest.Post(phpRoot + "set_expPassCollected.php", form))
{
var operation = www.SendWebRequest();
while (!operation.isDone)
{
await Task.Yield();
}
if (www.downloadHandler.text == "0")
{
Debug.Log("Success updating ExpPassCollected");
}
else
{
Debug.Log("Response : " + www.downloadHandler.text);
Debug.LogWarning("Failed to set exp_pass_collected to " + output);
}
}
GameManagerInstance.gameManager.RefreshData();
OnStateChanged.Invoke();
}
public static bool GetBuildingStates(string rawData)
{
bool success = false;

View File

@@ -0,0 +1,64 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class ExpPass : MonoBehaviour
{
public Transform[] items;
public Transform itemsParent;
[EasyButtons.Button]
void GetItems(){
items = new Transform[itemsParent.childCount];
for(int i =0; i < items.Length; i++){
items[i] = itemsParent.GetChild(i);
}
}
void Start()
{
DBmanager.OnStateChanged.AddListener(RefreshData);
RefreshData();
}
void RefreshData(){
for (int i = 0; i < items.Length; i++){
int curIndex = 0;
curIndex = i;
int expPassLevel = (i +1)* 10;
int expPassReward =(i +1) * 5;
Transform item = items[i];
item.GetChild(1).GetComponent<TMP_Text>().text = "Reach Level " + expPassLevel;
Slider slider = item.GetComponentInChildren<Slider>();
slider.GetComponentInChildren<TMP_Text>().text = DBmanager.LevelInt + " / " + expPassLevel;
slider.minValue=0;
slider.maxValue = expPassLevel;
slider.value = DBmanager.LevelInt;
item.GetComponentInChildren<Button>().interactable = expPassLevel <= DBmanager.LevelInt;
if(expPassLevel <= DBmanager.LevelInt){
item.GetComponentInChildren<Button>().gameObject.SetActive(!DBmanager.ExpPassCollected.Contains(expPassLevel));
}
item.GetComponentInChildren<Button>()?.onClick.AddListener(()=>{CollectExpPass(curIndex);});
// item
}
}
void CollectExpPass(int i){
Debug.Log("Collecting Exp Pass (index: " +i+ ")");
int expPassLevel = (i +1)* 10;
int expPassReward =(i +1) * 5;
if(expPassLevel > DBmanager.LevelInt){
Debug.LogError("Cannot collect, Not enough XP, This should be illegal");
return;
}
DBmanager.AddCollectedExpPass(expPassLevel);
DBmanager.SetGems(DBmanager.Gems + expPassReward);
items[i].GetComponentInChildren<Button>().gameObject.SetActive(false);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dbc3a35dffa376ad89b61f8432a8e5a8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -86,6 +86,7 @@ public class LoginManager : MonoBehaviour
PlayerPrefs.SetString("password", login_password.text);
PlayerPrefs.Save();}
DBmanager.username = login_username.text;
DBmanager.SetExpPassCollected(www.text.Split('\t')[7]);
DBmanager.SetXp(int.Parse(www.text.Split('\t')[6]),true);
DBmanager.GetBuildingStates(www.text.Split('\t')[5]);
DBmanager.SetOxygen(int.Parse(www.text.Split('\t')[4]),true);