Tutorial done
This commit is contained in:
@@ -112,6 +112,6 @@ public class AudioManager : MonoBehaviour
|
||||
}
|
||||
|
||||
public void TypeWriter(){
|
||||
audioSrc.PlayOneShot(typewriters[Random.Range(0, typewriters.Length)],0.7f);
|
||||
audioSrc.PlayOneShot(typewriters[Random.Range(0, typewriters.Length)],0.1f);
|
||||
}
|
||||
}
|
||||
|
||||
30
Assets/Game/Scripts/ChestDataObject.cs
Normal file
30
Assets/Game/Scripts/ChestDataObject.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu(fileName = "Chestdata", menuName = "Game/ChestdataObject", order = 1)]
|
||||
public class ChestDataObject : ScriptableObject
|
||||
{
|
||||
public string name;
|
||||
public int Price;
|
||||
public float minGold;
|
||||
public float maxGold;
|
||||
public float minGems;
|
||||
public float maxGems;
|
||||
public float gemsChance;
|
||||
|
||||
public float commonChance;
|
||||
public float rareChance;
|
||||
public float legendaryChance;
|
||||
|
||||
public string getInfo(){
|
||||
string items = $"Gold {minGold}-{maxGold}\n";
|
||||
items += $"Gems : {minGems}-{maxGems} [{gemsChance}%]\n";
|
||||
|
||||
items += $"Common Skin : [{commonChance}%]\n";
|
||||
items += $"Rare Skin : [{rareChance}%]\n";
|
||||
items += $"Legendary Skin : [{legendaryChance}%]";
|
||||
|
||||
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
11
Assets/Game/Scripts/ChestDataObject.cs.meta
Normal file
11
Assets/Game/Scripts/ChestDataObject.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14f135076942807149ce1d9e140a0731
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -25,18 +25,22 @@ public class ChestOpener : MonoBehaviour
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public async void OpenChest(int minLuck, int maxLuck){
|
||||
public async void OpenChest(ChestDataObject chestData){
|
||||
chestOpenPopup.SetActive(true);
|
||||
okButton.SetActive(false);
|
||||
int luckiness= Random.Range(minLuck,maxLuck);
|
||||
|
||||
List<SkinShopItemData> baseSkins = new List<SkinShopItemData>();
|
||||
List<SkinShopItemData> rareSkins = new List<SkinShopItemData>();
|
||||
List<SkinShopItemData> legendarySkins = new List<SkinShopItemData>();
|
||||
|
||||
SkinShopItemData selectedSkin = null;
|
||||
int gemsCount = 0;
|
||||
int goldCount = 0;
|
||||
if(luckiness > 70){
|
||||
float gemLucky = Random.Range(0,100f);
|
||||
float goldLucky = Random.Range(0,100f);
|
||||
int gemsCount = (gemLucky < chestData.gemsChance) ? (int)(chestData.minGems + ((chestData.maxGems - chestData.minGems)*(gemLucky/100f) )) : 0;
|
||||
int goldCount = (int)(chestData.minGold + ((chestData.maxGold - chestData.minGold)*(goldLucky/100f) ));
|
||||
|
||||
float skinsLucky = Random.Range(0,100f);
|
||||
if(skinsLucky < chestData.commonChance){
|
||||
//Skin is rewarded
|
||||
foreach(SkinShopItemData skin in skins.skins){
|
||||
if(!DBmanager.SkinsPurchased.Contains(skin.name)){
|
||||
@@ -53,24 +57,24 @@ public class ChestOpener : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
if(luckiness > 95 && legendarySkins.Count > 0){
|
||||
|
||||
if(skinsLucky < chestData.legendaryChance && legendarySkins.Count > 0){
|
||||
//Legend
|
||||
selectedSkin = legendarySkins[Random.Range(0,legendarySkins.Count)];
|
||||
}else if(luckiness > 85 && rareSkins.Count > 0){
|
||||
goldCount += 50000;
|
||||
}else if(skinsLucky < chestData.rareChance && rareSkins.Count > 0){
|
||||
selectedSkin = rareSkins[Random.Range(0,rareSkins.Count)];
|
||||
goldCount += 5000;
|
||||
}else if(baseSkins.Count > 0){
|
||||
selectedSkin = baseSkins[Random.Range(0,baseSkins.Count)];
|
||||
goldCount+= 500;
|
||||
}
|
||||
}
|
||||
|
||||
if(luckiness > 50){
|
||||
gemsCount = Mathf.CeilToInt((float)luckiness / 20f) * 10;
|
||||
}
|
||||
goldCount = Mathf.CeilToInt((float)luckiness / 10f) * 1000;
|
||||
|
||||
goldDrop.SetActive(goldCount > 0);
|
||||
gemsDrop.SetActive(gemsCount > 0);
|
||||
skinDrop.SetActive(selectedSkin!=null);
|
||||
goldDrop.transform.GetComponentInChildren<TMP_Text>().text = goldCount.ToString("0,000");
|
||||
goldDrop.transform.GetComponentInChildren<TMP_Text>().text = goldCount.ToString();
|
||||
gemsDrop.transform.GetComponentInChildren<TMP_Text>().text = gemsCount.ToString();
|
||||
|
||||
if(selectedSkin!=null){
|
||||
|
||||
@@ -148,14 +148,14 @@ public class GameManager : MonoBehaviour
|
||||
LoadingScreen.instance.LoadLevel("Login");
|
||||
}
|
||||
|
||||
public void BuyChest(ChestButton button){
|
||||
if(DBmanager.Gems < button.Price){
|
||||
public void BuyChest(ChestButton chestBtn){
|
||||
if(DBmanager.Gems < chestBtn.Price){
|
||||
MessageDialog.instance.ShowMessage("Failed", "Insufficient Gems to complete the purchase");
|
||||
return;
|
||||
}
|
||||
|
||||
DBmanager.SetGems(DBmanager.Gems-button.Price);
|
||||
ChestOpener.instance.OpenChest((int)button.minLuck, (int)button.maxLuck);
|
||||
DBmanager.SetGems(DBmanager.Gems-chestBtn.Price);
|
||||
ChestOpener.instance.OpenChest(chestBtn.chestData);
|
||||
}
|
||||
|
||||
public void BuyGold(GoldPackButton button){
|
||||
|
||||
@@ -109,6 +109,10 @@ public class SkinShopManager : MonoBehaviour
|
||||
return rarity;
|
||||
}
|
||||
|
||||
public void SelectItem(int index){
|
||||
skinShopItems[index].OnClick();
|
||||
}
|
||||
|
||||
public void SelectItem(SkinShopItemData data, bool Available){
|
||||
selectedSkin = data;
|
||||
if(data==null){
|
||||
@@ -143,7 +147,7 @@ public class SkinShopManager : MonoBehaviour
|
||||
Populate();
|
||||
}
|
||||
|
||||
void onBuy(){
|
||||
public void onBuy(){
|
||||
List<SkinShopItemData> skinsInSameRarity = new List<SkinShopItemData>();
|
||||
foreach(SkinShopItemData skin in skinsAvailableToPurchase){
|
||||
if(skin.skinType == selectedSkin.skinType){
|
||||
|
||||
@@ -154,7 +154,7 @@ public class SelectedItemMenu : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void OnUpgrade()
|
||||
public void OnUpgrade()
|
||||
{
|
||||
if(Selector.selectedBuilding.GetComponent<GoldMine>()!=null){
|
||||
AudioManager.instnace.UIPopup();
|
||||
@@ -191,7 +191,7 @@ public class SelectedItemMenu : MonoBehaviour
|
||||
OnUpgradeMenuClicked();
|
||||
}
|
||||
|
||||
void OnGoldmineCapUpgrade(){
|
||||
public void OnGoldmineCapUpgrade(){
|
||||
int L = Selector.selectedBuilding.curLevel+1;
|
||||
int C = GoldMine.GetCapacityRateByLevel(L);
|
||||
if(C >=GoldMine.LevelsCount){return;}
|
||||
@@ -204,7 +204,7 @@ public class SelectedItemMenu : MonoBehaviour
|
||||
OnUpgradeMenuClicked();
|
||||
}
|
||||
|
||||
void OnGoldmineProdUpgrade(){
|
||||
public void OnGoldmineProdUpgrade(){
|
||||
int L = Selector.selectedBuilding.curLevel+1;
|
||||
int C = GoldMine.GetCapacityRateByLevel(L);
|
||||
int P = GoldMine.GetProductionRateByLevel(L);
|
||||
@@ -231,7 +231,7 @@ public class SelectedItemMenu : MonoBehaviour
|
||||
AudioManager.instnace.UIPopup();
|
||||
}
|
||||
|
||||
void OpenSkinMenu(){
|
||||
public void OpenSkinMenu(){
|
||||
SkinShopManager.instance.Show();
|
||||
AudioManager.instnace.UIPopup();
|
||||
|
||||
|
||||
@@ -9,10 +9,9 @@ public class ChestButton : MonoBehaviour
|
||||
public bool readFromTexts;
|
||||
public TMP_Text txtPrice;
|
||||
public TMP_Text txtChestName;
|
||||
public string ChestName => txtChestName.text;
|
||||
public ChestDataObject chestData;
|
||||
public int Price;
|
||||
public float minLuck = 0;
|
||||
public float maxLuck = 100;
|
||||
public bool overridePrice;
|
||||
public Button btnInfo;
|
||||
public Button adButton;
|
||||
[TextArea]
|
||||
@@ -27,11 +26,11 @@ public class ChestButton : MonoBehaviour
|
||||
|
||||
void OnClickedInfo()
|
||||
{
|
||||
MessageDialog.instance.ShowMessage(ChestName, $"This chest will drop following items.\n\n{getItemsProbability()}");
|
||||
MessageDialog.instance.ShowMessage(chestData.name, $"This chest will drop following items.\n\n{chestData.getInfo()}");
|
||||
}
|
||||
|
||||
void OnClick(){
|
||||
MessageDialog.instance.ShowQuestion("Are you sure?", $"Are you sure to purchase {ChestName} for {Price} Gems?", Buy,null);
|
||||
MessageDialog.instance.ShowQuestion("Are you sure?", $"Are you sure to purchase {chestData.name} for {Price} Gems?", Buy,null);
|
||||
}
|
||||
|
||||
void OnAdClicked(){
|
||||
@@ -46,7 +45,7 @@ public class ChestButton : MonoBehaviour
|
||||
}
|
||||
|
||||
DBmanager.SetGems(DBmanager.Gems - Price);
|
||||
ChestOpener.instance.OpenChest((int)minLuck, (int)maxLuck);
|
||||
ChestOpener.instance.OpenChest(chestData);
|
||||
}
|
||||
|
||||
public void BuyFree(){
|
||||
@@ -56,49 +55,20 @@ public class ChestButton : MonoBehaviour
|
||||
|
||||
IEnumerator buyFree(){
|
||||
yield return new WaitForSeconds(1);
|
||||
ChestOpener.instance.OpenChest((int)minLuck, (int)maxLuck);
|
||||
}
|
||||
|
||||
public string getItemsProbability()
|
||||
{
|
||||
string items = "Gold";
|
||||
|
||||
if (maxLuck > 50)
|
||||
{
|
||||
float probability = ((maxLuck - 50f) / (maxLuck - minLuck)) * 100f;
|
||||
items += $"\nGems : {probability.ToString("n1")}%";
|
||||
}
|
||||
|
||||
if (maxLuck > 70)
|
||||
{
|
||||
//some skins
|
||||
float probability = ((maxLuck - 70f) / (maxLuck - minLuck)) * 100f;
|
||||
items += $"\nCommon Skin : {probability.ToString("n1")}%";
|
||||
}
|
||||
if (maxLuck > 85)
|
||||
{
|
||||
float probability = ((maxLuck - 85f) / (maxLuck - minLuck)) * 100f;
|
||||
items += $"\nRare Skin : {probability.ToString("n1")}%";
|
||||
}
|
||||
if (maxLuck > 95)
|
||||
{
|
||||
float probability = ((maxLuck - 95f) / (maxLuck - minLuck)) * 100f;
|
||||
items += $"\nLegendary Skin : {probability.ToString("n1")}%";
|
||||
}
|
||||
|
||||
|
||||
return items;
|
||||
ChestOpener.instance.OpenChest(chestData);
|
||||
}
|
||||
|
||||
void OnValidate()
|
||||
{
|
||||
infoTxt = getItemsProbability();
|
||||
|
||||
infoTxt = chestData.getInfo();
|
||||
if(!overridePrice){Price=chestData.Price;}
|
||||
txtPrice.text = Price.ToString();
|
||||
txtChestName.text = chestData.name;
|
||||
if (!readFromTexts) { return; }
|
||||
|
||||
if (txtPrice != null)
|
||||
{
|
||||
Price = int.Parse(txtPrice.text);
|
||||
}
|
||||
// if (txtPrice != null)
|
||||
// {
|
||||
// Price = int.Parse(txtPrice.text);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class SpecialChest : MonoBehaviour
|
||||
|
||||
IEnumerator StartChestList(){
|
||||
for(int i=0; i< quantity; i++){
|
||||
ChestOpener.instance.OpenChest((int)chestButton.minLuck, (int)chestButton.maxLuck);
|
||||
ChestOpener.instance.OpenChest(chestButton.chestData);
|
||||
while(ChestOpener.instance.active){
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
|
||||
@@ -2,18 +2,23 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TutorialManager : MonoBehaviour
|
||||
{
|
||||
public static bool justRegistered;
|
||||
public static TutorialManager instance;
|
||||
public TutorialScreen[] firstTutorial;
|
||||
public GameObject[] itemsToDisableWhileInTuto;
|
||||
public Button btn_skip;
|
||||
void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
void Start(){
|
||||
btn_skip.onClick.AddListener(OnSkip);
|
||||
|
||||
justRegistered= true; //for testing purpose
|
||||
if(justRegistered){
|
||||
StartSequence(firstTutorial);
|
||||
@@ -22,6 +27,11 @@ public class TutorialManager : MonoBehaviour
|
||||
|
||||
|
||||
async void StartSequence(TutorialScreen[] list){
|
||||
skipped=false;
|
||||
btn_skip.gameObject.SetActive(true);
|
||||
foreach(GameObject item in itemsToDisableWhileInTuto){
|
||||
item.SetActive(false);
|
||||
}
|
||||
foreach(TutorialScreen screen in list){
|
||||
screen.Hide();
|
||||
}
|
||||
@@ -30,15 +40,28 @@ public class TutorialManager : MonoBehaviour
|
||||
await Task.Delay(list[i].delayBeforeAppear);
|
||||
list[i].Show();
|
||||
|
||||
while(!nextClicked){
|
||||
while(!nextClicked && !skipped){
|
||||
await Task.Delay(500);
|
||||
}
|
||||
list[i].Hide();
|
||||
|
||||
if(skipped){
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach(GameObject item in itemsToDisableWhileInTuto){
|
||||
item.SetActive(true);
|
||||
}
|
||||
btn_skip.gameObject.SetActive(false);
|
||||
}
|
||||
bool nextClicked= false;
|
||||
bool skipped = false;
|
||||
|
||||
public static void NextClicked(){
|
||||
instance.nextClicked = true;
|
||||
}
|
||||
|
||||
void OnSkip(){
|
||||
skipped=true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,19 +3,25 @@ using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TutorialScreen : MonoBehaviour
|
||||
{
|
||||
public Transform messageParent;
|
||||
public Button btn_next;
|
||||
public Button[] additional_next_buttons;
|
||||
public int delayBeforeAppear;
|
||||
public bool hideNextButtonOnStart=true;
|
||||
public UnityEvent OnNextClicked;
|
||||
|
||||
Dictionary<TMP_Text, string> messages;
|
||||
|
||||
void Awake(){
|
||||
btn_next.onClick.AddListener(OnNextButton);
|
||||
foreach(Button btn in additional_next_buttons){
|
||||
btn.onClick.AddListener(OnNextButton);
|
||||
}
|
||||
}
|
||||
|
||||
public void Show(){
|
||||
@@ -59,6 +65,8 @@ public class TutorialScreen : MonoBehaviour
|
||||
}
|
||||
|
||||
public void OnNextButton(){
|
||||
OnNextClicked.Invoke();
|
||||
Debug.Log("Next button clicked");
|
||||
TutorialManager.NextClicked();
|
||||
AudioManager.instnace.UIClick();
|
||||
}
|
||||
|
||||
12
Assets/Game/Scripts/UIAnchorToWorldPoint.cs
Normal file
12
Assets/Game/Scripts/UIAnchorToWorldPoint.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class UIAnchorToWorldPoint : MonoBehaviour
|
||||
{
|
||||
public Transform worldPoint;
|
||||
void Update()
|
||||
{
|
||||
transform.position = Camera.main.WorldToScreenPoint(worldPoint.position);
|
||||
}
|
||||
}
|
||||
11
Assets/Game/Scripts/UIAnchorToWorldPoint.cs.meta
Normal file
11
Assets/Game/Scripts/UIAnchorToWorldPoint.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 989b71b0166e271688086c991b1b5fe6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -116,7 +116,7 @@ public class XpPass : MonoBehaviour
|
||||
DBmanager.SetGems(DBmanager.Gems + reward.amount);
|
||||
}else if(reward.rewardType == XpRewardType.Chest){
|
||||
// StartCoroutine(destroyTimer(Instantiate(chestPrefab, chestSpawnParent),5));
|
||||
ChestOpener.instance.OpenChest(0,100);
|
||||
ChestOpener.instance.OpenChest(reward.chestData);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -134,6 +134,7 @@ public class XpPassReward{
|
||||
public int level;
|
||||
public XpRewardType rewardType;
|
||||
public int amount;
|
||||
public ChestDataObject chestData;
|
||||
}
|
||||
|
||||
public enum XpRewardType{
|
||||
|
||||
Reference in New Issue
Block a user