Untitled

mail@pastecode.io avatar
unknown
plain_text
21 days ago
7.3 kB
30
Indexable
Never
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using JetBrains.Annotations;
using Unity.Mathematics;
using UnityEngine;

public class PuyoScript : MonoBehaviour

{
    public int dropSet = 0;
    public int preDropSet = 0;
    public bool Falling = true;
    public bool Rotating = true;
    public bool Left = true;
    public bool Right = true;
    public bool Spawn = true;
    public int Degrees = 0;
    public float gameStart;
    public bool moveNext = false;
    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 (dropSet == 0)
        {
            Falling = false;
            Rotating = false;
            Left = false;
            Right = false;
            Spawn = true;
        }
        if (dropSet == -1)
        {
            Falling = false;
            Rotating = false;
            Left = false;
            Right = false;
            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)
        {
            if (dropSet == -1)
            { transform.Translate(0, 3, 0); }
        }
        {
            if (dropSet == 0)
            { transform.Translate(-5, 0, 0); }
        }
    }
    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(0.5f, 0, 0); }
                if (Right == false)
                { transform.Translate(-0.5f, 0, 0); }
            }
        }

        if (Input.GetKeyDown(KeyCode.Z))
        {
            if (Rotating == true)
            {
                transform.Rotate(0, 0, -90);
                if (Left == false)
                { transform.Translate(-0.5f, 0, 0); }
                if (Right == false)
                { transform.Translate(0.5f, 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 = true;
        }
        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 = false;
        }
        if (Other.gameObject.layer == 5)
        {
            Falling = true;
            Rotating = true;
            Left = false;
            Right = true;
            Spawn = false;
        }
        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;
        }
        if (Other.gameObject.layer == 8)
        {
            Falling = false;
            Rotating = false;
            Left = false;
            Right = false;
            Spawn = false;
            dropSet = 0;
        }
        if (Other.gameObject.layer == 9)
        {
            Falling = false;
            Rotating = false;
            Left = false;
            Right = false;
            Spawn = false;
            dropSet = -1;
        }
    }
}
Leave a Comment