Переработать С# скрипт под Android приложение

Цена договорная
15 мая 2021, 17:03 • 2 отклика • 13 просмотров
  • Нужно оптимизировать скрипт, а главное сделать правильную систему сохранения, не обязательно использовать PlayerPrefs, лишь бы работало на Андроид устройствах. Так же проблема моей системы сохранения в том, что один скрипт находиться на разных объектах, и поэтому сохранения из одного объекта переходит к другим. (Если нужно могу прислать объект к которому прикрепляется скрипт, если так будет понятнее). Цена договорна.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

[System.Serializable]
public class Upgrades : MonoBehaviour
{


public GameObject _coinsman;
public GameObject _coinscar;
public GameObject _coinsship;
public GameObject _coinsplane;

public Button Manbutton;
public Button Carbutton;
public Button Shipbutton;
public Button Planebutton;

public Sprite Maxsprite;

public TMP_Text CoinsUptext;
public TMP_Text CoinsUptext1;
public TMP_Text CoinsUptext2;
public TMP_Text CoinsUptext3;

public TMP_Text lvlstext;
public TMP_Text lvlstext1;
public TMP_Text lvlstext2;
public TMP_Text lvlstext3;

public double ClickUpgradeCost;
public double ClickUpgradeCost1;
public double ClickUpgradeCost2;
public double ClickUpgradeCost3;

public MasterSc coin;
public MasterSc CoinsPerSec;

public double lvls;
public double lvls1;
public double lvls2;
public double lvls3;


public void Start()
{
Load();

}
public void Load()
{

lvls = double.Parse(PlayerPrefs.GetString( "lvls", "0"));
ClickUpgradeCost = double.Parse(PlayerPrefs.GetString("ClickUpgradeCost", "20"));
lvls1 = double.Parse(PlayerPrefs.GetString("lvls1", "0"));
ClickUpgradeCost1 = double.Parse(PlayerPrefs.GetString("ClickUpgradeCost1", "20"));
lvls2 = double.Parse(PlayerPrefs.GetString("lvls2", "0"));
ClickUpgradeCost2 = double.Parse(PlayerPrefs.GetString("ClickUpgradeCost2", "20"));
lvls3 = double.Parse(PlayerPrefs.GetString("lvls3", "0"));
ClickUpgradeCost3 = double.Parse(PlayerPrefs.GetString("ClickUpgradeCost3", "20"));
if (lvls == 5)
{
Manbutton.transform.localScale = new Vector3(2, 1.3f, 1);
Manbutton.enabled = false;
CoinsUptext.enabled = false;
Manbutton.GetComponent<Image>().sprite = Maxsprite;
Destroy(_coinsman);
}
if (lvls1 == 5)
{
Carbutton.transform.localScale = new Vector3(2, 1.3f, 1);
Carbutton.enabled = false;
CoinsUptext1.enabled = false;
Carbutton.GetComponent<Image>().sprite = Maxsprite;
Destroy(_coinscar);
}
if (lvls2 >= 5)
{
Shipbutton.transform.localScale = new Vector3(2, 1.3f, 1);
Shipbutton.enabled = false;
CoinsUptext2.enabled = false;
Shipbutton.GetComponent<Image>().sprite = Maxsprite;
Destroy(_coinsship);
}
if (lvls3 >= 5)
{
Planebutton.transform.localScale = new Vector3(2, 1.3f, 1);
Planebutton.enabled = false;
CoinsUptext3.enabled = false;
Planebutton.GetComponent<Image>().sprite = Maxsprite;
Destroy(_coinsplane);
}


}

public void Update()
{
CoinsUptext.text = "" + ClickUpgradeCost.ToString("F0");
CoinsUptext1.text = "" + ClickUpgradeCost1.ToString("F0");
CoinsUptext2.text = "" + ClickUpgradeCost2.ToString("F0");
CoinsUptext3.text = "" + ClickUpgradeCost3.ToString("F0");

lvlstext.text = lvls.ToString("F0") + "/5";
lvlstext1.text = lvls1.ToString("F0") + "/5";
lvlstext2.text = lvls2.ToString("F0") + "/5";
lvlstext3.text = lvls3.ToString("F0") + "/5";


PlayerPrefs.SetString( "lvls", lvls.ToString());
PlayerPrefs.SetString("ClickUpgradeCost", ClickUpgradeCost.ToString());
PlayerPrefs.SetString("lvls1", lvls1.ToString());
PlayerPrefs.SetString("ClickUpgradeCost1", ClickUpgradeCost1.ToString());
PlayerPrefs.SetString("lvls2", lvls2.ToString());
PlayerPrefs.SetString("ClickUpgradeCost2", ClickUpgradeCost2.ToString());
PlayerPrefs.SetString("lvls3", lvls3.ToString());
PlayerPrefs.SetString("ClickUpgradeCost3", ClickUpgradeCost3.ToString());


}

public void ClickUpgradeMan()
{
if (coin.Coin >= ClickUpgradeCost)
{
coin.Coin -= ClickUpgradeCost;
ClickUpgradeCost *= 1.2;

CoinsPerSec.CoinsPerSec += 0.3;
lvls += 1;
if (lvls == 5)
{
Manbutton.transform.localScale = new Vector3(2, 1.3f, 1);
Manbutton.enabled = false;
CoinsUptext.enabled = false;
Manbutton.GetComponent<Image>().sprite = Maxsprite;
Destroy(_coinsman);
}
}

}

public void ClickUpgradeCar()
{
if (coin.Coin >= ClickUpgradeCost1)
{
coin.Coin -= ClickUpgradeCost1;
ClickUpgradeCost1 *= 1.2;

CoinsPerSec.CoinsPerSec += 0.4;
lvls1 += 1;
if (lvls1 == 5)
{
Carbutton.transform.localScale = new Vector3(2, 1.3f, 1);
Carbutton.enabled = false;
CoinsUptext1.enabled = false;
Carbutton.GetComponent<Image>().sprite = Maxsprite;
Destroy(_coinscar);
}

}

}
public void ClickUpgradeShip()
{
if (coin.Coin >= ClickUpgradeCost2)
{
coin.Coin -= ClickUpgradeCost2;
ClickUpgradeCost2 *= 1.2;

CoinsPerSec.CoinsPerSec += 0.7;
lvls2 += 1;
if (lvls2 >= 5)
{
Shipbutton.transform.localScale = new Vector3(2, 1.3f, 1);
Shipbutton.enabled = false;
CoinsUptext2.enabled = false;
Shipbutton.GetComponent<Image>().sprite = Maxsprite;
Destroy(_coinsship);
}

}

}
public void ClickUpgradePlane()
{
if (coin.Coin >= ClickUpgradeCost3)
{
coin.Coin -= ClickUpgradeCost3;
ClickUpgradeCost3 *= 1.2;

CoinsPerSec.CoinsPerSec += 1;
lvls3 += 1;
if (lvls3 >= 5)
{
Planebutton.transform.localScale = new Vector3(2, 1.3f, 1);
Planebutton.enabled = false;
CoinsUptext3.enabled = false;
Planebutton.GetComponent<Image>().sprite = Maxsprite;
Destroy(_coinsplane);
}

}

}

}
Отзывы
Avatar r50 a6ce93fe35b158fd29ba0e8681c918c22117160e9586a56eee4ffbc20df9bda1
Заказчик
Все прошло успешно и быстро, так же порадовала договоренность по цене.
3 года назад
Avatar r50 a6ce93fe35b158fd29ba0e8681c918c22117160e9586a56eee4ffbc20df9bda1
Фрилансер
 
3 года назад