before changing xp system

This commit is contained in:
Sewmina
2022-10-25 01:00:45 +05:30
parent 9175e6740b
commit dd89c3fbb5
58 changed files with 35548 additions and 3589 deletions

View File

@@ -51,11 +51,13 @@ public class Building : MonoBehaviour
}
}
public void Upgrade(int newLevel =-1, int cost =-1){
public void Upgrade(int newLevel =-1, int gold_cost =-1, int metal_cost = -1){
if(curLevel >= buildingData.levels.Count-1){Debug.Log("Already max");return;}
if(cost<0){cost = buildingData.levels[curLevel+1].price;}
Debug.Log("Upgrading " + buildingData.buildingName + " for " + cost + " coins");
if(gold_cost<0){gold_cost = buildingData.levels[curLevel+1].price;}
if(metal_cost<0){metal_cost = buildingData.levels[curLevel+1].metal_price;}
Debug.Log("Upgrading " + buildingData.buildingName + " for " + gold_cost + " coins and " + metal_cost + " energy");
switch (curLevel)
{
@@ -63,11 +65,12 @@ public class Building : MonoBehaviour
case 1: Debug.Log("2 Stars"); break;
}
if(DBmanager.Coins < cost){
if(DBmanager.Coins < gold_cost && DBmanager.Metal < metal_cost){
MessageDialog.instance.ShowMessage("Failed", "Insufficient Resources to complete the transaction");
return;
}
DBmanager.SetCoins(DBmanager.Coins-cost);
DBmanager.SetCoins(DBmanager.Coins- gold_cost);
DBmanager.SetMetal(DBmanager.Metal - metal_cost);
if(newLevel <0){
curLevel = Mathf.Clamp(curLevel+1,0, buildingData.levels.Count-1);
}else{

View File

@@ -60,14 +60,22 @@ public class ChestOpener : MonoBehaviour
if(skinsLucky < chestData.legendaryChance && legendarySkins.Count > 0){
//Legend
selectedSkin = legendarySkins[Random.Range(0,legendarySkins.Count)];
goldCount += 50000;
if(legendarySkins.Count == 0){
goldCount += 50000;
}else{
selectedSkin = legendarySkins[Random.Range(0,legendarySkins.Count)];
}
}else if(skinsLucky < chestData.rareChance && rareSkins.Count > 0){
selectedSkin = rareSkins[Random.Range(0,rareSkins.Count)];
if(rareSkins.Count == 0){
goldCount += 5000;
}else if(baseSkins.Count > 0){
selectedSkin = baseSkins[Random.Range(0,baseSkins.Count)];
}else{
selectedSkin = rareSkins[Random.Range(0,rareSkins.Count)];
}}else if(baseSkins.Count > 0){
if(baseSkins.Count == 0){
goldCount+= 500;
}else{
selectedSkin = baseSkins[Random.Range(0,baseSkins.Count)];
}
}
}

View File

@@ -29,6 +29,9 @@ public class GameManager : MonoBehaviour
public Slider[] levelSliders;
public TMP_Text[] levelProgressTxts;
public TMP_Text[] rankText;
public Image[] rankImages;
// public GameObject loadingScreen;
[Header("Profile")]
@@ -122,6 +125,18 @@ public class GameManager : MonoBehaviour
{
levelProgressTxt.text = $"{DBmanager.Xp}/{DBmanager.XpForNextLevel()}";
}
foreach(TMP_Text rankTxt in rankText){
rankTxt.text = DBmanager.CurrentRank.name;
}
foreach(Image rankImg in rankImages){
rankImg.sprite = DBmanager.CurrentRank.image;
ParticleSystem[] effects = rankImg.transform.parent.parent.GetComponentsInChildren<ParticleSystem>();
foreach(ParticleSystem effect in effects){
effect.startColor = new Color(DBmanager.CurrentRank.color.r,DBmanager.CurrentRank.color.g, DBmanager.CurrentRank.color.b, effect.startColor.a);
}
}
}
public async void LoadMinigame()

View File

@@ -1,33 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GoldMine : MonoBehaviour
{
public static int LevelsCount => levelsCount;
static int levelsCount = 40;
public static int levelsCount => Stats.levels.Length;
public Sprite statIcon;
static int ProductionMultiplier=50;
static int CapacityMultiplier=1000;
static int gold_prod_upgrade_cost = 3000;
static int gold_cap_upgrade_cost = 2500;
public GoldMineData gold_stats;
public static GoldMineData Stats;
// static int ProductionMultiplier=50;
// static int CapacityMultiplier=1000;
// static int gold_prod_upgrade_cost = 3000;
// static int gold_cap_upgrade_cost = 2500;
void Awake()
{ BuildingData data =GetComponent<Building>().buildingData;
{
Stats = gold_stats;
BuildingData data =GetComponent<Building>().buildingData;
data.levels = new List<BuildingLevel>();
data.productinoRates = new float[levelsCount*levelsCount];
Debug.Log($"Gold mine levels combos:{levelsCount}");
for(int i=0; i < levelsCount * levelsCount; i++){
int l = i+1;
int lvl = (i%levelsCount);
int p = GetProductionRateByLevel(l);
int c = GetCapacityRateByLevel(l);
int L = GetLevelByRates(c,p);
List<BuildingStat> stats = new List<BuildingStat>();
stats.Add(new BuildingStat("Gold per hour", (p * ProductionMultiplier).ToString(),statIcon));
stats.Add(new BuildingStat("Capacity", (c * CapacityMultiplier).ToString(),statIcon));
data.levels.Add(new BuildingLevel(l,stats,l*3000));
data.levels[i].xpGain = (i > 0) ? 150 : 0;
data.productinoRates[i] = p * ProductionMultiplier;
Debug.Log($"Level:{l},{L},{lvl} ,Prod:{p}, Capactiy:{c}");
List<BuildingStat> stats = new List<BuildingStat>();
// stats.Add(new BuildingStat("Gold per hour", (p * ProductionMultiplier).ToString(),statIcon));
// stats.Add(new BuildingStat("Capacity", (c * CapacityMultiplier).ToString(),statIcon));
stats.Add(new BuildingStat("Gold per hour", (gold_stats.levels[p-1].Production).ToString(),statIcon));
stats.Add(new BuildingStat("Capacity", (gold_stats.levels[c-1].Capacity).ToString(),statIcon));
data.levels.Add(new BuildingLevel(l,stats,gold_stats.levels[lvl].costGold,gold_stats.levels[lvl].costMetal));
data.levels[i].xpGain = (i > 0) ? 150 : 0;
data.productinoRates[i] = gold_stats.levels[p-1].Production;
// Debug.Log($"Level:{l},{L} ,Prod:{p}, Capactiy:{c}");
}
}
@@ -49,13 +57,25 @@ public class GoldMine : MonoBehaviour
return (levelsCount*Production) + Capacity - levelsCount;
}
public static int GetCostForProduction(int level){
public static int GetGoldCostForProduction(int level){
int Level = GetProductionRateByLevel(level);
return Level*gold_prod_upgrade_cost;
int cost = 0;
try{cost = Stats.levels[Level%levelsCount].costGold;}catch{
Debug.LogError("Error at receiving gold cost for level " + level);
}
return cost;
}
public static int GetCostForCapacity(int level){
public static int GetGoldCostForCapacity(int level){
int Level = GetCapacityRateByLevel(level);
return Level*gold_cap_upgrade_cost;
return Stats.levels[ Level%levelsCount].costGold;
}
public static int GetMetalCostForProduction(int level){
int Level = GetProductionRateByLevel(level);
return Stats.levels[ Level%levelsCount].costMetal;
}
public static int GetMetalCostForCapacity(int level){
int Level = GetCapacityRateByLevel(level);
return Stats.levels[ Level%levelsCount].costMetal;
}
}

View File

@@ -28,6 +28,7 @@ public class LoadingScreen : MonoBehaviour
IEnumerator loadlLevel(string levelName){
AudioManager.instnace.SetMusic(-1);
TutorialManager.instance=null;
loading=true;
canvasGroup.alpha=0;
canvasGroup.blocksRaycasts=true;

View File

@@ -6,9 +6,9 @@ using UnityEngine.SceneManagement;
public class MaintainceChecker : MonoBehaviour
{
public static int version = 8;
public static int version = 10;
public static MaintainceChecker instance;
public int checkInterval = 10;
public int checkInterval = 30;
float t;
void Start()
{

View File

@@ -801,7 +801,9 @@ public class SpaceshipController : NetworkBehaviour
DBmanager.SetMetal(DBmanager.Metal+250);
MinigameManager.instance.rankedSummary.ShowLoss();
DBmanager.SetTrophies(Mathf.Clamp(DBmanager.Trophies - 15, 0, int.MaxValue));
// DBmanager.SetTrophies(Mathf.Clamp(DBmanager.Trophies - 15, 0, int.MaxValue));
DBmanager.SetTrophies(Mathf.Clamp(DBmanager.Trophies - DBmanager.CurrentRank.trophieLoss, 0, int.MaxValue));
}
}

View File

@@ -23,6 +23,7 @@ public class SelectedItemMenu : MonoBehaviour
public GameObject goldmineUpgradeMenu;
public Button btn_gold_prod;
public Button btn_gold_cap;
public Transform upgrade_statParent;
public GameObject[] upgrade_tierIndicators;
public TMP_Text upgrade_buildingName;
@@ -163,23 +164,39 @@ public class SelectedItemMenu : MonoBehaviour
int C = GoldMine.GetCapacityRateByLevel(L);
int P = GoldMine.GetProductionRateByLevel(L);
//Calculate prices
int gold_cost_p = GoldMine.GetGoldCostForProduction(L);
int metal_cost_p = GoldMine.GetMetalCostForProduction(L);
int gold_cost_c = GoldMine.GetGoldCostForCapacity(L);
int metal_cost_c = GoldMine.GetMetalCostForCapacity(L);
if(P>=GoldMine.LevelsCount){
btn_gold_prod.interactable=false;
btn_gold_prod.transform.Find("txt_price").GetComponent<TMP_Text>().text = "Max!";
btn_gold_prod.transform.Find("Price/txt_price").GetComponent<TMP_Text>().text = "Max!";
btn_gold_prod.transform.Find("Price/txt_price_metal").gameObject.SetActive(false);
btn_gold_prod.transform.Find("Price/txt_price").gameObject.SetActive(true);
}
else{
bool affroadable = DBmanager.Coins >= GoldMine.GetCostForProduction(L);
bool affroadable = DBmanager.Coins >= gold_cost_p && DBmanager.Metal >= metal_cost_p;
btn_gold_prod.interactable=affroadable;
btn_gold_prod.transform.Find("txt_price").GetComponent<TMP_Text>().text = GoldMine.GetCostForProduction(L).ToString();
btn_gold_prod.transform.Find("Price/txt_price").GetComponent<TMP_Text>().text = gold_cost_p.ToString();
btn_gold_prod.transform.Find("Price/txt_price_metal").GetComponent<TMP_Text>().text = metal_cost_p.ToString();
btn_gold_prod.transform.Find("Price/txt_price").gameObject.SetActive(gold_cost_p>0);
btn_gold_prod.transform.Find("Price/txt_price_metal").gameObject.SetActive(metal_cost_p>0);
}
if(C>=GoldMine.LevelsCount){
btn_gold_cap.interactable = false;
btn_gold_cap.transform.Find("txt_price").GetComponent<TMP_Text>().text = "Max!";
btn_gold_cap.transform.Find("Price/txt_price").GetComponent<TMP_Text>().text = "Max!";
btn_gold_cap.transform.Find("Price/txt_price_metal").gameObject.SetActive(false);
btn_gold_cap.transform.Find("Price/txt_price").gameObject.SetActive(true);
}
else{
bool affroadable = DBmanager.Coins >= GoldMine.GetCostForCapacity(L);
bool affroadable = DBmanager.Coins >= gold_cost_c && DBmanager.Metal >= metal_cost_c;
btn_gold_cap.interactable=affroadable;
btn_gold_cap.transform.Find("txt_price").GetComponent<TMP_Text>().text = GoldMine.GetCostForCapacity(L).ToString();
btn_gold_cap.transform.Find("Price/txt_price").GetComponent<TMP_Text>().text = gold_cost_c.ToString();
btn_gold_cap.transform.Find("Price/txt_price_metal").GetComponent<TMP_Text>().text = metal_cost_c.ToString();
btn_gold_cap.transform.Find("Price/txt_price").gameObject.SetActive(gold_cost_c > 0);
btn_gold_cap.transform.Find("Price/txt_price_metal").gameObject.SetActive(metal_cost_c > 0);
}
@@ -199,7 +216,7 @@ public class SelectedItemMenu : MonoBehaviour
int newLevel = GoldMine.GetLevelByRates(C + 1, P);
upgradeBtn.interactable= false;
Selector.selectedBuilding.Upgrade(newLevel:newLevel-1, cost:GoldMine.GetCostForCapacity(L) );
Selector.selectedBuilding.Upgrade(newLevel:newLevel-1, gold_cost:GoldMine.GetGoldCostForCapacity(L), metal_cost: GoldMine.GetMetalCostForCapacity(L) );
goldmineUpgradeMenu.SetActive(false);
OnUpgradeMenuClicked();
}
@@ -211,7 +228,7 @@ public class SelectedItemMenu : MonoBehaviour
if(P >=GoldMine.LevelsCount){return;}
int newLevel = GoldMine.GetLevelByRates(C, P+1);
upgradeBtn.interactable= false;
Selector.selectedBuilding.Upgrade(newLevel:newLevel-1, cost: GoldMine.GetCostForProduction(L));
Selector.selectedBuilding.Upgrade(newLevel:newLevel-1, gold_cost: GoldMine.GetGoldCostForProduction(L), metal_cost: GoldMine.GetMetalCostForProduction(L));
goldmineUpgradeMenu.SetActive(false);
OnUpgradeMenuClicked();

View File

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

View File

@@ -44,12 +44,14 @@ public class BuildingLevel{
public int level = 0;
public List<BuildingStat> stats;
public int price = 1000;
public int metal_price =0;
public int xpGain = 100;
public BuildingLevel(int _level, List<BuildingStat> _stats, int _price){
public BuildingLevel(int _level, List<BuildingStat> _stats, int _price, int _metal_price=0){
level = _level;
stats = _stats;
price = _price;
metal_price = _metal_price;
}
}

View File

@@ -10,7 +10,9 @@ using System.Net;
using System.Net.Sockets;
public class DBmanager : MonoBehaviour
{
public static string phpRoot = "http://vmi1005083.contaboserver.net/upf-dev/";
static RankLevel[] rankLevels;
static RankLevel[] RankLevels {get{if(rankLevels==null){return Resources.Load<RankLevels>("ScriptableObjects/RankLevels").levels;}else{return rankLevels;}}}
public static string phpRoot = "http://vmi1005083.contaboserver.net/upf/";
public static string username = null;
public static int userid=0;
@@ -36,6 +38,19 @@ public class DBmanager : MonoBehaviour
public static int Gems => gems;
public static int Metal => metal;
public static int Trophies => trophies;
public static RankLevel CurrentRank {
get{
RankLevel level = RankLevels[0];
foreach(RankLevel lvl in RankLevels){
if(Trophies > lvl.minimumTrophies){
level = lvl;
}else{
break;
}
}
return level;
}}
public static int MostTime=> mostTime;
public static int DoubleKills => doubleKills;
public static int TripleKills => tripleKills;

View File

@@ -1,7 +1,7 @@
using UnityEngine;
[CreateAssetMenu(fileName = "GoldMineStats", menuName = "Game/GoldMineData", order = 1)]
public class SpawnManagerScriptableObject : ScriptableObject
public class GoldMineData : ScriptableObject
{
public GoldMineLevel[] levels;
}

View File

@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class RankLevel{
public string name;
public int minimumTrophies;
public int trophieLoss;
public Sprite image;
public Color color;
}

View File

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

View File

@@ -0,0 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "RankLevels", menuName = "Game/RankLevels", order = 1)]
public class RankLevels : ScriptableObject
{
public RankLevel[] levels;
}

View File

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

View File

@@ -0,0 +1,10 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "XpRewards", menuName = "Game/XpRewards", order = 1)]
public class XPRewards : ScriptableObject
{
public XpPassReward[] rewards;
}

View File

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

View File

@@ -19,7 +19,7 @@ public class TutorialManager : MonoBehaviour
void Start(){
btn_skip.onClick.AddListener(OnSkip);
justRegistered= true; //for testing purpose
// justRegistered= true; //for testing purpose
if(justRegistered){
StartSequence(firstTutorial);
justRegistered =false;

View File

@@ -140,5 +140,6 @@ public class XpPassReward{
public enum XpRewardType{
Gold,
Gems,
Chest
Chest,
Energy
}