コード例 #1
0
    public virtual void Init(Animator animator, AI_Brain brain, AI_Behaviour behaviour)
    {
        if (_initialized == false)
        {
            DisableState();
            _brain     = brain;
            _animator  = animator;
            _behaviour = behaviour;

            if (_behaviour != null)
            {
                m_fields = this.GetType()
                           .GetFields(BindingFlags.Instance | BindingFlags.Public)
                           .Where(field => field.GetCustomAttribute <AI_LinkData>() != null && field.FieldType.IsGenericType)
                           .ToArray();

                t_fields = _behaviour.GetType()
                           .GetFields(BindingFlags.Instance | BindingFlags.Public)
                           .Where(field => field.GetCustomAttribute <AI_LinkData>() != null && field.FieldType.IsGenericType)
                           .ToArray();

                m_eventMethods = this.GetType()
                                 .GetMethods(BindingFlags.Instance | BindingFlags.Public);

                LinkData();
                InitEvents();
            }

            _initialized = true;
        }
    }
コード例 #2
0
        public void InstallBrain(AI_Brain brain)
        {
            if (IsBrainInstalled == true)
            {
                Debug.Log("Brain was already installed!!");
                return;
            }

            Debug.Log($"Brain was installed!! Brain name is '{brain.name}'");
            this.brain = brain;
            enabled    = true;
        }
コード例 #3
0
    public void Awake()
    {
        // Create an instance
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Destroy(this.gameObject);
        }

        // Get required components
        PlayerCards = GetComponent <PlayerCardController>();
        Brain       = GetComponent <AI_Brain>();
    }