Effects added in shop

dev-ali
Ali Sharoz 2 weeks ago
parent d8b1ed7687
commit 53572bcb2e

@ -2959,6 +2959,11 @@ PrefabInstance:
propertyPath: m_Name
value: Sparkle_ellow
objectReference: {fileID: 0}
- target: {fileID: 4033412786151888123, guid: 49057b33ea71fbb4da4e8f02a8db9f28,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4123381426564554493, guid: 49057b33ea71fbb4da4e8f02a8db9f28,
type: 3}
propertyPath: m_Materials.Array.size
@ -3020,6 +3025,12 @@ Transform:
type: 3}
m_PrefabInstance: {fileID: 834928115}
m_PrefabAsset: {fileID: 0}
--- !u!1 &834928117 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 4033412786151888123, guid: 49057b33ea71fbb4da4e8f02a8db9f28,
type: 3}
m_PrefabInstance: {fileID: 834928115}
m_PrefabAsset: {fileID: 0}
--- !u!1 &892229232
GameObject:
m_ObjectHideFlags: 0
@ -5204,7 +5215,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1323667006}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
@ -9253,6 +9264,12 @@ PrefabInstance:
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 42c597428e933b6459d47d1d9ac7d933, type: 3}
--- !u!1 &467508691553497674 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 7487719306644811017, guid: 42c597428e933b6459d47d1d9ac7d933,
type: 3}
m_PrefabInstance: {fileID: 467508691553497673}
m_PrefabAsset: {fileID: 0}
--- !u!1 &867399617953754665
GameObject:
m_ObjectHideFlags: 0
@ -19287,14 +19304,14 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Color: {r: 0, g: 0, b: 0, a: 0.28235295}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: ecc225411c44d814bbb5d4a97e19eeb0, type: 3}
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
@ -19429,6 +19446,13 @@ MonoBehaviour:
column: 0
levelLeaderBtn: {fileID: 1137828060}
TimerManager: {fileID: 242488685}
Backgrounds:
- {fileID: 834928117}
- {fileID: 6825969688944082723}
- {fileID: 467508691553497674}
TileBG: {fileID: 1323667008}
BoxBG: {fileID: 1790415148045805216}
BoxBGSprite: {fileID: 21300000, guid: ecc225411c44d814bbb5d4a97e19eeb0, type: 3}
--- !u!114 &1790415148045805218
MonoBehaviour:
m_ObjectHideFlags: 0
@ -41208,6 +41232,12 @@ PrefabInstance:
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 3627893f9a824364e96f6e199e719418, type: 3}
--- !u!1 &6825969688944082723 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 399311634534860263, guid: 3627893f9a824364e96f6e199e719418,
type: 3}
m_PrefabInstance: {fileID: 6825969688944082722}
m_PrefabAsset: {fileID: 0}
--- !u!4 &7790633250115468875
Transform:
m_ObjectHideFlags: 0

File diff suppressed because it is too large Load Diff

