Untitled
unknown
plain_text
2 years ago
3.9 kB
21
Indexable
using System.Collections;
using System.Collections.Generic;
using Unity.Mathematics;
using UnityEngine;
public class PuyoScript : MonoBehaviour
{
public int dropSet = 1;
public int preDropSet = 0;
public bool Falling = true;
public bool Rotating = true;
public bool Spawn = false;
public Color[] puyo;
public GameObject [] puyo2;
int puyotypeIndex;
void Start()
{
}
void Update()
{
if (Falling == true)
{if (transform.eulerAngles.z == 0)
transform.Translate (0, -0.01f, 0);
if (transform.eulerAngles.z == 90)
transform.Translate (-0.01f, 0, 0);
if (transform.eulerAngles.z == 180)
transform.Translate (0, 0.01f, 0);
if (transform.eulerAngles.z == 270)
transform.Translate (0.01f, 0, 0);}
if (Input.GetKeyDown(KeyCode.X)) {
if (Rotating == true)
if (transform.position.x > -14.5)
if (transform.position.x < -9.5)
{
transform.Rotate (0, 0, 90);
}
}
if (Input.GetKeyDown(KeyCode.Z)) {
if (Rotating == true)
if (transform.position.x > -14.5)
if (transform.position.x < -9.5)
{
transform.Rotate (0, 0, -90);
}
}
if (Input.GetKey(KeyCode.LeftArrow))
if (transform.position.x > -14.5) {
if (Falling == true)
if (transform.eulerAngles.z == 0)
{transform.Translate(-0.5f, 0, 0);}}
if (Input.GetKey(KeyCode.LeftArrow))
if (transform.position.x > -14) {
if (Falling == true)
if (transform.eulerAngles.z == 90)
{transform.Translate(0, 0.5f, 0);}}
if (Input.GetKey(KeyCode.LeftArrow))
if (transform.position.x > -14.5) {
if (Falling == true)
if (transform.eulerAngles.z == 180)
{transform.Translate(0.5f, 0, 0);}
if (Input.GetKey(KeyCode.LeftArrow))
if (transform.position.x > -14) {
if (Falling == true)
if (transform.eulerAngles.z == 270)
{transform.Translate(0, -0.5f, 0);}
}
}
if (Input.GetKey(KeyCode.RightArrow)) {
if (transform.position.x < -9.5) {
if (Falling == true)
if (transform.eulerAngles.z == 0)
{transform.Translate(0.5f, 0, 0);}}
if (Input.GetKey(KeyCode.RightArrow))
if (transform.position.x < -10) {
if (Falling == true)
if (transform.eulerAngles.z == 90)
{transform.Translate(0, -0.5f, 0);}}
if (Input.GetKey(KeyCode.RightArrow))
if (transform.position.x < -9.5) {
if (Falling == true)
if (transform.eulerAngles.z == 180)
{transform.Translate(-0.5f, 0, 0);}}
if (Input.GetKey(KeyCode.RightArrow))
if (transform.position.x < -10) {
if (Falling == true)
if (transform.eulerAngles.z == 270)
{transform.Translate(0, 0.5f, 0);}
}
}
}
void OnTriggerEnter2D(Collider2D Other)
{
Falling = false;
Rotating = false;
Spawn = true;
if (Spawn == true)
{Instantiate(puyo2[puyotypeIndex], new Vector2 (-12.5f, 5f),puyo2[puyotypeIndex].transform.rotation);
Spawn = false;}
}
}Editor is loading...
Leave a Comment