/// <summary> /// 检查 /// </summary> public void UpdateBehaviorType(MovingEntity entity, SteeringBehavior.Type_ type) { if (type == Type) { return; } Behavior = SteeringBehavior.Create(entity, type); }
// Use this for initialization void Start() { _movingEntity = GetComponent <MovingEntity>(); if (_movingEntity == null) { Debug.LogError("Need Script: MovingEntity"); } UpdateState(StateType.Patrol); }
/// <summary> /// 工厂方法 /// </summary> /// <param name="entity"></param> /// <param name="type"></param> /// <returns></returns> public static SteeringBehavior Create(MovingEntity entity, SteeringBehavior.Type_ type) { if (type == Type_.seek) { return(new Seek(entity)); } else if (type == Type_.wall_avoidance) { return(new WallAvoidance(entity)); } else if (type == Type_.wander) { return(new Wander(entity)); } return(null); }
public WallAvoidance(MovingEntity entity) : base(entity, "WallAvoidance", Type_.wall_avoidance) { }
protected SteeringBehavior(MovingEntity entity, string name, SteeringBehavior.Type_ type) { _movingEntity = entity; BehaviorName = name; Type = type; }
public Wander(MovingEntity entity) : base(entity, "Wander", Type_.wander) { }
public Seek(MovingEntity movingEntity) : base(movingEntity, "Seek", Type_.seek) { }