40 lines
1,019 B
C#
Executable file
40 lines
1,019 B
C#
Executable file
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class BubbleBlock : MonoBehaviour
|
|
{
|
|
private GameObject Player;
|
|
private bool Up;
|
|
public float TimeUp;
|
|
public float Speed;
|
|
|
|
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
|
{
|
|
if (collision.tag == "Player")
|
|
{
|
|
Player = collision.gameObject;
|
|
Up = true;
|
|
Player.GetComponent<Move>().BB = this;
|
|
Invoke("Stop", TimeUp);
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (Up)
|
|
{
|
|
transform.Translate(Vector3.up * Speed * Time.deltaTime);
|
|
Player.gameObject.transform.position = transform.position;
|
|
}
|
|
}
|
|
|
|
public void Stop()
|
|
{
|
|
Player.GetComponent<Rigidbody2D>().WakeUp();
|
|
Up = false;
|
|
Player.GetComponent<Rigidbody2D>().linearVelocity = Vector2.up * Player.GetComponent<Move>().jumpforce;
|
|
Destroy(this.gameObject);
|
|
}
|
|
}
|