And now for the fun part – testing our implementation. It's going to be an easy one since all we need to do is attach the following client class to an empty GameObject in a Unity scene:
using UnityEngine;
using System.Collections.Generic;
namespace Chapter.Strategy {
public class ClientStrategy : MonoBehaviour {
private GameObject _drone;
private List<IManeuverBehaviour>
_components = new List<IManeuverBehaviour>();
private void SpawnDrone() {
_drone =
GameObject.CreatePrimitive(PrimitiveType.Cube);
_drone.AddComponent<Drone>();
_drone.transform.position =
Random.insideUnitSphere * 10;
ApplyRandomStrategies();
}
private void ApplyRandomStrategies() {
_components.Add(
_drone.AddComponent<WeavingManeuver>());
_components.Add(
_drone.AddComponent...