您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
36 行
777 B
36 行
777 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.Entities;
|
|
using Unity.Transforms;
|
|
using UnityEngine;
|
|
using Unity.Collections;
|
|
using Unity.Mathematics;
|
|
using Unity.Jobs;
|
|
|
|
public class BallGoalCheckSystem : JobComponentSystem
|
|
{
|
|
protected override JobHandle OnUpdate(JobHandle inputDeps)
|
|
{
|
|
Entities
|
|
.WithAll<BallTag>()
|
|
.WithStructuralChanges()
|
|
.ForEach((Entity entity, ref Translation trans) =>
|
|
{
|
|
float3 pos = trans.Value;
|
|
float bound = GameManager.main.xBound;
|
|
|
|
if (pos.x >= bound)
|
|
{
|
|
GameManager.main.PlayerScored(0);
|
|
EntityManager.DestroyEntity(entity);
|
|
}
|
|
else if (pos.x <= -bound)
|
|
{
|
|
GameManager.main.PlayerScored(1);
|
|
EntityManager.DestroyEntity(entity);
|
|
}
|
|
}).Run();
|
|
|
|
return inputDeps;
|
|
}
|
|
}
|