Tutorial start
This commit is contained in:
@@ -21,6 +21,7 @@ public class AudioManager : MonoBehaviour
|
||||
[SerializeField]private AudioClip pickupCollected;
|
||||
[SerializeField]private AudioClip minigameVictory;
|
||||
[SerializeField]private AudioClip minigameFailed;
|
||||
[SerializeField]private AudioClip[] typewriters;
|
||||
|
||||
|
||||
|
||||
@@ -109,4 +110,8 @@ public class AudioManager : MonoBehaviour
|
||||
public void MinigameLost(){
|
||||
audioSrc.PlayOneShot(minigameFailed);
|
||||
}
|
||||
|
||||
public void TypeWriter(){
|
||||
audioSrc.PlayOneShot(typewriters[Random.Range(0, typewriters.Length)],0.7f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,10 @@ public class Building : MonoBehaviour
|
||||
case 1: Debug.Log("2 Stars"); break;
|
||||
}
|
||||
|
||||
|
||||
if(DBmanager.Coins < cost){
|
||||
MessageDialog.instance.ShowMessage("Failed", "Insufficient Resources to complete the transaction");
|
||||
return;
|
||||
}
|
||||
DBmanager.SetCoins(DBmanager.Coins-cost);
|
||||
if(newLevel <0){
|
||||
curLevel = Mathf.Clamp(curLevel+1,0, buildingData.levels.Count-1);
|
||||
|
||||
@@ -75,12 +75,7 @@ public class ChestOpener : MonoBehaviour
|
||||
|
||||
if(selectedSkin!=null){
|
||||
skinDrop.transform.GetChild(1).GetComponent<Image>().sprite = selectedSkin.image;
|
||||
Color bgColor = new Color(0,1,0);
|
||||
if(rareSkins.Contains(selectedSkin)){
|
||||
bgColor = new Color(0,1,1);
|
||||
}else if(legendarySkins.Contains(selectedSkin)){
|
||||
bgColor = new Color(1,0,0);
|
||||
}
|
||||
Color bgColor = SkinShopManager.getRarityColor(selectedSkin);
|
||||
|
||||
skinBgParticle.startColor = new Color(bgColor.r,bgColor.g,bgColor.b, skinBgParticle.startColor.a);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class CollectBtn : MonoBehaviour
|
||||
resourceType = _resourceType;
|
||||
}
|
||||
|
||||
async void OnClick(){
|
||||
public async void OnClick(){
|
||||
collectableAmount= GetCollectableGold();
|
||||
lastCollected = await DBmanager.GetNetworkTime();
|
||||
switch (resourceType){
|
||||
|
||||
16
Assets/Game/Scripts/CutoutMaskUI.cs
Normal file
16
Assets/Game/Scripts/CutoutMaskUI.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
public class CutoutMaskUI : Image
|
||||
{
|
||||
public override Material materialForRendering{
|
||||
get{
|
||||
Material material = new Material(base.materialForRendering);
|
||||
material.SetInt("_StencilComp", (int)CompareFunction.NotEqual);
|
||||
return material;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Game/Scripts/CutoutMaskUI.cs.meta
Normal file
11
Assets/Game/Scripts/CutoutMaskUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 448373c5b90f871059fe30b040c7c888
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -545,7 +545,7 @@ public class DBmanager : MonoBehaviour
|
||||
}
|
||||
SetMetal(metal-data.price);
|
||||
AddSkin(data);
|
||||
AudioManager.instnace.Spend();
|
||||
AudioManager.instnace.ChestOpen();
|
||||
}
|
||||
|
||||
public static void AddSkin(SkinShopItemData data){
|
||||
|
||||
@@ -4,32 +4,57 @@ using UnityEngine;
|
||||
|
||||
public class GoldMine : MonoBehaviour
|
||||
{
|
||||
static int LevelsCount = 40;
|
||||
void Start()
|
||||
{
|
||||
for(int i=0; i < LevelsCount * LevelsCount; i++){
|
||||
public static int LevelsCount => levelsCount;
|
||||
static int levelsCount = 40;
|
||||
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;
|
||||
void Awake()
|
||||
{ BuildingData data =GetComponent<Building>().buildingData;
|
||||
data.levels = new List<BuildingLevel>();
|
||||
data.productinoRates = new float[levelsCount*levelsCount];
|
||||
for(int i=0; i < levelsCount * levelsCount; i++){
|
||||
int l = i+1;
|
||||
int p = GetProductionRateByLevel(l);
|
||||
int c = GetCapacityRateByLevel(l);
|
||||
int L = GetLevelByRates(c,p);
|
||||
Debug.Log($"Level:{l},{L} ,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));
|
||||
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} ,Prod:{p}, Capactiy:{c}");
|
||||
}
|
||||
|
||||
}
|
||||
//Note for future me: Refer to the sketch you draw on laptop to understand below equations
|
||||
public static int GetProductionRateByLevel(int level){
|
||||
//P = L - C - (2l-3)
|
||||
int l = Mathf.CeilToInt((float)level/(float)LevelsCount);
|
||||
int l = Mathf.CeilToInt((float)level/(float)levelsCount);
|
||||
return l;
|
||||
}
|
||||
|
||||
public static int GetCapacityRateByLevel(int level){
|
||||
//C = L -3(l - 1)
|
||||
int l = Mathf.CeilToInt((float)level/(float)LevelsCount);
|
||||
return level - LevelsCount * (l - 1);
|
||||
int l = Mathf.CeilToInt((float)level/(float)levelsCount);
|
||||
return level - levelsCount * (l - 1);
|
||||
}
|
||||
|
||||
public static int GetLevelByRates(int Capacity, int Production){
|
||||
//L = 3P + C -3
|
||||
return (LevelsCount*Production) + Capacity - LevelsCount;
|
||||
return (levelsCount*Production) + Capacity - levelsCount;
|
||||
}
|
||||
|
||||
public static int GetCostForProduction(int level){
|
||||
int Level = GetProductionRateByLevel(level);
|
||||
return Level*gold_prod_upgrade_cost;
|
||||
}
|
||||
public static int GetCostForCapacity(int level){
|
||||
int Level = GetCapacityRateByLevel(level);
|
||||
return Level*gold_cap_upgrade_cost;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ public class LoginManager : MonoBehaviour
|
||||
|
||||
// public OtherUIbuttons otherUI;
|
||||
public BuildingData defaultBuilding;
|
||||
public GameObject loadingScreen;
|
||||
|
||||
void Start()
|
||||
{
|
||||
@@ -66,6 +67,7 @@ public class LoginManager : MonoBehaviour
|
||||
IEnumerator LoginPlayer()
|
||||
{
|
||||
loginBtn.interactable=false;
|
||||
loadingScreen.SetActive(true);
|
||||
WWWForm form = new WWWForm();
|
||||
form.AddField("name", login_username.text);
|
||||
form.AddField("password", login_password.text);
|
||||
@@ -102,18 +104,24 @@ public class LoginManager : MonoBehaviour
|
||||
Debug.Log("XP : " + DBmanager.Xp);
|
||||
|
||||
UnityEngine.SceneManagement.SceneManager.LoadScene("GameScene");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("User Login failed. Error #" + www.text);
|
||||
MessageDialog.instance.ShowMessage("Error!", "Sorry, We couldn't log you in,\n Error: " + www.text);
|
||||
loadingScreen.SetActive(false);
|
||||
|
||||
}
|
||||
loginBtn.interactable=true;
|
||||
|
||||
}
|
||||
|
||||
IEnumerator Register()
|
||||
{
|
||||
regBtn.interactable = false;
|
||||
loadingScreen.SetActive(true);
|
||||
|
||||
WWWForm form = new WWWForm();
|
||||
form.AddField("name", reg_username.text);
|
||||
form.AddField("password", reg_password.text);
|
||||
@@ -128,14 +136,22 @@ public class LoginManager : MonoBehaviour
|
||||
PlayerPrefs.Save();
|
||||
DBmanager.username = reg_username.text;
|
||||
DBmanager.AddBuilding(defaultBuilding);
|
||||
UnityEngine.SceneManagement.SceneManager.LoadScene("GameScene");
|
||||
// UnityEngine.SceneManagement.SceneManager.LoadScene("GameScene");
|
||||
login_username.text = reg_username.text;
|
||||
login_password.text = reg_password.text;
|
||||
TutorialManager.justRegistered =true;
|
||||
StartCoroutine(LoginPlayer());
|
||||
// loadingScreen.SetActive(false);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("User creation failed " + www.text);
|
||||
MessageDialog.instance.ShowMessage("Error!", "Sorry, We couldn't Register you,\n Error: " + www.text);
|
||||
loadingScreen.SetActive(false);
|
||||
|
||||
}
|
||||
regBtn.interactable=true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using UnityEngine.SceneManagement;
|
||||
|
||||
public class MaintainceChecker : MonoBehaviour
|
||||
{
|
||||
public static int version = 2;
|
||||
public static int version = 8;
|
||||
public static MaintainceChecker instance;
|
||||
public int checkInterval = 10;
|
||||
float t;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
public class SkinShopItem : MonoBehaviour
|
||||
@@ -8,19 +9,27 @@ public class SkinShopItem : MonoBehaviour
|
||||
[Tooltip("In order of: normal, rare, legendary. 3 items required")]
|
||||
public GameObject[] banners;
|
||||
public Image frame;
|
||||
public bool Available;
|
||||
public GameObject notPurchasedIndicator;
|
||||
public SkinShopItemData skinData;
|
||||
|
||||
public void Set(SkinShopItemData data){
|
||||
public void Set(SkinShopItemData data, bool available){
|
||||
skinData = data;
|
||||
// newItem.backgroundImg.color = (skinsData.skins[i].skinType==SkinType.Base) ? basicColor : (skinsData.skins[i].skinType==SkinType.Rare ? rareColor : legendaryColor);
|
||||
spaceshipImg.sprite = data.image;
|
||||
|
||||
if(available){spaceshipImg.sprite = data.image;}
|
||||
spaceshipImg.color = available ? Color.white : Color.black;
|
||||
Available = available;
|
||||
UpdateFrame();
|
||||
|
||||
banners[0].SetActive(data.skinType== SkinType.Base);
|
||||
banners[1].SetActive(data.skinType== SkinType.Rare);
|
||||
banners[2].SetActive(data.skinType== SkinType.Legendary);
|
||||
if(data.price <=0){
|
||||
banners[0].SetActive(true);
|
||||
banners[1].SetActive(false);
|
||||
}else{
|
||||
banners[0].SetActive(false);
|
||||
banners[1].SetActive(data.skinType== SkinType.Base);
|
||||
}
|
||||
banners[2].SetActive(data.skinType== SkinType.Rare);
|
||||
banners[3].SetActive(data.skinType== SkinType.Legendary);
|
||||
|
||||
|
||||
}
|
||||
@@ -36,13 +45,17 @@ public class SkinShopItem : MonoBehaviour
|
||||
if(!DBmanager.SkinsPurchased.Contains(skinData.name)){
|
||||
frame.color = Color.red;
|
||||
notPurchasedIndicator.SetActive(true);
|
||||
notPurchasedIndicator.GetComponentInChildren<TMP_Text>().text = skinData.price.ToString();
|
||||
}else{
|
||||
notPurchasedIndicator.SetActive(false);
|
||||
}
|
||||
if(!Available){
|
||||
notPurchasedIndicator.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClick(){
|
||||
SkinShopManager.instance.SelectItem(skinData);
|
||||
SkinShopManager.instance.SelectItem(skinData,Available);
|
||||
}
|
||||
public void OnSelectionChanged(string selectedItem){
|
||||
if(selectedItem == skinData.name){
|
||||
|
||||
@@ -8,6 +8,8 @@ using UnityEngine.UI;
|
||||
public class SkinShopManager : MonoBehaviour
|
||||
{
|
||||
public static SkinShopManager instance;
|
||||
public static bool availableToUpgrade;
|
||||
public NewSkinDisplay newSkinDisplay;
|
||||
public Building skinShopBuilding;
|
||||
public SkinsData skinsData;
|
||||
public GameObject popup;
|
||||
@@ -17,6 +19,8 @@ public class SkinShopManager : MonoBehaviour
|
||||
public Button btn_Equip;
|
||||
public Button btn_Buy;
|
||||
public static SkinShopItemData selectedSkin;
|
||||
public int[] prices;
|
||||
public static int[] Prices => instance.prices;
|
||||
List<SkinShopItem> skinShopItems=new List<SkinShopItem>();
|
||||
|
||||
void Awake() {
|
||||
@@ -34,8 +38,11 @@ public class SkinShopManager : MonoBehaviour
|
||||
Populate();
|
||||
popup.SetActive(true);
|
||||
}
|
||||
|
||||
List<SkinShopItemData> skinsAvailableToPurchase= new List<SkinShopItemData>();
|
||||
public void Populate(){
|
||||
int purchasedFlagships=0;
|
||||
int flagshipsCount=0;
|
||||
|
||||
//Validate skins list
|
||||
if(DBmanager.SkinsPurchased.Count <=0){
|
||||
foreach(SkinShopItemData skin in skinsData.skins){
|
||||
@@ -52,25 +59,57 @@ public class SkinShopManager : MonoBehaviour
|
||||
for(int i=0;i < listItemsParent.childCount;i++){
|
||||
Destroy(listItemsParent.GetChild(i).gameObject);
|
||||
}
|
||||
skinsAvailableToPurchase = new List<SkinShopItemData>();
|
||||
skinShopItems = new List<SkinShopItem>();
|
||||
for(int i=0; i<skinsData.skins.Length;i++){
|
||||
int rarity = 0;
|
||||
if(skinsData.skins[i].skinType == SkinType.Rare){rarity=1;}
|
||||
if(skinsData.skins[i].skinType == SkinType.Legendary){rarity=2;}
|
||||
int rarity = getRarityInt(skinsData.skins[i]);
|
||||
bool isAvailable = skinShopBuilding.curLevel >= rarity;
|
||||
if(!isAvailable){continue;}
|
||||
|
||||
if(skinShopBuilding.curLevel < rarity){
|
||||
continue;
|
||||
bool isOwned = DBmanager.SkinsPurchased.Contains(skinsData.skins[i].name);
|
||||
|
||||
|
||||
if(skinShopBuilding.curLevel == rarity){
|
||||
flagshipsCount++;
|
||||
if(isOwned){
|
||||
purchasedFlagships++;
|
||||
}
|
||||
}
|
||||
SkinShopItem newItem = Instantiate(listItemPrefab, listItemsParent).GetComponent<SkinShopItem>();
|
||||
newItem.Set(skinsData.skins[i]);
|
||||
skinShopItems.Add(newItem);
|
||||
|
||||
if(!isOwned){
|
||||
skinsAvailableToPurchase.Add(skinsData.skins[i]);
|
||||
}else{
|
||||
SkinShopItem newItem = Instantiate(listItemPrefab, listItemsParent).GetComponent<SkinShopItem>();
|
||||
|
||||
newItem.Set(skinsData.skins[i],isOwned);
|
||||
skinShopItems.Add(newItem);
|
||||
}
|
||||
|
||||
|
||||
// newItem.backgroundImg.color = (skinsData.skins[i].skinType==SkinType.Base) ? basicColor : (skinsData.skins[i].skinType==SkinType.Rare ? rareColor : legendaryColor);
|
||||
}
|
||||
Debug.Log("Question ships: " +skinsAvailableToPurchase.Count);
|
||||
foreach(SkinShopItemData skin in skinsAvailableToPurchase){
|
||||
int rarity = getRarityInt(skin);
|
||||
SkinShopItem newItem = Instantiate(listItemPrefab, listItemsParent).GetComponent<SkinShopItem>();
|
||||
newItem.Set(skin,false);
|
||||
skinShopItems.Add(newItem);
|
||||
}
|
||||
|
||||
SelectItem(selectedSkin);
|
||||
availableToUpgrade = purchasedFlagships >= ((float)flagshipsCount/2f);
|
||||
|
||||
SelectItem(selectedSkin,true);
|
||||
}
|
||||
|
||||
public void SelectItem(SkinShopItemData data){
|
||||
int getRarityInt(SkinShopItemData skin){
|
||||
int rarity = 0;
|
||||
if(skin.skinType == SkinType.Rare){rarity=1;}
|
||||
if(skin.skinType == SkinType.Legendary){rarity=2;}
|
||||
|
||||
return rarity;
|
||||
}
|
||||
|
||||
public void SelectItem(SkinShopItemData data, bool Available){
|
||||
selectedSkin = data;
|
||||
if(data==null){
|
||||
btn_Equip.gameObject.SetActive(false); btn_Buy.gameObject.SetActive(false);
|
||||
@@ -99,10 +138,24 @@ public class SkinShopManager : MonoBehaviour
|
||||
Populate();
|
||||
}
|
||||
|
||||
void onBuy(){
|
||||
DBmanager.PurchaseSkin(selectedSkin);
|
||||
public void EquipSkin(SkinShopItemData skin){
|
||||
EquipSkin(skin.name);
|
||||
Populate();
|
||||
}
|
||||
|
||||
void onBuy(){
|
||||
List<SkinShopItemData> skinsInSameRarity = new List<SkinShopItemData>();
|
||||
foreach(SkinShopItemData skin in skinsAvailableToPurchase){
|
||||
if(skin.skinType == selectedSkin.skinType){
|
||||
skinsInSameRarity.Add(skin);
|
||||
}
|
||||
}
|
||||
|
||||
SkinShopItemData randomSkin = skinsInSameRarity[UnityEngine.Random.Range(0,skinsInSameRarity.Count)];
|
||||
|
||||
DBmanager.PurchaseSkin(randomSkin);
|
||||
SkinShopManager.instance.Populate();
|
||||
newSkinDisplay.Show(randomSkin);
|
||||
}
|
||||
|
||||
public static void EquipSkin(string skin){
|
||||
@@ -117,6 +170,17 @@ public class SkinShopManager : MonoBehaviour
|
||||
|
||||
return "Default";
|
||||
}
|
||||
|
||||
public static Color getRarityColor(SkinShopItemData skin){
|
||||
Color color = new Color(0,1,0);
|
||||
if(skin.skinType == SkinType.Rare){
|
||||
color = new Color(0,1,1);
|
||||
}else if(skin.skinType == SkinType.Legendary){
|
||||
color = new Color(1,0,0);
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
||||
@@ -21,6 +21,8 @@ public class SpaceshipController : NetworkBehaviour
|
||||
public int Kills;
|
||||
[SyncVar(hook = nameof(OnTrailTimeChanged))]
|
||||
public float trailTime;
|
||||
public float minTrailTime;
|
||||
public float maxTrailTime;
|
||||
[SyncVar]
|
||||
public int moonsCollected;
|
||||
public float trailIncrementRate = 0.5f;
|
||||
@@ -102,8 +104,9 @@ public class SpaceshipController : NetworkBehaviour
|
||||
trailMgr.trail.time = newValue;
|
||||
if (isLocalPlayer)
|
||||
{
|
||||
SceneData.holder.boostBtn.gameObject.SetActive(scale > 1);
|
||||
if(scale <=1 && boosting){
|
||||
bool isBoostAvailable= trailTime > minTrailTime;
|
||||
SceneData.holder.boostBtn.gameObject.SetActive(isBoostAvailable);
|
||||
if(!isBoostAvailable&& boosting){
|
||||
CmdSetBoosting(false);
|
||||
}
|
||||
}
|
||||
@@ -195,6 +198,8 @@ public class SpaceshipController : NetworkBehaviour
|
||||
if (isServer)
|
||||
{
|
||||
startedTime = NetworkTime.time;
|
||||
trailTime =0;
|
||||
DecreaseTrail(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -546,14 +551,14 @@ public class SpaceshipController : NetworkBehaviour
|
||||
|
||||
void IncreaseTrail(float rate)
|
||||
{
|
||||
trailTime = trailMgr.trail.time + rate;
|
||||
trailTime = Mathf.Clamp(trailMgr.trail.time + rate,minTrailTime,maxTrailTime);
|
||||
trailMgr.trail.time = trailTime;
|
||||
// Debug.Log("Increasing trail of" + pname);
|
||||
}
|
||||
|
||||
public void DecreaseTrail(float rate)
|
||||
{
|
||||
trailTime = Mathf.Clamp(trailMgr.trail.time - rate,0,float.MaxValue);
|
||||
trailTime = Mathf.Clamp(trailMgr.trail.time - rate,minTrailTime,maxTrailTime);
|
||||
trailMgr.trail.time = trailTime;
|
||||
// Debug.Log("Decreasing trail of" + pname);
|
||||
}
|
||||
@@ -608,7 +613,7 @@ public class SpaceshipController : NetworkBehaviour
|
||||
Scores = 0;
|
||||
Kills = 0;
|
||||
startedTime = NetworkTime.time;
|
||||
trailTime = 1;
|
||||
DecreaseTrail(trailTime);
|
||||
trailMgr.trail.time = trailTime;
|
||||
RpcDie(killer);
|
||||
gameObject.SetActive(false);
|
||||
|
||||
28
Assets/Game/Scripts/NewSkinDisplay.cs
Normal file
28
Assets/Game/Scripts/NewSkinDisplay.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class NewSkinDisplay : MonoBehaviour
|
||||
{
|
||||
public ParticleSystem glowParticle;
|
||||
public Image rocketImg;
|
||||
SkinShopItemData newSkin;
|
||||
|
||||
public void Show(SkinShopItemData skin){
|
||||
newSkin =skin;
|
||||
gameObject.SetActive(true);
|
||||
glowParticle.startColor = SkinShopManager.getRarityColor(skin);
|
||||
rocketImg.sprite = newSkin.image;
|
||||
}
|
||||
|
||||
public void Cancel(){
|
||||
gameObject.SetActive(false);
|
||||
AudioManager.instnace.UIClick();
|
||||
}
|
||||
|
||||
public void Equip(){
|
||||
SkinShopManager.instance.EquipSkin(newSkin);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
11
Assets/Game/Scripts/NewSkinDisplay.cs.meta
Normal file
11
Assets/Game/Scripts/NewSkinDisplay.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 92aec48cae38c57cb85cb0f6b38edc43
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/Game/Scripts/RocketHanger.cs
Normal file
17
Assets/Game/Scripts/RocketHanger.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class RocketHanger : MonoBehaviour
|
||||
{
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Game/Scripts/RocketHanger.cs.meta
Normal file
11
Assets/Game/Scripts/RocketHanger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eae943e5c73af568eba479f83225c1a0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -26,6 +26,7 @@ public class SelectedItemMenu : MonoBehaviour
|
||||
public Transform upgrade_statParent;
|
||||
public GameObject[] upgrade_tierIndicators;
|
||||
public TMP_Text upgrade_buildingName;
|
||||
public TMP_Text extraDetailsTxt;
|
||||
public Button upgradeBtn;
|
||||
|
||||
[Header("Special buildings")]
|
||||
@@ -84,9 +85,9 @@ public class SelectedItemMenu : MonoBehaviour
|
||||
infoMenu.SetActive(false);
|
||||
}
|
||||
|
||||
void OnUpgradeMenuClicked()
|
||||
public void OnUpgradeMenuClicked()
|
||||
{
|
||||
|
||||
extraDetailsTxt.gameObject.SetActive(false);
|
||||
// Debug.Log("Opening Upgrade Menu for : " + Selector.selectedBuilding.buildingData.name);
|
||||
AudioManager.instnace.UIPopup();
|
||||
|
||||
@@ -126,8 +127,7 @@ public class SelectedItemMenu : MonoBehaviour
|
||||
if (Selector.selectedBuilding.curLevel < Selector.selectedData.levels.Count - 1)
|
||||
{
|
||||
upgradeBtn.interactable = (Selector.selectedData.levels[Selector.selectedBuilding.curLevel + 1].price < DBmanager.Coins);
|
||||
upgradeBtn.GetComponentInChildren<TMP_Text>().text = Selector.selectedData.levels[Selector.selectedBuilding.curLevel + 1].price.ToString();
|
||||
|
||||
upgradeBtn.GetComponentInChildren<TMP_Text>().text = Selector.selectedData.levels[Selector.selectedBuilding.curLevel + 1].price.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -137,7 +137,16 @@ public class SelectedItemMenu : MonoBehaviour
|
||||
Debug.Log("Already max");
|
||||
}
|
||||
|
||||
|
||||
if(Selector.selectedData == rocketRepair){
|
||||
SkinShopManager.instance.Populate();
|
||||
upgradeBtn.interactable= (SkinShopManager.availableToUpgrade);
|
||||
if(!SkinShopManager.availableToUpgrade && Selector.selectedBuilding.curLevel < Selector.selectedData.levels.Count-1){
|
||||
// MessageDialog.instance.ShowMessage("Notice!","You have to purchase half of the best rarity skins available to upgrade");
|
||||
extraDetailsTxt.gameObject.SetActive(true);
|
||||
extraDetailsTxt.text = "You have to purchase half of the best rarity skins available to upgrade";
|
||||
extraDetailsTxt.color = Color.red;
|
||||
}
|
||||
}
|
||||
|
||||
if (upgrade_statParent.childCount < stats.Count)
|
||||
{
|
||||
@@ -154,17 +163,23 @@ public class SelectedItemMenu : MonoBehaviour
|
||||
int C = GoldMine.GetCapacityRateByLevel(L);
|
||||
int P = GoldMine.GetProductionRateByLevel(L);
|
||||
//Calculate prices
|
||||
if(P>=3){
|
||||
btn_gold_prod.interactable=false; btn_gold_prod.transform.Find("txt_price").GetComponent<TMP_Text>().text = "Max!";
|
||||
if(P>=GoldMine.LevelsCount){
|
||||
btn_gold_prod.interactable=false;
|
||||
btn_gold_prod.transform.Find("txt_price").GetComponent<TMP_Text>().text = "Max!";
|
||||
}
|
||||
else{
|
||||
btn_gold_prod.interactable=true; btn_gold_prod.transform.Find("txt_price").GetComponent<TMP_Text>().text = (gold_prod_upgrade_cost * P).ToString();
|
||||
bool affroadable = DBmanager.Coins >= GoldMine.GetCostForProduction(L);
|
||||
btn_gold_prod.interactable=affroadable;
|
||||
btn_gold_prod.transform.Find("txt_price").GetComponent<TMP_Text>().text = GoldMine.GetCostForProduction(L).ToString();
|
||||
}
|
||||
if(C>=3){
|
||||
btn_gold_cap.interactable=false; btn_gold_cap.transform.Find("txt_price").GetComponent<TMP_Text>().text = "Max!";
|
||||
if(C>=GoldMine.LevelsCount){
|
||||
btn_gold_cap.interactable = false;
|
||||
btn_gold_cap.transform.Find("txt_price").GetComponent<TMP_Text>().text = "Max!";
|
||||
}
|
||||
else{
|
||||
btn_gold_cap.interactable=true; btn_gold_cap.transform.Find("txt_price").GetComponent<TMP_Text>().text = (gold_cap_upgrade_cost * C).ToString();
|
||||
bool affroadable = DBmanager.Coins >= GoldMine.GetCostForCapacity(L);
|
||||
btn_gold_cap.interactable=affroadable;
|
||||
btn_gold_cap.transform.Find("txt_price").GetComponent<TMP_Text>().text = GoldMine.GetCostForCapacity(L).ToString();
|
||||
|
||||
}
|
||||
|
||||
@@ -175,17 +190,16 @@ public class SelectedItemMenu : MonoBehaviour
|
||||
Selector.selectedBuilding.Upgrade();
|
||||
OnUpgradeMenuClicked();
|
||||
}
|
||||
int gold_prod_upgrade_cost = 3000;
|
||||
int gold_cap_upgrade_cost = 2500;
|
||||
|
||||
void OnGoldmineCapUpgrade(){
|
||||
int L = Selector.selectedBuilding.curLevel+1;
|
||||
int C = GoldMine.GetCapacityRateByLevel(L);
|
||||
if(C >=3){return;}
|
||||
if(C >=GoldMine.LevelsCount){return;}
|
||||
int P = GoldMine.GetProductionRateByLevel(L);
|
||||
|
||||
int newLevel = GoldMine.GetLevelByRates(C + 1, P);
|
||||
upgradeBtn.interactable= false;
|
||||
Selector.selectedBuilding.Upgrade(newLevel:newLevel-1, cost: C*gold_cap_upgrade_cost);
|
||||
Selector.selectedBuilding.Upgrade(newLevel:newLevel-1, cost:GoldMine.GetCostForCapacity(L) );
|
||||
goldmineUpgradeMenu.SetActive(false);
|
||||
OnUpgradeMenuClicked();
|
||||
}
|
||||
@@ -194,10 +208,10 @@ public class SelectedItemMenu : MonoBehaviour
|
||||
int L = Selector.selectedBuilding.curLevel+1;
|
||||
int C = GoldMine.GetCapacityRateByLevel(L);
|
||||
int P = GoldMine.GetProductionRateByLevel(L);
|
||||
if(P >=3){return;}
|
||||
if(P >=GoldMine.LevelsCount){return;}
|
||||
int newLevel = GoldMine.GetLevelByRates(C, P+1);
|
||||
upgradeBtn.interactable= false;
|
||||
Selector.selectedBuilding.Upgrade(newLevel:newLevel-1, cost: C*gold_prod_upgrade_cost);
|
||||
Selector.selectedBuilding.Upgrade(newLevel:newLevel-1, cost: GoldMine.GetCostForProduction(L));
|
||||
|
||||
goldmineUpgradeMenu.SetActive(false);
|
||||
OnUpgradeMenuClicked();
|
||||
|
||||
44
Assets/Game/Scripts/TutorialManager.cs
Normal file
44
Assets/Game/Scripts/TutorialManager.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
public class TutorialManager : MonoBehaviour
|
||||
{
|
||||
public static bool justRegistered;
|
||||
public static TutorialManager instance;
|
||||
public TutorialScreen[] firstTutorial;
|
||||
void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
void Start(){
|
||||
justRegistered= true; //for testing purpose
|
||||
if(justRegistered){
|
||||
StartSequence(firstTutorial);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async void StartSequence(TutorialScreen[] list){
|
||||
foreach(TutorialScreen screen in list){
|
||||
screen.Hide();
|
||||
}
|
||||
for(int i=0; i < list.Length; i++){
|
||||
nextClicked = false;
|
||||
await Task.Delay(list[i].delayBeforeAppear);
|
||||
list[i].Show();
|
||||
|
||||
while(!nextClicked){
|
||||
await Task.Delay(500);
|
||||
}
|
||||
list[i].Hide();
|
||||
}
|
||||
}
|
||||
bool nextClicked= false;
|
||||
|
||||
public static void NextClicked(){
|
||||
instance.nextClicked = true;
|
||||
}
|
||||
}
|
||||
11
Assets/Game/Scripts/TutorialManager.cs.meta
Normal file
11
Assets/Game/Scripts/TutorialManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a91d1290d1c1c780ab983d3d404aaa07
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
65
Assets/Game/Scripts/TutorialScreen.cs
Normal file
65
Assets/Game/Scripts/TutorialScreen.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TutorialScreen : MonoBehaviour
|
||||
{
|
||||
public Transform messageParent;
|
||||
public Button btn_next;
|
||||
public int delayBeforeAppear;
|
||||
public bool hideNextButtonOnStart=true;
|
||||
|
||||
Dictionary<TMP_Text, string> messages;
|
||||
|
||||
void Awake(){
|
||||
btn_next.onClick.AddListener(OnNextButton);
|
||||
}
|
||||
|
||||
public void Show(){
|
||||
gameObject.SetActive(true);
|
||||
ShowTexts();
|
||||
}
|
||||
|
||||
async void ShowTexts(){
|
||||
if(hideNextButtonOnStart){btn_next.gameObject.SetActive(false);}
|
||||
int typewriteDelay = 0;
|
||||
if(messages == null){
|
||||
messages = new Dictionary<TMP_Text, string>();
|
||||
TMP_Text[] texts = messageParent.GetComponentsInChildren<TMP_Text>();
|
||||
foreach(TMP_Text text in texts){
|
||||
messages.Add(text, text.text);
|
||||
text.text = "";
|
||||
}
|
||||
}
|
||||
foreach(KeyValuePair<TMP_Text, string> message in messages){
|
||||
message.Key.text="";
|
||||
Debug.Log(message.Value);
|
||||
for(int i=0; i < message.Value.Length; i++){
|
||||
message.Key.text+=message.Value.ToCharArray()[i];
|
||||
if(typewriteDelay< 4){
|
||||
typewriteDelay++;
|
||||
}else{
|
||||
AudioManager.instnace.TypeWriter();
|
||||
typewriteDelay=0;
|
||||
}
|
||||
await Task.Delay(20);
|
||||
}
|
||||
await Task.Delay(500);
|
||||
}
|
||||
|
||||
|
||||
btn_next.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void Hide(){
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void OnNextButton(){
|
||||
TutorialManager.NextClicked();
|
||||
AudioManager.instnace.UIClick();
|
||||
}
|
||||
}
|
||||
11
Assets/Game/Scripts/TutorialScreen.cs.meta
Normal file
11
Assets/Game/Scripts/TutorialScreen.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56baa627e873d35a984a9c8cf18ef589
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -51,6 +51,10 @@ public class WorldItemSelector : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectBuilding(Building building){
|
||||
Selector.selectBuilding(building);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Vector2? startedPos= null;
|
||||
|
||||
@@ -5,7 +5,9 @@ using TMPro;
|
||||
using UnityEngine.UI;
|
||||
public class XpPass : MonoBehaviour
|
||||
{
|
||||
public GameObject panel;
|
||||
public TMP_Text nextLevelTxt;
|
||||
public GameObject newRewardsNotification;
|
||||
public float sliderWidthPerLevel = 450;
|
||||
public Slider levelSlider;
|
||||
[SerializeField]
|
||||
@@ -22,16 +24,16 @@ public class XpPass : MonoBehaviour
|
||||
|
||||
public void Show(){
|
||||
Refresh();
|
||||
gameObject.SetActive(true);
|
||||
panel.SetActive(true);
|
||||
}
|
||||
|
||||
public void Hide(){
|
||||
gameObject.SetActive(false);
|
||||
panel.SetActive(false);
|
||||
}
|
||||
|
||||
void Refresh(){
|
||||
nextLevelTxt.text = (DBmanager.LevelInt +1).ToString();
|
||||
|
||||
int rewardsLeftToCollect= 0;
|
||||
//Sort Rewards by Level
|
||||
XpPassReward temp;
|
||||
for (int j = 0; j <= rewards.Length - 2; j++) {
|
||||
@@ -88,11 +90,18 @@ public class XpPass : MonoBehaviour
|
||||
rewardCard.GetComponent<Button>().interactable=false;
|
||||
rewardCard.transform.GetChild(3).gameObject.SetActive(true);
|
||||
}
|
||||
if(rewardCard.GetComponent<Button>().interactable){
|
||||
rewardsLeftToCollect++;
|
||||
}
|
||||
rewardCard.GetComponent<Button>().onClick.AddListener(()=>OnRewardCollect(reward.level));
|
||||
}
|
||||
levelSlider.GetComponent<RectTransform>().sizeDelta = new Vector2(sliderWidthPerLevel * rewards.Length-2 ,levelSlider.GetComponent<RectTransform>().sizeDelta.y);
|
||||
rewardCardPrefab.SetActive(false); xpLevelPointPrefab.SetActive(false);
|
||||
levelSlider.value = DBmanager.Level / (float)rewards[rewards.Length-1].level;
|
||||
|
||||
//Set notification
|
||||
newRewardsNotification.SetActive(rewardsLeftToCollect>0);
|
||||
newRewardsNotification.GetComponentInChildren<TMP_Text>().text = rewardsLeftToCollect.ToString();
|
||||
}
|
||||
|
||||
public void OnRewardCollect(int level){
|
||||
|
||||
Reference in New Issue
Block a user