We will implement two classes—FormationPattern and FormationManager:
- Create the FormationPattern pseudo-abstract class:
using UnityEngine; using System.Collections; using System.Collections.Generic; public class FormationPattern: MonoBehaviour { public int numOfSlots; public GameObject leader; }
- Implement the Start function:
void Start() { if (leader == null) leader = transform.gameObject; }
- Define the function for getting the position for a given slot:
public virtual Vector3 GetSlotLocation(int slotIndex) { return Vector3.zero; }
- Define the function for retrieving, if a given number of slots is supported by the formation:
public bool SupportsSlots(int slotCount) { return slotCount <= numOfSlots; }
- Implement the ...