public override List <string> GetDataForSave() { List <GameObject> balls = Mirror.GetMirror().Balls; List <string> data = (from ball in balls select ball.name).ToList(); return(data); }
public static Mirror GetMirror() { if (_instance == null) { GameObject instanceObject = new GameObject(); _instance = instanceObject.AddComponent <Mirror>(); } return(_instance); }
public bool TryBuySomething(uint price, GameObject prefab) { if (m_playerWallet.CanDecreaseMoney(price)) { Mirror.GetMirror().AddBall(prefab); OnSuccessBuy?.Invoke(); m_playerWallet.DecreaseMoney(price); return(true); } OnFailedToBuy?.Invoke(); return(false); }
public void Shoot() { m_cannonballRigidbody.constraints = RigidbodyConstraints.None; float sliderAmount = FindObjectOfType <FireButtonSlider>().SliderAmount; m_cannonballRigidbody.AddForce(m_cannonballRigidbody.transform.forward * m_startImpulsePower * (1 + sliderAmount)); m_cannonballRigidbody.AddTorque(m_cannonballRigidbody.transform.right * m_startImpulsePower * (1 + sliderAmount)); m_cannonballRigidbody.transform.parent = null; m_cannonballRigidbody.GetComponent <CannonBall>().SetAppearance(Mirror.GetMirror().CurrentBall); m_shootParticleSystem.Play(); OnShoot(); m_cannonballRigidbody.GetComponent <CannonBall>().enabled = true; }
public override void LoadData(List <string> data) { BuyButton[] shopButtons = FindObjectsOfType <BuyButton>(); for (int i = 0; i < data.Count; i++) { foreach (var button in shopButtons) { if (button != null && button.TargetPrefab.name == data[i]) { GameObject soldTextPrefab = UnityEngine.Resources.Load("Prefabs/SoldText") as GameObject; Instantiate(soldTextPrefab, button.transform.position, Quaternion.identity); Mirror.GetMirror().AddBall(button.TargetPrefab); Destroy(button.gameObject); } } } }
private void Awake() { _instance = this; }