Untitled

 avatar
unknown
plain_text
a year ago
3.9 kB
1
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;
    private bool Falling = true;
    private bool Rotating = true;
    private bool ReSpawn = 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);}
        if (ReSpawn == true)
            Instantiate(puyo2[puyotypeIndex], new Vector2 (-12.5f, 5f),puyo2[puyotypeIndex].transform.rotation);
                ReSpawn = false;
            }
        }
    }

  void OnTriggerEnter2D(Collider2D Other)
{ 
    Falling = false;
    Rotating = false;
    ReSpawn = true;

}
}
Leave a Comment