2
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.3 KiB
C#

using Entitas;
using UnityEngine;
public enum EPointType
{
Red,
Blue,
}
public enum EPointState
{
Create,
CreateWait,
Running,
Destroy,
}
[Game]
public class PointComponent : IComponent
{
public EPointState State;
public EPointType PointType;
public Vector3 CastSpeed;
public float TimeLeft;
}
namespace Game
{
public abstract partial class Util
{
public static void ClearPoint(GameEntity entity)
{
var point = entity.point;
point.State = EPointState.Create;
}
public static void CreatePt(Vector3 pos, Vector3 direction)
{
pos = new Vector3(pos.x, 0, pos.z);
var count = GameRandom.Randint(1, 4);
for (int i = 0; i < count; i++)
{
var pointPos = pos + GameRandom.RandomVector3(-0.4f, 0.4f);
var dir = pointPos - pos + direction;
var cfgId = GameRandom.Roll(0.7f) ? GameConst.PtRedId : GameConst.PtBlueId;
Util.CreateEntity(cfgId, (entity) =>
{
entity.point.CastSpeed = dir;
Util.SetEntityPos(entity, pointPos);
});
}
}
}
}