Помогите с оптимизацией
Добавлено: 14 фев 2012, 14:57
Код для интерфеса магазина и местами очень тормозит. Подскажите что тут слишком криво сделано , и как лучше?
Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
using System;
public abstract class TZTabMenu : MonoBehaviour
{
private bool _isscroll = false;
public bool _isstatic = false;
// flags for smooth move of scroll panel
private bool _smoothscrollback = false;
private bool _smoothscrollforward = false;
private bool _smoothscrollbarshow = false;
private bool _smoothscrollbarhide = false;
// touch pos
private float _touchpos = 0;
private float _newpos = 0;
// coef for container move and scrollbar move
public float _scrollcoef = 0;
public float _scrollbarcoef = 0;
//
private float _scrollalpha = 0;
private bool _isvisible = true;
// const parameters
public Vector3 SCROLL_BAR_POSITION_TOP = new Vector3(0.58f, 0.52f, -1f);
public Vector3 SCROLL_BAR_POSITION_BUTTOM = new Vector3(0.58f, -0.50f, -1f);
private Vector3 CONTAINER_DEFAULT_POS;
private float ITEMS_AREA_TOP;
private float ITEMS_AREA_BUTTOM;
private float ITEMS_CONTAINER_OFFSET;
private Transform _camera;
public int _currenttab = 0;
private tk2dSprite SHOP_TABS;
private Transform SHOP_SCROLL_BAR;
private tk2dSprite SHOP_SCROLL_BAR_SPRITE;
public string[] _tablist;
public Transform SHOP_ITEM_CONTAINER;
private bool _ishide = false;
public Transform _topslider = null;
public float[] _topsliderpos;
private float _currenttopsliderpos;
private bool _movetopslider = false;
private float _topsliderstep;
public bool isNoTabs = false;
public float areaOffset = 0.6f;
// Use this for initialization
private void Start()
{
_topsliderstep = 0.04f*Camera.main.orthographicSize*60f;
//init slider pos
if (_topsliderpos.Length > 0)
{
_currenttopsliderpos = _topsliderpos[0];
}
// link to camera transform
_camera = Camera.main.transform;
// const parameters
CONTAINER_DEFAULT_POS = new Vector3(0, 0, -1f);
ITEMS_AREA_TOP = areaOffset * Camera.main.orthographicSize + _camera.position.y;
ITEMS_AREA_BUTTOM = -areaOffset * Camera.main.orthographicSize + _camera.position.y;
ITEMS_CONTAINER_OFFSET = 0.05f * Camera.main.orthographicSize;
// init all links of shop gameobjects at LinksContainer
if (!isNoTabs)
{
SHOP_TABS = GameObject.FindGameObjectWithTag("TZTopTabs").GetComponent<tk2dSprite>();
}
SHOP_ITEM_CONTAINER = GameObject.FindGameObjectWithTag("TZItemContainer").GetComponent<Transform>();
SHOP_SCROLL_BAR = GameObject.FindGameObjectWithTag("TZScrollBar").GetComponent<Transform>();
SHOP_SCROLL_BAR_SPRITE = SHOP_SCROLL_BAR.GetComponent<tk2dSprite>();
SHOP_SCROLL_BAR_SPRITE.color = new Color(1f, 1f, 1f, 0);
SHOP_ITEM_CONTAINER.localPosition = CONTAINER_DEFAULT_POS;
InitTabs(0, true, 0);
}
// Update is called once per frame
private void Update()
{
// blocking layer
if (TZButton.ButtonBlockingZ < transform.position.z)
{
_isvisible = false;
}
else
{
_isvisible = true;
}
if ((!_ishide) && (tag == "ShopItemBack") &&
((transform.position.y > (0.767f * Camera.main.orthographicSize + Camera.main.transform.position.y)) ||
(transform.position.y < (-0.767f * Camera.main.orthographicSize + Camera.main.transform.position.y))))
{
_ishide = true;
transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, 2000f);
}
else if ((_ishide) && (tag == "ShopItemBack") &&
((transform.position.y < (0.767f * Camera.main.orthographicSize + Camera.main.transform.position.y)) &&
(transform.position.y > (-0.767f * Camera.main.orthographicSize + Camera.main.transform.position.y))))
{
_ishide = false;
transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, 0);
}
// _isvisible = false when blocking layer is in front of shop window
if (_movetopslider)
{
if (((_topslider.position.x + 0.05f) > _currenttopsliderpos) &&
((_topslider.position.x - 0.05f) < _currenttopsliderpos))
{
_movetopslider = false;
_topslider.position = new Vector3(_currenttopsliderpos, _topslider.position.y, _topslider.position.z);
}
else if (_topslider.position.x > _currenttopsliderpos)
{
_topslider.Translate(-_topsliderstep*Time.deltaTime, 0, 0);
}
else
{
_topslider.Translate(_topsliderstep*Time.deltaTime, 0, 0);
}
}
if (!_isstatic && _isvisible)
{
// event on mouse down(touch screen)
if (Input.GetMouseButtonDown(0))
{
_touchpos = Camera.main.ScreenToWorldPoint(Input.mousePosition).y;
if ((_touchpos < ITEMS_AREA_TOP) && (_touchpos > ITEMS_AREA_BUTTOM))
{
_isscroll = true;
_smoothscrollbarshow = true;
_smoothscrollbarhide = false;
}
}
// event on mouse up
if (Input.GetMouseButtonUp(0))
{
_isscroll = false;
_smoothscrollbarhide = true;
_smoothscrollbarshow = false;
if (SHOP_ITEM_CONTAINER.localPosition.y < 0)
{
_smoothscrollback = true;
}
if (SHOP_ITEM_CONTAINER.localPosition.y > (_scrollcoef))
{
_smoothscrollforward = true;
}
}
if (_isscroll)
{
_newpos = Camera.main.ScreenToWorldPoint(Input.mousePosition).y;
if (Mathf.Abs((Mathf.Abs(_newpos) - Mathf.Abs(_touchpos))) > 0.01)
{
// move items container
SHOP_ITEM_CONTAINER.Translate(0, (_newpos - _touchpos), 0);
if (((SHOP_SCROLL_BAR.localPosition.y + (_touchpos - _newpos)/_scrollbarcoef) <
SCROLL_BAR_POSITION_TOP.y)
&&
((SHOP_SCROLL_BAR.localPosition.y + (_touchpos - _newpos)/_scrollbarcoef) >
SCROLL_BAR_POSITION_BUTTOM.y))
{
SHOP_SCROLL_BAR.Translate(0, (_touchpos - _newpos)/_scrollbarcoef, 0);
}
_touchpos = _newpos;
}
}
if (_smoothscrollback)
{
SHOP_ITEM_CONTAINER.Translate(0, ITEMS_CONTAINER_OFFSET, 0);
SHOP_SCROLL_BAR.Translate(0, - Time.deltaTime * 60f * ITEMS_CONTAINER_OFFSET/_scrollbarcoef, 0);
if (SHOP_ITEM_CONTAINER.localPosition.y > 0)
{
SHOP_ITEM_CONTAINER.localPosition = CONTAINER_DEFAULT_POS;
SHOP_SCROLL_BAR.localPosition = SCROLL_BAR_POSITION_TOP;
_smoothscrollback = false;
}
}
if (_smoothscrollforward)
{
SHOP_ITEM_CONTAINER.Translate(0, -ITEMS_CONTAINER_OFFSET, 0);
SHOP_SCROLL_BAR.Translate(0, Time.deltaTime * 60f * ITEMS_CONTAINER_OFFSET / _scrollbarcoef, 0);
if (SHOP_ITEM_CONTAINER.localPosition.y < _scrollcoef)
{
SHOP_ITEM_CONTAINER.localPosition = new Vector3(0, _scrollcoef, -1f);
SHOP_SCROLL_BAR.localPosition = SCROLL_BAR_POSITION_BUTTOM;
_smoothscrollforward = false;
}
}
if (_smoothscrollbarshow && !_smoothscrollbarhide)
{
_scrollalpha += 0.1f;
if (_scrollalpha > 1f)
{
SHOP_SCROLL_BAR_SPRITE.color = new Color(1f, 1f, 1f, 1f);
_smoothscrollbarshow = false;
}
else
{
SHOP_SCROLL_BAR_SPRITE.color = new Color(1f, 1f, 1f, _scrollalpha);
}
}
if (_smoothscrollbarhide && !_smoothscrollbarshow)
{
_scrollalpha -= 0.1f;
if (_scrollalpha < 0)
{
SHOP_SCROLL_BAR_SPRITE.color = new Color(1f, 1f, 1f, 0f);
_smoothscrollbarhide = false;
}
else
{
SHOP_SCROLL_BAR_SPRITE.color = new Color(1f, 1f, 1f, _scrollalpha);
}
}
}
}
public void InitTabs(int idtab, bool restoretabs, int param)
{
// destroy all items of old tab
if (SHOP_ITEM_CONTAINER.childCount > 0)
{
for (int i = 0; i < SHOP_ITEM_CONTAINER.childCount; i++)
{
Destroy(SHOP_ITEM_CONTAINER.GetChild(i).gameObject);
}
}
if (isNoTabs == false)
{
_currenttab = idtab;
SHOP_TABS.spriteId = SHOP_TABS.GetSpriteIdByName(_tablist[idtab]);
}
if (restoretabs)
{
SHOP_ITEM_CONTAINER.localPosition = CONTAINER_DEFAULT_POS;
SHOP_SCROLL_BAR.localPosition = SCROLL_BAR_POSITION_TOP;
}
InitItems(Type.GetType(_tablist[idtab]), param);
}
private void SwitchTab(string idtab)
{
_currenttopsliderpos = _topsliderpos[int.Parse(idtab)] * Camera.main.orthographicSize;
_movetopslider = true;
InitTabs(int.Parse(idtab), true,1);
}
public void UpdateWindow()
{
InitTabs(_currenttab, false,1);
}
public abstract void Confirm();
public abstract void InitItems(Type enumtype, int param);
}
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
using System;
public class ShopController : TZTabMenu
{
private Vector3 ITEM_ICON_POS = new Vector3(-0.4f, 0.034f, -0.15f);
// buy parameter
private string _itembuytype;
private Transform _itembuyObject = null;
public static string QuestParam = "";
public static bool isBuyCust = false;
public static Customization custToBuy;
public static Transform custButton = null;
public override void InitItems(Type enumtype, int param)
{
LinksContainer.Instance.InitShopLinks();
if (enumtype.ToString() == _tablist[0])
{
if (custButton != null)
{
Destroy(custButton.gameObject);
}
string[] items;
items = Enum.GetNames(enumtype);
// <refactor> move to global parameter
int PLAYERSTARS = PlayerPrefs.GetInt("PLAYER_STARS");
//get player stars amount
LinksContainer.Instance.SHOP_PLAYER_STARS_AMOUNT.text = PLAYERSTARS.ToString();
// destroy all items of old tab
if (SHOP_ITEM_CONTAINER.childCount > 0)
{
for (int i = 0; i < SHOP_ITEM_CONTAINER.childCount; i++)
{
Destroy(SHOP_ITEM_CONTAINER.GetChild(i).gameObject);
}
}
// coef for translate of items and scrollbar
_scrollcoef = items.Length*0.35f - 1.2f;
_scrollbarcoef = (items.Length*0.35f - 1.2f)/1f;
if (items.Length < 4)
{
_isstatic = true;
}
else
{
_isstatic = false;
}
for (int i = 0; i < items.Length; i++)
{
Transform shopitemback =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.SHOP_ITEM_BACK);
if (param == 1)
{
AnimWindow animWindow = shopitemback.GetComponent<AnimWindow>();
if (animWindow != null)
{
Destroy(animWindow);
}
shopitemback.localScale = new Vector3(Camera.main.orthographicSize, Camera.main.orthographicSize, Camera.main.orthographicSize);
}
// set item price
TZTextMesh itemprice = shopitemback.FindChild("ItemPrice").GetComponent<TZTextMesh>();
int price = (int) Enum.Parse(enumtype, items[i]);
itemprice.text = price.ToString();
// set item count to label "ItemCount"
TZTextMesh itemcount = shopitemback.FindChild("ItemCount").GetComponent<TZTextMesh>();
int ic = PlayerPrefs.GetInt(items[i]);
itemcount.text = ic.ToString();
shopitemback.name = items[i];
shopitemback.parent = SHOP_ITEM_CONTAINER;
TZTextMesh texttm = shopitemback.FindChild("Text").GetComponent<TZTextMesh>();
switch (i)
{
case 0:
{
texttm.text = "Slimming capsule.\n" +
"Take her to become\n" +
"smaller and faster!";
break;
}
case 1:
{
texttm.text = "Take her to become\n" +
"bigger and slower!";
break;
}
case 2:
{
texttm.text = "Destroy the missile\n" +
"obstacles in its path.";
break;
}
case 3:
{
texttm.text = "This is a magic bag,\n" +
"with its help you fly\n" +
"over obstacles. ";
break;
}
case 4:
{
texttm.text = "Click on the glasses\n" +
"to go through all the\n" +
"obstacles.";
break;
}
}
Transform itemicon =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.SHOP_ITEM);
if (param == 1)
{
itemicon.localScale = Vector3.one * Camera.main.orthographicSize;
}
itemicon.parent = shopitemback;
shopitemback.localPosition = new Vector3(0, (0.4f - i*0.35f), 0);
itemicon.localPosition = ITEM_ICON_POS;
tk2dSprite itemsprite = itemicon.GetComponent<tk2dSprite>();
itemsprite.spriteId = itemsprite.GetSpriteIdByName(items[i]);
TZButton itembutton = shopitemback.GetComponent<TZButton>();
itembutton.messageParam = items[i];
itembutton.messageName = "BuyItem";
if (PLAYERSTARS < price)
{
itembutton._isblocked = true;
Transform disablelayer =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.DISABLE_ITEM_LAYER);
disablelayer.parent = shopitemback;
disablelayer.localPosition = new Vector3(0, 0, -0.2f);
}
TZGUIController.ChangeLayer(shopitemback, gameObject.layer);
}
}
else if (enumtype.ToString() == _tablist[2])
{
if (custButton != null)
{
Destroy(custButton.gameObject);
}
// destroy all items of old tab
if (SHOP_ITEM_CONTAINER.childCount > 0)
{
for (int i = 0; i < SHOP_ITEM_CONTAINER.childCount; i++)
{
Destroy(SHOP_ITEM_CONTAINER.GetChild(i).gameObject);
}
}
List<Quest> questList = new List<Quest>();
for (int i = 0; i < QuestsContainer.Instance.QuestList.Count; i++)
{
if (QuestsContainer.Instance.QuestList[i].Price > 0)
{
questList.Add(QuestsContainer.Instance.QuestList[i]);
}
}
// coef for translate of items and scrollbar
_scrollcoef = questList.Count*0.35f - 1.2f;
_scrollbarcoef = (questList.Count*0.35f - 1.2f)/1f;
if (questList.Count < 4)
{
_isstatic = true;
}
else
{
_isstatic = false;
}
for (int i = 0; i < questList.Count; i++)
{
Transform shopitemback =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.QUEST_ITEM_BACK);
if (param == 1)
{
AnimWindow animWindow = shopitemback.GetComponent<AnimWindow>();
if (animWindow != null)
{
Destroy(animWindow);
}
shopitemback.localScale = new Vector3(Camera.main.orthographicSize, Camera.main.orthographicSize, Camera.main.orthographicSize);
}
// set item price
TZTextMesh itemprice = shopitemback.FindChild("ItemPrice").GetComponent<TZTextMesh>();
int price = questList[i].Price;
itemprice.text = price.ToString();
//shopitemback.name = items[i];
shopitemback.parent = SHOP_ITEM_CONTAINER;
TZTextMesh texttm = shopitemback.FindChild("Text").GetComponent<TZTextMesh>();
texttm.text = questList[i].Description;
shopitemback.parent = SHOP_ITEM_CONTAINER;
Transform itemicon =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.QUEST_ITEM);
itemicon.localScale = Vector3.one * Camera.main.orthographicSize;
itemicon.parent = shopitemback;
shopitemback.localPosition = new Vector3(0, (0.4f - i*0.35f), 0);
itemicon.localPosition = ITEM_ICON_POS + Vector3.up*0.01f;
tk2dSprite itemsprite = itemicon.GetComponent<tk2dSprite>();
itemsprite.spriteId = itemsprite.GetSpriteIdByName(questList[i].QuestType);
TZButton itembutton = shopitemback.GetComponent<TZButton>();
itembutton.messageParam = questList[i].ID.ToString() + "_" + questList[i].Price.ToString();
itembutton.messageName = "BuyQuest";
GameObject gameObject = shopitemback.FindChild("ItemCount").gameObject;
Destroy(gameObject);
tk2dSprite counter = shopitemback.FindChild("Counter").GetComponent<tk2dSprite>();
if (QuestsContainer.Instance.questsUsing[questList[i].ID] == 1)
{
counter.spriteId = counter.GetSpriteIdByName("counteryes");
itembutton._isblocked = true;
}
else
{
Destroy(counter.gameObject);
}
//TZTextMesh textItem = shopitemback.FindChild("Text").GetComponent<TZTextMesh>();
//textItem.text = "x" + questList[i].Count.ToString() + "=" + questList[i].BonusAmount.ToString();
int PLAYERSTARS = PlayerPrefs.GetInt("PLAYER_STARS");
if (PLAYERSTARS < price)
{
itembutton._isblocked = true;
Transform disablelayer =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.DISABLE_ITEM_LAYER);
disablelayer.parent = shopitemback;
disablelayer.localPosition = new Vector3(0, 0, -0.2f);
}
TZGUIController.ChangeLayer(shopitemback, gameObject.layer);
}
}
else if (enumtype.ToString() == _tablist[1])
{
custButton = LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.CUSTOMIZE_BUTTON);
custButton.parent = transform;
custButton.localPosition = new Vector3(0.3519354f, -0.7553403f, -3f);
string[] items;
items = Enum.GetNames(enumtype);
// <refactor> move to global parameter
int PLAYERSTARS = PlayerPrefs.GetInt("PLAYER_STARS");
//get player stars amount
LinksContainer.Instance.SHOP_PLAYER_STARS_AMOUNT.text = PLAYERSTARS.ToString();
// destroy all items of old tab
if (SHOP_ITEM_CONTAINER.childCount > 0)
{
for (int i = 0; i < SHOP_ITEM_CONTAINER.childCount; i++)
{
Destroy(SHOP_ITEM_CONTAINER.GetChild(i).gameObject);
}
}
// coef for translate of items and scrollbar
_scrollcoef = items.Length*0.35f - 1.2f;
_scrollbarcoef = (items.Length*0.35f - 1.2f)/1f;
if (items.Length < 4)
{
_isstatic = true;
}
else
{
_isstatic = false;
}
for (int i = 0; i < items.Length; i++)
{
Transform shopitemback =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.CUSTOMIZE_ITEM_BACK);
if (param == 1)
{
AnimWindow animWindow = shopitemback.GetComponent<AnimWindow>();
if (animWindow != null)
{
Destroy(animWindow);
}
shopitemback.localScale = new Vector3(Camera.main.orthographicSize, Camera.main.orthographicSize, Camera.main.orthographicSize);
}
// set item price
TZTextMesh itemprice = shopitemback.FindChild("ItemPrice").GetComponent<TZTextMesh>();
int price = CustomizationContainer.Instance.Customizations[i].Price;
itemprice.text = CustomizationContainer.Instance.Customizations[i].Price.ToString();
TZTextMesh texttm = shopitemback.FindChild("Text").GetComponent<TZTextMesh>();
texttm.text = CustomizationContainer.Instance.Customizations[i].Description;
shopitemback.name = CustomizationContainer.Instance.Customizations[i].Id.ToString();
shopitemback.parent = SHOP_ITEM_CONTAINER;
Transform itemicon =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.CUSTOMIZE_ITEM);
itemicon.localScale = Vector3.one * Camera.main.orthographicSize;
itemicon.parent = shopitemback;
shopitemback.localPosition = new Vector3(0, (0.4f - i*0.35f), 0);
itemicon.localPosition = ITEM_ICON_POS - Vector3.up * 0.021f;
tk2dSprite itemsprite = itemicon.GetComponent<tk2dSprite>();
itemsprite.spriteId = itemsprite.GetSpriteIdByName(items[i]);
TZButton itembutton = shopitemback.GetComponent<TZButton>();
itembutton.messageParam = CustomizationContainer.Instance.Customizations[i].Id.ToString();
itembutton.messageName = "BuyCustomization";
GameObject gameObject = shopitemback.FindChild("ItemCount").gameObject;
Destroy(gameObject);
tk2dSprite counter = shopitemback.FindChild("Counter").GetComponent<tk2dSprite>();
if (CustomizationContainer.Instance.Customizations[i].IsPurchased == true)
{
counter.spriteId = counter.GetSpriteIdByName("counteryes");
itembutton.messageName = "UseCustomization";
if (CustomizationContainer.Instance.Customizations[i].IsUsed == true)
{
tk2dSprite labelok = shopitemback.FindChild("BackLabel").GetComponent<tk2dSprite>();
labelok.spriteId = labelok.GetSpriteIdByName("labelok");
tk2dSprite tk2DSprite = shopitemback.GetComponent<tk2dSprite>();
tk2DSprite.spriteId = tk2DSprite.GetSpriteIdByName("pressed_shop_button");
itembutton.sprite_down = "active_shop_button";
itembutton.sprite_up = "pressed_shop_button";
}
}
else
{
Destroy(shopitemback.FindChild("BackLabel").gameObject);
Destroy(counter.gameObject);
}
if (PLAYERSTARS < price)
{
if (CustomizationContainer.Instance.Customizations[i].IsPurchased == false)
{
itembutton._isblocked = true;
Transform disablelayer =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(
ObjectsEnum.DISABLE_ITEM_LAYER);
disablelayer.parent = shopitemback;
disablelayer.localPosition = new Vector3(0, 0, -0.2f);
}
}
TZGUIController.ChangeLayer(shopitemback, gameObject.layer);
}
}
}
public override void Confirm()
{
if (_currenttab == 0)
{
int itemcount = PlayerPrefs.GetInt(_itembuytype);
itemcount++;
PlayerPrefs.SetInt(_itembuytype, itemcount);
int price = (int) Enum.Parse(typeof (SHOPITEMSENUM), _itembuytype);
int PLAYERSTARS = PlayerPrefs.GetInt("PLAYER_STARS");
if (PLAYERSTARS >= price)
{
PlayerPrefs.SetInt("PLAYER_STARS", (PLAYERSTARS - price));
if (_itembuyObject != null)
{
TZTextMesh ic = _itembuyObject.FindChild("ItemCount").GetComponent<TZTextMesh>();
ic.text = itemcount.ToString();
}
}
}else if (_currenttab == 1)
{
int custid = int.Parse(_itembuytype);
int price = CustomizationContainer.Instance.Customizations[custid].Price;
int PLAYERSTARS = PlayerPrefs.GetInt("PLAYER_STARS");
if (PLAYERSTARS >= price)
{
PlayerPrefs.SetInt("PLAYER_STARS", (PLAYERSTARS - price));
LinksContainer.Instance.SHOP_PLAYER_STARS_AMOUNT.text = (PLAYERSTARS - price).ToString();
CustomizationContainer.Instance.Customizations[custid].IsPurchased = true;
}
CustomizationContainer.Instance.SavePurchasedStat();
}
else if (_currenttab == 2)
{
string[] param = QuestParam.Split('_');
QuestsContainer.Instance.questsUsing[int.Parse(param[0])] = 1;
QuestsContainer.Instance.SaveQuestsStat();
int price = int.Parse(param[1]);
int PLAYERSTARS = PlayerPrefs.GetInt("PLAYER_STARS");
if (PLAYERSTARS >= price)
{
PlayerPrefs.SetInt("PLAYER_STARS", (PLAYERSTARS - price));
LinksContainer.Instance.SHOP_PLAYER_STARS_AMOUNT.text = (PLAYERSTARS - price).ToString();
}
}
UpdateWindow();
}
private void setItemBuyType(string buytype)
{
_itembuytype = buytype;
_itembuyObject = GameObject.Find(buytype).transform;
}
}
using System.Collections;
using System;
public abstract class TZTabMenu : MonoBehaviour
{
private bool _isscroll = false;
public bool _isstatic = false;
// flags for smooth move of scroll panel
private bool _smoothscrollback = false;
private bool _smoothscrollforward = false;
private bool _smoothscrollbarshow = false;
private bool _smoothscrollbarhide = false;
// touch pos
private float _touchpos = 0;
private float _newpos = 0;
// coef for container move and scrollbar move
public float _scrollcoef = 0;
public float _scrollbarcoef = 0;
//
private float _scrollalpha = 0;
private bool _isvisible = true;
// const parameters
public Vector3 SCROLL_BAR_POSITION_TOP = new Vector3(0.58f, 0.52f, -1f);
public Vector3 SCROLL_BAR_POSITION_BUTTOM = new Vector3(0.58f, -0.50f, -1f);
private Vector3 CONTAINER_DEFAULT_POS;
private float ITEMS_AREA_TOP;
private float ITEMS_AREA_BUTTOM;
private float ITEMS_CONTAINER_OFFSET;
private Transform _camera;
public int _currenttab = 0;
private tk2dSprite SHOP_TABS;
private Transform SHOP_SCROLL_BAR;
private tk2dSprite SHOP_SCROLL_BAR_SPRITE;
public string[] _tablist;
public Transform SHOP_ITEM_CONTAINER;
private bool _ishide = false;
public Transform _topslider = null;
public float[] _topsliderpos;
private float _currenttopsliderpos;
private bool _movetopslider = false;
private float _topsliderstep;
public bool isNoTabs = false;
public float areaOffset = 0.6f;
// Use this for initialization
private void Start()
{
_topsliderstep = 0.04f*Camera.main.orthographicSize*60f;
//init slider pos
if (_topsliderpos.Length > 0)
{
_currenttopsliderpos = _topsliderpos[0];
}
// link to camera transform
_camera = Camera.main.transform;
// const parameters
CONTAINER_DEFAULT_POS = new Vector3(0, 0, -1f);
ITEMS_AREA_TOP = areaOffset * Camera.main.orthographicSize + _camera.position.y;
ITEMS_AREA_BUTTOM = -areaOffset * Camera.main.orthographicSize + _camera.position.y;
ITEMS_CONTAINER_OFFSET = 0.05f * Camera.main.orthographicSize;
// init all links of shop gameobjects at LinksContainer
if (!isNoTabs)
{
SHOP_TABS = GameObject.FindGameObjectWithTag("TZTopTabs").GetComponent<tk2dSprite>();
}
SHOP_ITEM_CONTAINER = GameObject.FindGameObjectWithTag("TZItemContainer").GetComponent<Transform>();
SHOP_SCROLL_BAR = GameObject.FindGameObjectWithTag("TZScrollBar").GetComponent<Transform>();
SHOP_SCROLL_BAR_SPRITE = SHOP_SCROLL_BAR.GetComponent<tk2dSprite>();
SHOP_SCROLL_BAR_SPRITE.color = new Color(1f, 1f, 1f, 0);
SHOP_ITEM_CONTAINER.localPosition = CONTAINER_DEFAULT_POS;
InitTabs(0, true, 0);
}
// Update is called once per frame
private void Update()
{
// blocking layer
if (TZButton.ButtonBlockingZ < transform.position.z)
{
_isvisible = false;
}
else
{
_isvisible = true;
}
if ((!_ishide) && (tag == "ShopItemBack") &&
((transform.position.y > (0.767f * Camera.main.orthographicSize + Camera.main.transform.position.y)) ||
(transform.position.y < (-0.767f * Camera.main.orthographicSize + Camera.main.transform.position.y))))
{
_ishide = true;
transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, 2000f);
}
else if ((_ishide) && (tag == "ShopItemBack") &&
((transform.position.y < (0.767f * Camera.main.orthographicSize + Camera.main.transform.position.y)) &&
(transform.position.y > (-0.767f * Camera.main.orthographicSize + Camera.main.transform.position.y))))
{
_ishide = false;
transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, 0);
}
// _isvisible = false when blocking layer is in front of shop window
if (_movetopslider)
{
if (((_topslider.position.x + 0.05f) > _currenttopsliderpos) &&
((_topslider.position.x - 0.05f) < _currenttopsliderpos))
{
_movetopslider = false;
_topslider.position = new Vector3(_currenttopsliderpos, _topslider.position.y, _topslider.position.z);
}
else if (_topslider.position.x > _currenttopsliderpos)
{
_topslider.Translate(-_topsliderstep*Time.deltaTime, 0, 0);
}
else
{
_topslider.Translate(_topsliderstep*Time.deltaTime, 0, 0);
}
}
if (!_isstatic && _isvisible)
{
// event on mouse down(touch screen)
if (Input.GetMouseButtonDown(0))
{
_touchpos = Camera.main.ScreenToWorldPoint(Input.mousePosition).y;
if ((_touchpos < ITEMS_AREA_TOP) && (_touchpos > ITEMS_AREA_BUTTOM))
{
_isscroll = true;
_smoothscrollbarshow = true;
_smoothscrollbarhide = false;
}
}
// event on mouse up
if (Input.GetMouseButtonUp(0))
{
_isscroll = false;
_smoothscrollbarhide = true;
_smoothscrollbarshow = false;
if (SHOP_ITEM_CONTAINER.localPosition.y < 0)
{
_smoothscrollback = true;
}
if (SHOP_ITEM_CONTAINER.localPosition.y > (_scrollcoef))
{
_smoothscrollforward = true;
}
}
if (_isscroll)
{
_newpos = Camera.main.ScreenToWorldPoint(Input.mousePosition).y;
if (Mathf.Abs((Mathf.Abs(_newpos) - Mathf.Abs(_touchpos))) > 0.01)
{
// move items container
SHOP_ITEM_CONTAINER.Translate(0, (_newpos - _touchpos), 0);
if (((SHOP_SCROLL_BAR.localPosition.y + (_touchpos - _newpos)/_scrollbarcoef) <
SCROLL_BAR_POSITION_TOP.y)
&&
((SHOP_SCROLL_BAR.localPosition.y + (_touchpos - _newpos)/_scrollbarcoef) >
SCROLL_BAR_POSITION_BUTTOM.y))
{
SHOP_SCROLL_BAR.Translate(0, (_touchpos - _newpos)/_scrollbarcoef, 0);
}
_touchpos = _newpos;
}
}
if (_smoothscrollback)
{
SHOP_ITEM_CONTAINER.Translate(0, ITEMS_CONTAINER_OFFSET, 0);
SHOP_SCROLL_BAR.Translate(0, - Time.deltaTime * 60f * ITEMS_CONTAINER_OFFSET/_scrollbarcoef, 0);
if (SHOP_ITEM_CONTAINER.localPosition.y > 0)
{
SHOP_ITEM_CONTAINER.localPosition = CONTAINER_DEFAULT_POS;
SHOP_SCROLL_BAR.localPosition = SCROLL_BAR_POSITION_TOP;
_smoothscrollback = false;
}
}
if (_smoothscrollforward)
{
SHOP_ITEM_CONTAINER.Translate(0, -ITEMS_CONTAINER_OFFSET, 0);
SHOP_SCROLL_BAR.Translate(0, Time.deltaTime * 60f * ITEMS_CONTAINER_OFFSET / _scrollbarcoef, 0);
if (SHOP_ITEM_CONTAINER.localPosition.y < _scrollcoef)
{
SHOP_ITEM_CONTAINER.localPosition = new Vector3(0, _scrollcoef, -1f);
SHOP_SCROLL_BAR.localPosition = SCROLL_BAR_POSITION_BUTTOM;
_smoothscrollforward = false;
}
}
if (_smoothscrollbarshow && !_smoothscrollbarhide)
{
_scrollalpha += 0.1f;
if (_scrollalpha > 1f)
{
SHOP_SCROLL_BAR_SPRITE.color = new Color(1f, 1f, 1f, 1f);
_smoothscrollbarshow = false;
}
else
{
SHOP_SCROLL_BAR_SPRITE.color = new Color(1f, 1f, 1f, _scrollalpha);
}
}
if (_smoothscrollbarhide && !_smoothscrollbarshow)
{
_scrollalpha -= 0.1f;
if (_scrollalpha < 0)
{
SHOP_SCROLL_BAR_SPRITE.color = new Color(1f, 1f, 1f, 0f);
_smoothscrollbarhide = false;
}
else
{
SHOP_SCROLL_BAR_SPRITE.color = new Color(1f, 1f, 1f, _scrollalpha);
}
}
}
}
public void InitTabs(int idtab, bool restoretabs, int param)
{
// destroy all items of old tab
if (SHOP_ITEM_CONTAINER.childCount > 0)
{
for (int i = 0; i < SHOP_ITEM_CONTAINER.childCount; i++)
{
Destroy(SHOP_ITEM_CONTAINER.GetChild(i).gameObject);
}
}
if (isNoTabs == false)
{
_currenttab = idtab;
SHOP_TABS.spriteId = SHOP_TABS.GetSpriteIdByName(_tablist[idtab]);
}
if (restoretabs)
{
SHOP_ITEM_CONTAINER.localPosition = CONTAINER_DEFAULT_POS;
SHOP_SCROLL_BAR.localPosition = SCROLL_BAR_POSITION_TOP;
}
InitItems(Type.GetType(_tablist[idtab]), param);
}
private void SwitchTab(string idtab)
{
_currenttopsliderpos = _topsliderpos[int.Parse(idtab)] * Camera.main.orthographicSize;
_movetopslider = true;
InitTabs(int.Parse(idtab), true,1);
}
public void UpdateWindow()
{
InitTabs(_currenttab, false,1);
}
public abstract void Confirm();
public abstract void InitItems(Type enumtype, int param);
}
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
using System;
public class ShopController : TZTabMenu
{
private Vector3 ITEM_ICON_POS = new Vector3(-0.4f, 0.034f, -0.15f);
// buy parameter
private string _itembuytype;
private Transform _itembuyObject = null;
public static string QuestParam = "";
public static bool isBuyCust = false;
public static Customization custToBuy;
public static Transform custButton = null;
public override void InitItems(Type enumtype, int param)
{
LinksContainer.Instance.InitShopLinks();
if (enumtype.ToString() == _tablist[0])
{
if (custButton != null)
{
Destroy(custButton.gameObject);
}
string[] items;
items = Enum.GetNames(enumtype);
// <refactor> move to global parameter
int PLAYERSTARS = PlayerPrefs.GetInt("PLAYER_STARS");
//get player stars amount
LinksContainer.Instance.SHOP_PLAYER_STARS_AMOUNT.text = PLAYERSTARS.ToString();
// destroy all items of old tab
if (SHOP_ITEM_CONTAINER.childCount > 0)
{
for (int i = 0; i < SHOP_ITEM_CONTAINER.childCount; i++)
{
Destroy(SHOP_ITEM_CONTAINER.GetChild(i).gameObject);
}
}
// coef for translate of items and scrollbar
_scrollcoef = items.Length*0.35f - 1.2f;
_scrollbarcoef = (items.Length*0.35f - 1.2f)/1f;
if (items.Length < 4)
{
_isstatic = true;
}
else
{
_isstatic = false;
}
for (int i = 0; i < items.Length; i++)
{
Transform shopitemback =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.SHOP_ITEM_BACK);
if (param == 1)
{
AnimWindow animWindow = shopitemback.GetComponent<AnimWindow>();
if (animWindow != null)
{
Destroy(animWindow);
}
shopitemback.localScale = new Vector3(Camera.main.orthographicSize, Camera.main.orthographicSize, Camera.main.orthographicSize);
}
// set item price
TZTextMesh itemprice = shopitemback.FindChild("ItemPrice").GetComponent<TZTextMesh>();
int price = (int) Enum.Parse(enumtype, items[i]);
itemprice.text = price.ToString();
// set item count to label "ItemCount"
TZTextMesh itemcount = shopitemback.FindChild("ItemCount").GetComponent<TZTextMesh>();
int ic = PlayerPrefs.GetInt(items[i]);
itemcount.text = ic.ToString();
shopitemback.name = items[i];
shopitemback.parent = SHOP_ITEM_CONTAINER;
TZTextMesh texttm = shopitemback.FindChild("Text").GetComponent<TZTextMesh>();
switch (i)
{
case 0:
{
texttm.text = "Slimming capsule.\n" +
"Take her to become\n" +
"smaller and faster!";
break;
}
case 1:
{
texttm.text = "Take her to become\n" +
"bigger and slower!";
break;
}
case 2:
{
texttm.text = "Destroy the missile\n" +
"obstacles in its path.";
break;
}
case 3:
{
texttm.text = "This is a magic bag,\n" +
"with its help you fly\n" +
"over obstacles. ";
break;
}
case 4:
{
texttm.text = "Click on the glasses\n" +
"to go through all the\n" +
"obstacles.";
break;
}
}
Transform itemicon =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.SHOP_ITEM);
if (param == 1)
{
itemicon.localScale = Vector3.one * Camera.main.orthographicSize;
}
itemicon.parent = shopitemback;
shopitemback.localPosition = new Vector3(0, (0.4f - i*0.35f), 0);
itemicon.localPosition = ITEM_ICON_POS;
tk2dSprite itemsprite = itemicon.GetComponent<tk2dSprite>();
itemsprite.spriteId = itemsprite.GetSpriteIdByName(items[i]);
TZButton itembutton = shopitemback.GetComponent<TZButton>();
itembutton.messageParam = items[i];
itembutton.messageName = "BuyItem";
if (PLAYERSTARS < price)
{
itembutton._isblocked = true;
Transform disablelayer =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.DISABLE_ITEM_LAYER);
disablelayer.parent = shopitemback;
disablelayer.localPosition = new Vector3(0, 0, -0.2f);
}
TZGUIController.ChangeLayer(shopitemback, gameObject.layer);
}
}
else if (enumtype.ToString() == _tablist[2])
{
if (custButton != null)
{
Destroy(custButton.gameObject);
}
// destroy all items of old tab
if (SHOP_ITEM_CONTAINER.childCount > 0)
{
for (int i = 0; i < SHOP_ITEM_CONTAINER.childCount; i++)
{
Destroy(SHOP_ITEM_CONTAINER.GetChild(i).gameObject);
}
}
List<Quest> questList = new List<Quest>();
for (int i = 0; i < QuestsContainer.Instance.QuestList.Count; i++)
{
if (QuestsContainer.Instance.QuestList[i].Price > 0)
{
questList.Add(QuestsContainer.Instance.QuestList[i]);
}
}
// coef for translate of items and scrollbar
_scrollcoef = questList.Count*0.35f - 1.2f;
_scrollbarcoef = (questList.Count*0.35f - 1.2f)/1f;
if (questList.Count < 4)
{
_isstatic = true;
}
else
{
_isstatic = false;
}
for (int i = 0; i < questList.Count; i++)
{
Transform shopitemback =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.QUEST_ITEM_BACK);
if (param == 1)
{
AnimWindow animWindow = shopitemback.GetComponent<AnimWindow>();
if (animWindow != null)
{
Destroy(animWindow);
}
shopitemback.localScale = new Vector3(Camera.main.orthographicSize, Camera.main.orthographicSize, Camera.main.orthographicSize);
}
// set item price
TZTextMesh itemprice = shopitemback.FindChild("ItemPrice").GetComponent<TZTextMesh>();
int price = questList[i].Price;
itemprice.text = price.ToString();
//shopitemback.name = items[i];
shopitemback.parent = SHOP_ITEM_CONTAINER;
TZTextMesh texttm = shopitemback.FindChild("Text").GetComponent<TZTextMesh>();
texttm.text = questList[i].Description;
shopitemback.parent = SHOP_ITEM_CONTAINER;
Transform itemicon =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.QUEST_ITEM);
itemicon.localScale = Vector3.one * Camera.main.orthographicSize;
itemicon.parent = shopitemback;
shopitemback.localPosition = new Vector3(0, (0.4f - i*0.35f), 0);
itemicon.localPosition = ITEM_ICON_POS + Vector3.up*0.01f;
tk2dSprite itemsprite = itemicon.GetComponent<tk2dSprite>();
itemsprite.spriteId = itemsprite.GetSpriteIdByName(questList[i].QuestType);
TZButton itembutton = shopitemback.GetComponent<TZButton>();
itembutton.messageParam = questList[i].ID.ToString() + "_" + questList[i].Price.ToString();
itembutton.messageName = "BuyQuest";
GameObject gameObject = shopitemback.FindChild("ItemCount").gameObject;
Destroy(gameObject);
tk2dSprite counter = shopitemback.FindChild("Counter").GetComponent<tk2dSprite>();
if (QuestsContainer.Instance.questsUsing[questList[i].ID] == 1)
{
counter.spriteId = counter.GetSpriteIdByName("counteryes");
itembutton._isblocked = true;
}
else
{
Destroy(counter.gameObject);
}
//TZTextMesh textItem = shopitemback.FindChild("Text").GetComponent<TZTextMesh>();
//textItem.text = "x" + questList[i].Count.ToString() + "=" + questList[i].BonusAmount.ToString();
int PLAYERSTARS = PlayerPrefs.GetInt("PLAYER_STARS");
if (PLAYERSTARS < price)
{
itembutton._isblocked = true;
Transform disablelayer =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.DISABLE_ITEM_LAYER);
disablelayer.parent = shopitemback;
disablelayer.localPosition = new Vector3(0, 0, -0.2f);
}
TZGUIController.ChangeLayer(shopitemback, gameObject.layer);
}
}
else if (enumtype.ToString() == _tablist[1])
{
custButton = LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.CUSTOMIZE_BUTTON);
custButton.parent = transform;
custButton.localPosition = new Vector3(0.3519354f, -0.7553403f, -3f);
string[] items;
items = Enum.GetNames(enumtype);
// <refactor> move to global parameter
int PLAYERSTARS = PlayerPrefs.GetInt("PLAYER_STARS");
//get player stars amount
LinksContainer.Instance.SHOP_PLAYER_STARS_AMOUNT.text = PLAYERSTARS.ToString();
// destroy all items of old tab
if (SHOP_ITEM_CONTAINER.childCount > 0)
{
for (int i = 0; i < SHOP_ITEM_CONTAINER.childCount; i++)
{
Destroy(SHOP_ITEM_CONTAINER.GetChild(i).gameObject);
}
}
// coef for translate of items and scrollbar
_scrollcoef = items.Length*0.35f - 1.2f;
_scrollbarcoef = (items.Length*0.35f - 1.2f)/1f;
if (items.Length < 4)
{
_isstatic = true;
}
else
{
_isstatic = false;
}
for (int i = 0; i < items.Length; i++)
{
Transform shopitemback =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.CUSTOMIZE_ITEM_BACK);
if (param == 1)
{
AnimWindow animWindow = shopitemback.GetComponent<AnimWindow>();
if (animWindow != null)
{
Destroy(animWindow);
}
shopitemback.localScale = new Vector3(Camera.main.orthographicSize, Camera.main.orthographicSize, Camera.main.orthographicSize);
}
// set item price
TZTextMesh itemprice = shopitemback.FindChild("ItemPrice").GetComponent<TZTextMesh>();
int price = CustomizationContainer.Instance.Customizations[i].Price;
itemprice.text = CustomizationContainer.Instance.Customizations[i].Price.ToString();
TZTextMesh texttm = shopitemback.FindChild("Text").GetComponent<TZTextMesh>();
texttm.text = CustomizationContainer.Instance.Customizations[i].Description;
shopitemback.name = CustomizationContainer.Instance.Customizations[i].Id.ToString();
shopitemback.parent = SHOP_ITEM_CONTAINER;
Transform itemicon =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(ObjectsEnum.CUSTOMIZE_ITEM);
itemicon.localScale = Vector3.one * Camera.main.orthographicSize;
itemicon.parent = shopitemback;
shopitemback.localPosition = new Vector3(0, (0.4f - i*0.35f), 0);
itemicon.localPosition = ITEM_ICON_POS - Vector3.up * 0.021f;
tk2dSprite itemsprite = itemicon.GetComponent<tk2dSprite>();
itemsprite.spriteId = itemsprite.GetSpriteIdByName(items[i]);
TZButton itembutton = shopitemback.GetComponent<TZButton>();
itembutton.messageParam = CustomizationContainer.Instance.Customizations[i].Id.ToString();
itembutton.messageName = "BuyCustomization";
GameObject gameObject = shopitemback.FindChild("ItemCount").gameObject;
Destroy(gameObject);
tk2dSprite counter = shopitemback.FindChild("Counter").GetComponent<tk2dSprite>();
if (CustomizationContainer.Instance.Customizations[i].IsPurchased == true)
{
counter.spriteId = counter.GetSpriteIdByName("counteryes");
itembutton.messageName = "UseCustomization";
if (CustomizationContainer.Instance.Customizations[i].IsUsed == true)
{
tk2dSprite labelok = shopitemback.FindChild("BackLabel").GetComponent<tk2dSprite>();
labelok.spriteId = labelok.GetSpriteIdByName("labelok");
tk2dSprite tk2DSprite = shopitemback.GetComponent<tk2dSprite>();
tk2DSprite.spriteId = tk2DSprite.GetSpriteIdByName("pressed_shop_button");
itembutton.sprite_down = "active_shop_button";
itembutton.sprite_up = "pressed_shop_button";
}
}
else
{
Destroy(shopitemback.FindChild("BackLabel").gameObject);
Destroy(counter.gameObject);
}
if (PLAYERSTARS < price)
{
if (CustomizationContainer.Instance.Customizations[i].IsPurchased == false)
{
itembutton._isblocked = true;
Transform disablelayer =
LinksContainer.Instance.ObjectInstanceBuilder.BuildObject(
ObjectsEnum.DISABLE_ITEM_LAYER);
disablelayer.parent = shopitemback;
disablelayer.localPosition = new Vector3(0, 0, -0.2f);
}
}
TZGUIController.ChangeLayer(shopitemback, gameObject.layer);
}
}
}
public override void Confirm()
{
if (_currenttab == 0)
{
int itemcount = PlayerPrefs.GetInt(_itembuytype);
itemcount++;
PlayerPrefs.SetInt(_itembuytype, itemcount);
int price = (int) Enum.Parse(typeof (SHOPITEMSENUM), _itembuytype);
int PLAYERSTARS = PlayerPrefs.GetInt("PLAYER_STARS");
if (PLAYERSTARS >= price)
{
PlayerPrefs.SetInt("PLAYER_STARS", (PLAYERSTARS - price));
if (_itembuyObject != null)
{
TZTextMesh ic = _itembuyObject.FindChild("ItemCount").GetComponent<TZTextMesh>();
ic.text = itemcount.ToString();
}
}
}else if (_currenttab == 1)
{
int custid = int.Parse(_itembuytype);
int price = CustomizationContainer.Instance.Customizations[custid].Price;
int PLAYERSTARS = PlayerPrefs.GetInt("PLAYER_STARS");
if (PLAYERSTARS >= price)
{
PlayerPrefs.SetInt("PLAYER_STARS", (PLAYERSTARS - price));
LinksContainer.Instance.SHOP_PLAYER_STARS_AMOUNT.text = (PLAYERSTARS - price).ToString();
CustomizationContainer.Instance.Customizations[custid].IsPurchased = true;
}
CustomizationContainer.Instance.SavePurchasedStat();
}
else if (_currenttab == 2)
{
string[] param = QuestParam.Split('_');
QuestsContainer.Instance.questsUsing[int.Parse(param[0])] = 1;
QuestsContainer.Instance.SaveQuestsStat();
int price = int.Parse(param[1]);
int PLAYERSTARS = PlayerPrefs.GetInt("PLAYER_STARS");
if (PLAYERSTARS >= price)
{
PlayerPrefs.SetInt("PLAYER_STARS", (PLAYERSTARS - price));
LinksContainer.Instance.SHOP_PLAYER_STARS_AMOUNT.text = (PLAYERSTARS - price).ToString();
}
}
UpdateWindow();
}
private void setItemBuyType(string buytype)
{
_itembuytype = buytype;
_itembuyObject = GameObject.Find(buytype).transform;
}
}