@ -91,6 +91,17 @@ public class GameManager
PlayerPrefs.SetInt("PipeIndex", value);
}
}
public static int EffectIndex
{
get
{
return PlayerPrefs.GetInt("EffectIndex", -1);
}
set
{
PlayerPrefs.SetInt("EffectIndex", value);
}
}
public static int StarLevel
{

@ -83,7 +83,10 @@ public class GamePlayManager : MonoBehaviour
[SerializeField] private TimerManager TimerManager;
// Adding the isTimerLevel flag
public static bool isTimerLevel;
public List<GameObject> Backgrounds;
public Image TileBG;
public Image BoxBG;
public Sprite BoxBGSprite;
private void Awake()
{
instance = this;
@ -108,6 +111,13 @@ public class GamePlayManager : MonoBehaviour
public void SetupLevel()
{
if (GameManager.EffectIndex != -1)
{
Backgrounds[GameManager.EffectIndex].SetActive(true);
TileBG.enabled = true;
BoxBG.sprite = BoxBGSprite;
BoxBG.color = new Color(255,255,255,255);
}
isGameOver = false;
closeGameOver = false;
MessagePopup.instance.HideAll();

@ -42,6 +42,7 @@ public class ShopManager : MonoBehaviour, IDetailedStoreListener
public List<ConsumableItem> cItem;
public List<ConsumableItem> pItem;
public List<ConsumableItem> eItem;
public List<int> coinsRewards;
//public NonConsumableItem ncItem;
//public SubscriptionItem sItem;
@ -54,7 +55,9 @@ public class ShopManager : MonoBehaviour, IDetailedStoreListener
public PayloadData payloadData;
public List<ButtonState> PipeButtons;
public List<ButtonState> EffectButtons;
//public List<Button> PurchaseButtons;
public GameObject NotEnoughCoinsObj;
[Serializable]
public class ButtonState
{
@ -70,6 +73,7 @@ public class ShopManager : MonoBehaviour, IDetailedStoreListener
coinTxt.text = coins.ToString();
SetupBuilder();
PipePrefGetter();
EffectPrefGetter();
}
@ -147,21 +151,50 @@ public class ShopManager : MonoBehaviour, IDetailedStoreListener
}
}
}
void EffectPrefGetter()
{
for (int i = 0; i < EffectButtons.Count; i++)
{
EffectButtons[i].isEquipped = PlayerPrefs.GetInt("EffectButtonIsEquipped" + i) == 1 ? true : false;
EffectButtons[i].isPurchased = PlayerPrefs.GetInt("EffectButtonIsPurchased" + i) == 1 ? true : false;
if (EffectButtons[i].isPurchased == false)
{
EffectButtons[i].PurchaseButton.gameObject.SetActive(true);
EffectButtons[i].EquipButton.gameObject.SetActive(false);
}
else
{
EffectButtons[i].EquipButton.gameObject.SetActive(true);
EffectButtons[i].PurchaseButton.gameObject.SetActive(false);
if (EffectButtons[i].isEquipped == true)
{
EffectButtons[i].equipButtonText.text = "Equipped";
}
else
{
EffectButtons[i].equipButtonText.text = "Equip";
}
}
}
}
#region setup and initialize
void SetupBuilder()
{
var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
for (int i = 0; i < cItem.Count; i++)
{
builder.AddProduct(cItem[i].Id, ProductType.Consumable);
}
for (int i = 1; i < pItem.Count; i++)//Starting from 1 because 1 set of pipe is already bought by default.
{
builder.AddProduct(pItem[i].Id, ProductType.NonConsumable);
}
//for (int i = 0; i < eItem.Count; i++)//Starting from 1 because 1 set of pipe is already bought by default.
//{
// builder.AddProduct(eItem[i].Id, ProductType.NonConsumable);
//}
//builder.AddProduct(ncItem.Id, ProductType.NonConsumable);
//builder.AddProduct(sItem.Id, ProductType.Subscription);
@ -191,9 +224,13 @@ public class ShopManager : MonoBehaviour, IDetailedStoreListener
currentPurchaseType = PurchaseType.Pipes;
Debug.Log("Purchasing pipes1... : " + pItem[index].Id);
m_StoreController.InitiatePurchase(pItem[index].Id);
//Debug.Log("Purchasing pipes2... : "+ pItem[index].Id);
}
public void Consumable_Btn_Pressed_Effects(int index)
{
currentPurchaseType = PurchaseType.Effects;
AddEffects(index);
}
//public void NonConsumable_Btn_Pressed()
//{
@ -212,7 +249,7 @@ public class ShopManager : MonoBehaviour, IDetailedStoreListener
public PurchaseType currentPurchaseType;
public enum PurchaseType
{
Coins, Pipes,
Coins, Pipes, Effects,
}
#region main
//processing purchase
@ -265,6 +302,28 @@ public class ShopManager : MonoBehaviour, IDetailedStoreListener
}
}
}
//else if (currentPurchaseType == PurchaseType.Effects)
//{
// for (int h = 0; h < eItem.Count; h++)
// {
// Debug.Log("product.definition.id : " + product.definition.id);
// Debug.Log("pItem[h].Id : " + eItem[h].Id);
// if (product.definition.id == eItem[h].Id)//consumable item is pressed
// {
// //string receipt = product.receipt;
// //data = JsonUtility.FromJson<Data>(receipt);
// //payload = JsonUtility.FromJson<Payload>(data.Payload);
// //payloadData = JsonUtility.FromJson<PayloadData>(payload.json);
// //int quantity = payloadData.quantity;
// //for (int i = 0; i < quantity; i++)
// //{
// AddEffects(h);
// //}
// }
// }
//}
//else if (product.definition.id == ncItem.Id)//non consumable
//{
@ -396,7 +455,14 @@ public class ShopManager : MonoBehaviour, IDetailedStoreListener
coins += toAdd;
PlayerPrefs.SetInt("Coin", coins);
StartCoroutine(startCoinShakeEffect(coins - toAdd, coins, .5f));
}
void SubtractCoins(int coinsToSubtract)
{
int coins = PlayerPrefs.GetInt("Coin");
coins -= coinsToSubtract;
PlayerPrefs.SetInt("Coin", coins);
StartCoroutine(startCoinShakeEffect(coins + coinsToSubtract, coins, .5f));
}
public void EquipUnEquipPipe(int buttonIndex)
{
@ -428,10 +494,48 @@ public class ShopManager : MonoBehaviour, IDetailedStoreListener
}
}
public void EquipUnEquipEffect(int buttonIndex)
{
if (EffectButtons[buttonIndex].isEquipped)
{
PlayerPrefs.SetInt("EffectButtonIsEquipped" + buttonIndex, 0);
PlayerPrefs.SetInt("EffectButtonIsEquipped-1", 1);
EffectIndexSetter(-1);
}
else
{
for (int i = 0; i < EffectButtons.Count; i++)
{
if (i != buttonIndex)
{
EffectButtons[i].isEquipped = false;
PlayerPrefs.SetInt("EffectButtonIsEquipped" + i, 0);
EffectButtons[i].equipButtonText.text = "Equip";
}
else
{
EffectButtons[i].isEquipped = true;
PlayerPrefs.SetInt("EffectButtonIsEquipped" + i, 1);
EffectButtons[i].equipButtonText.text = "Equipped";
EffectIndexSetter(buttonIndex);
}
}
}
}
public void PipeIndexSetter(int index)
{
GameManager.PipeIndex = index;
}
public void EffectIndexSetter(int index)
{
GameManager.EffectIndex = index;
}
void AddPipes(int index)
{
PlayerPrefs.SetInt("PipeButtonIsPurchased" + index, 1);
@ -440,6 +544,23 @@ public class ShopManager : MonoBehaviour, IDetailedStoreListener
PipeButtons[index].PurchaseButton.gameObject.SetActive(false);
Debug.Log("Pipe " + index + " purchased");
}
void AddEffects(int index)
{
int coins = PlayerPrefs.GetInt("Coin");
if (coins > eItem[index].price)
{
SubtractCoins((int)eItem[index].price);
PlayerPrefs.SetInt("EffectButtonIsPurchased" + index, 1);
EffectButtons[index].isPurchased = true;
EffectButtons[index].EquipButton.gameObject.SetActive(true);
EffectButtons[index].PurchaseButton.gameObject.SetActive(false);
Debug.Log("Effect " + index + " purchased");
}
else
{
NotEnoughCoinsObj.SetActive(true);
}
}
float val;
IEnumerator startCoinShakeEffect(int oldValue, int newValue, float animTime)
{

Loading…
Cancel
Save