Commit 60565d35 authored by LiLiuZhou's avatar LiLiuZhou

1

parent abf592aa
...@@ -19,6 +19,8 @@ public class GameController : MonoBehaviour ...@@ -19,6 +19,8 @@ public class GameController : MonoBehaviour
public Transform Fruits; public Transform Fruits;
public bool IsGameOver = false;
//准备销毁的水果集合 //准备销毁的水果集合
public LinkedList<GameObject> TempList = new LinkedList<GameObject>(); public LinkedList<GameObject> TempList = new LinkedList<GameObject>();
......
...@@ -37,6 +37,15 @@ public class Fruit : MonoBehaviour ...@@ -37,6 +37,15 @@ public class Fruit : MonoBehaviour
private void OnCollisionEnter2D(Collision2D collision) private void OnCollisionEnter2D(Collision2D collision)
{ {
if (GameController.GetInstance().IsGameOver)
return;
if (rig2D.bodyType == RigidbodyType2D.Kinematic)
{
GameController.GetInstance().IsGameOver = true;
Debug.LogError("游戏结束");
}
if (collision.gameObject.CompareTag("Bottom")) if (collision.gameObject.CompareTag("Bottom"))
{ {
if (!BottomColiderIsCD) if (!BottomColiderIsCD)
...@@ -106,7 +115,7 @@ public class Fruit : MonoBehaviour ...@@ -106,7 +115,7 @@ public class Fruit : MonoBehaviour
Vector2 Velocity = Vector2 Velocity =
gameObject.GetComponent<Rigidbody2D>().velocity.magnitude > collision.gameObject.GetComponent<Rigidbody2D>().velocity.magnitude? gameObject.GetComponent<Rigidbody2D>().velocity.magnitude > collision.gameObject.GetComponent<Rigidbody2D>().velocity.magnitude?
gameObject.GetComponent<Rigidbody2D>().velocity : collision.gameObject.GetComponent<Rigidbody2D>().velocity; gameObject.GetComponent<Rigidbody2D>().velocity : collision.gameObject.GetComponent<Rigidbody2D>().velocity;
Obj.GetComponent<Fruit>().rig2D = Obj.GetComponent<Rigidbody2D>();
Obj.GetComponent<Rigidbody2D>().velocity = Velocity; Obj.GetComponent<Rigidbody2D>().velocity = Velocity;
#region 上报水果合成 #region 上报水果合成
......
using System; #define Test
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
[RequireComponent(typeof(EventTrigger))] [RequireComponent(typeof(EventTrigger))]
public class TouchPanel : BasePanel public class TouchPanel : BasePanel
{ {
//相机 //相机
public Camera cam; public Camera cam;
...@@ -122,8 +126,11 @@ public class TouchPanel : BasePanel ...@@ -122,8 +126,11 @@ public class TouchPanel : BasePanel
RequestNewFruitType(); RequestNewFruitType();
return; return;
} }
#if Test
int NowFruitType = 7;
#else
int NowFruitType = InstantFruitList.Dequeue(); int NowFruitType = InstantFruitList.Dequeue();
#endif
NowFruit = GameObject.Instantiate(Resources.Load<GameObject>("Fruits/" + NowFruitType)); NowFruit = GameObject.Instantiate(Resources.Load<GameObject>("Fruits/" + NowFruitType));
NowFruit.name = NowFruitType.ToString(); NowFruit.name = NowFruitType.ToString();
NowFruit.transform.position = new Vector3(0, GameController.GetInstance().RedLinePosY); NowFruit.transform.position = new Vector3(0, GameController.GetInstance().RedLinePosY);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment