Untitled
unknown
plain_text
13 days ago
1.6 kB
4
Indexable
Never
using System.Collections; using System.Collections.Generic; using UnityEngine; public class PuyoFall : MonoBehaviour { int set = 1; int preSet = 0; public GameObject[] puyo; public GameObject[] puyo2; void Start() { if (transform.position.y == -5.4) { int puyoIndex = Random.Range(0, puyo.Length); Instantiate(puyo[puyoIndex], new Vector3(-12.5f, 5.5f, 0), puyo[puyoIndex].transform.rotation); } { int puyo2Index = Random.Range(0, puyo2.Length); Instantiate(puyo2[puyo2Index], new Vector3(-12.5f, 4.5f, 0), puyo2[puyo2Index].transform.rotation); } } void Update() { if (set == preSet + 1) if (transform.position.y > -5.5) transform.Translate(0, -0.05f, 0); if (Input.GetKey(KeyCode.LeftArrow)) if (transform.position.x > -14.5) if (transform.position.y > -5.5) transform.Translate(-1, 0, 0); if (Input.GetKey(KeyCode.RightArrow)) if (transform.position.x < -9.5) if (transform.position.y > -5.5) transform.Translate(1, 0, 0); } void OnTriggerEnter(Collider other) { { int puyoIndex = Random.Range(0, puyo.Length); Instantiate(puyo[puyoIndex], new Vector3(-12.5f, 5.5f, 0), puyo[puyoIndex].transform.rotation); } { int puyo2Index = Random.Range(0, puyo2.Length); Instantiate(puyo2[puyo2Index], new Vector3(-12.5f, 4.5f, 0), puyo2[puyo2Index].transform.rotation); } } }
Leave a Comment