Untitled

mail@pastecode.io avatar
unknown
plain_text
25 days ago
5.5 kB
13
Indexable
Never
using System.Collections;
using System.Collections.Generic;
using JetBrains.Annotations;
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 Left = true;
    public bool Right = true;
    public bool Spawn = false;
    public int Degrees = 0;
    public Color[] puyo;
    public GameObject [] puyo2;
    int puyotypeIndex;
    public LayerMask layerNumber;
    public Ray rayNumber;
    public RaycastHit hitNumber;

    void Start()
    {if (dropSet == 1) 
    {Falling = true;
    Rotating = true;
    Left = true;
    Right = true;
    Spawn = true;}
    if (transform.position.y == 5.5)
        if (transform.eulerAngles.z == 0)
        {transform.Rotate (0, 0, 0);}
        if (transform.eulerAngles.z == 180)
        {transform.Rotate (0, 0, -180);}
        if (transform.eulerAngles.z == 270)
        {transform.Rotate (0, 0, -270);}
        if (transform.eulerAngles.z == 90)
        {transform.Rotate (0, 0, -90);}
    
    if (Spawn == false)
        {Instantiate(puyo2[puyotypeIndex], new Vector2 (-12.5f, 5f),puyo2[puyotypeIndex].transform.rotation);
        Spawn = false;
        dropSet ++;}}
    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) 
            {transform.Rotate (0, 0, 90);
            if (Left == false)
            {transform.Translate (-1f, 0, 0);}
            if (Right == false)
            {transform.Translate (1f, 0, 0);}
            }
        }

        if (Input.GetKeyDown(KeyCode.Z)) {
            if (Rotating == true) 
            {transform.Rotate (0, 0, -90);
            if (Left == false)
            {transform.Translate (1f, 0, 0);}
            if (Right == false)
            {transform.Translate (-1f, 0, 0);}
            }
        }

        if (Input.GetKey(KeyCode.LeftArrow))
            if (transform.position.x > -14.5) {
                if (Left == true)
                    if (transform.eulerAngles.z == 0)
                        {transform.Translate(-0.5f, 0, 0);}}
        if (Input.GetKey(KeyCode.LeftArrow))    
            if (transform.position.x > -14) {
                if (Left == true)
                    if (transform.eulerAngles.z == 90)
                        {transform.Translate(0, 0.5f, 0);}}
        if (Input.GetKey(KeyCode.LeftArrow))    
            if (transform.position.x > -14.5) {
                if (Left == true)
                    if (transform.eulerAngles.z == 180)
                        {transform.Translate(0.5f, 0, 0);}
        if (Input.GetKey(KeyCode.LeftArrow))    
            if (transform.position.x > -14) {
                if (Left == true)
                    if (transform.eulerAngles.z == 270)
                        {transform.Translate(0, -0.5f, 0);}
            }
        }

        if (Input.GetKey(KeyCode.RightArrow)) {
            if (transform.position.x < -9.5) {
                if (Right == true) 
                    if (transform.eulerAngles.z == 0)
                        {transform.Translate(0.5f, 0, 0);}}
        if (Input.GetKey(KeyCode.RightArrow))    
            if (transform.position.x < -10) {
                if (Right == true) 
                    if (transform.eulerAngles.z == 90)
                        {transform.Translate(0, -0.5f, 0);}}
        if (Input.GetKey(KeyCode.RightArrow))    
            if (transform.position.x < -9.5) {
                if (Right == true)     
                    if (transform.eulerAngles.z == 180)
                        {transform.Translate(-0.5f, 0, 0);}}
        if (Input.GetKey(KeyCode.RightArrow))    
            if (transform.position.x < -10) {
                if (Right == true) 
                    if (transform.eulerAngles.z == 270)
                        {transform.Translate(0, 0.5f, 0);}
            }
        }
    }
void OnTriggerEnter2D(Collider2D Other)
    {if (Other.gameObject.layer == 3)
        {Falling = false;
        Rotating = false;
        Left = false;
        Right = false;
        Spawn = false;}
    if (Other.gameObject.layer == 2)
        {Falling = false;
        Rotating = false;
        Left = false;
        Right = false;
        Spawn = false;}
    if (Other.gameObject.layer == 4)
        {Falling = true;
        Rotating = true;
        Left = true;
        Right = false;}
        Spawn = true;
    if (Other.gameObject.layer == 5)
        {Falling = true;
        Rotating = true;
        Left = false;
        Right = true;
        Spawn = true;}
    if (Other.gameObject.layer == 0)
        {Falling = false;
        Rotating = false;
        Left = false;
        Right = false;
        Spawn = false;}
    if (Other.gameObject.layer == 1)
        {Falling = true;
        Rotating = true;
        Left = false;
        Right = false;
        Spawn = false;}    
    }
}
Leave a Comment