بزرگترین جشنواره سال راکت! ۵۰ درصد تخفیف شگفت انگیز نوروزی!
از دستش نده!همه ی دایره ها بجز دایره ی آخر به حالت WinGame می روند چیکار کنم که دایره ی آخر هم WinGame بشه
using System.Collections; using System.Collections.Generic; using UnityEngine; public enum State{ InGame, GameOver, WinGame } public class GameManaged : MonoBehaviour { public State current = State.InGame; public SpriteRenderer _Sprite; public GameObject CirclePrefab; public GameObject[] Gm_Circle; public GameObject Gm_MainCircle; public int Gm_MainCircle_Speed; public int NumCir; public int End; void Start() { Gm_Circle = new GameObject[NumCir]; for (int i = 0; i < NumCir; i += 1) { Gm_Circle[i] = Instantiate(CirclePrefab, transform.position, Quaternion.identity) as GameObject; transform.Translate(0,-1,0); } } void Update() { if(current == State.InGame){ Gm_MainCircle.transform.Rotate (0,0,Gm_MainCircle_Speed * Time.deltaTime); } } void Refresh(){ switch (current) { case State.GameOver:{ for (int i = 0; i < Gm_Circle.Length; i++) { Gm_Circle[i].GetComponent <Circle >().currentstate = CircleState.GameOver; } } break; case State.WinGame:{ for (int i = 0; i < Gm_Circle.Length; i++) { Gm_Circle[i].GetComponent <Circle >().currentstate = CircleState.Winner; } _Sprite.color = Color.Lerp (Color.white , Color.green , 1f); } break; } } public void GetGameState(State get){ current = get; Refresh(); } public void GetFelan(){ End ++; if(End == NumCir){ GetGameState (State.WinGame); } } } // کد بعدی using System.Collections; using System.Collections.Generic; using UnityEngine; public enum CircleState { CanMove, InMove, End, GameOver, Winner } public class Circle : MonoBehaviour { public CircleState currentstate = CircleState.CanMove; LineRenderer _LineRenderer; public float TimeWin = 1f; public Vector3 [] This; public Vector3 Target; public Transform _MainCircle; GameManaged _Game; void Start() { _LineRenderer = GetComponent <LineRenderer >(); _MainCircle = GameObject .FindGameObjectWithTag ("MainCircle").GetComponent <Transform >(); _Game = FindObjectOfType <GameManaged >(); } void Update() { switch (currentstate) { case CircleState.CanMove:{ if (Input .GetMouseButtonDown(0)){ Target = new Vector3 (0,Mathf.Round (transform.position.y) + 1,0); currentstate = CircleState.InMove; } } break; case CircleState.InMove:{ transform.position = Vector3.Lerp (transform.position, Target, 0.35f); if (Mathf.Abs(Target.y - transform.position.y) < 0.01f){ currentstate = CircleState.CanMove; } } break; case CircleState.End:{ This[0] = transform.position; This[1] = Vector3.zero; _LineRenderer .SetPositions (This); } break; case CircleState.Winner:{ TimeWin -= 1f * Time.deltaTime; if (TimeWin >= 0){ transform.Translate(-15f * Time.deltaTime,0,0); This[0] = transform.position; This[1] = Vector3.zero; _LineRenderer .SetPositions (This); } } break; } } public void SetParent(){ transform.SetParent (_MainCircle.transform); } void OnTriggerEnter2D(Collider2D other) { if (currentstate == CircleState.InMove){ if (other.tag == "Circle"){ _Game.GetGameState (State.GameOver); currentstate = CircleState.GameOver; } } if (other.tag == "MainCircle"){ _Game.GetFelan(); SetParent(); currentstate = CircleState.End; } } }
به حبیب الله تحریری ماسوله کمک کنید تا مشکل خودش را حل کند؛ اینطور میتوانیم با هم پیشرفت کنیم.
آیا مایل به ارسال نوتیفیکیشن و اخبار از طرف راکت هستید ؟