예제 #1
0
    /// <summary>
    /// Destory script based on the behaviourIndex
    /// </summary>
    /// <param name="behaviourIndex">index of behaviour</param>
    private void DestroyScript(int behaviourIndex)
    {
        switch (behaviourIndex)
        {
        case 0:
            UnityEngine.Object.DestroyImmediate(controller.GetComponent <IdleBehaviour>());
            break;

        case 1:
            MovementBehaviour behaviour = controller.GetComponent <MovementBehaviour>();
            List <Type>       types     = behaviour.OnDestroy();
            UnityEngine.Object.DestroyImmediate(behaviour);
            DestroyTypes(types);
            break;

        case 2:
            UnityEngine.Object.DestroyImmediate(controller.GetComponent <AttackBehaviour>());
            break;

        case 3:
            UnityEngine.Object.DestroyImmediate(controller.GetComponent <AggroBehaviour>());
            break;
        }
    }