示例#1
0
    public override void Initialize()
    {
        base.Initialize();

        AISensor = GetComponentInChildren <AISensor>();
        if (AISensor != null)
        {
            AISensor.Initialize(this);
        }

        Brain = GetComponent <AIBrain>();
        if (Brain != null)
        {
            Brain.Initialize(this, AISensor);
        }

        ////FSM TESTING
        //FSMState normalState = FSMManager.GetState("ZombieWander");
        //if (normalState != null)
        //    EntityFSM.ChangeState(normalState);
        //else
        //{
        //    Debug.LogError("Can't find Zombie Wander state");
        //}
    }
示例#2
0
    public void Initialize(Character character)
    {
        _parentCharacter = character;

        WorkingMemory = new WorkingMemory();
        WorkingMemory.Initialize(_parentCharacter);

        BlackBoard = new BlackBoard();
        Sensor     = new AISensor();
        Sensor.Initialize(_parentCharacter);
        TargetingSystem = new AITargeting();
        TargetingSystem.Initialize(_parentCharacter);
        WeaponSystem = new AIWeapon();
        WeaponSystem.Initialize(_parentCharacter);
        Planner = new GoapPlanner(this);


        _goals              = GameManager.Inst.DBManager.DBHandlerAI.GetCharacterGoalSet(_parentCharacter.GoapID);
        _actions            = GameManager.Inst.DBManager.DBHandlerAI.GetCharacterActionSet(_parentCharacter.GoapID);
        _currentWorldStates = new List <GoapWorldState>();

        _parentCharacter.MyEventHandler.OnCurrentActionComplete -= OnCurrentActionComplete;
        _parentCharacter.MyEventHandler.OnCurrentActionComplete += OnCurrentActionComplete;
        _parentCharacter.MyEventHandler.OnPerFrameTimer         -= PerFrameUpdate;
        _parentCharacter.MyEventHandler.OnPerFrameTimer         += PerFrameUpdate;

        //update parent character for each action
        foreach (GoapAction action in _actions)
        {
            action.ParentCharacter = _parentCharacter;
        }

        //BlackBoard.PatrolLoc = new Vector3(63.9f, 0.3f, -13.3f);
        //BlackBoard.PatrolRange = new Vector3(30, 10, 15);

        if (ControlType != AIControlType.Player)
        {
            BlackBoard.GuardLevel = 1;
            _parentCharacter.SendCommand(CharacterCommands.SetAlert);
        }

        _currentGoal   = null;
        _currentAction = null;


        _parentCharacter.MyEventHandler.OnOneSecondTimer += OnOneSecondTimer;
    }
示例#3
0
文件: AI.cs 项目: rotorist/Warzone
	public void Initialize(Character character)
	{
		_parentCharacter = character;

		WorkingMemory = new WorkingMemory();
		WorkingMemory.Initialize(_parentCharacter);

		BlackBoard = new BlackBoard();
		Sensor = new AISensor();
		Sensor.Initialize(_parentCharacter);
		TargetingSystem = new AITargeting();
		TargetingSystem.Initialize(_parentCharacter);
		WeaponSystem = new AIWeapon();
		WeaponSystem.Initialize(_parentCharacter);
		Planner = new GoapPlanner(this);


		_goals = GameManager.Inst.DBManager.DBHandlerAI.GetCharacterGoalSet(_parentCharacter.GoapID);
		_actions = GameManager.Inst.DBManager.DBHandlerAI.GetCharacterActionSet(_parentCharacter.GoapID);
		_currentWorldStates = new List<GoapWorldState>();

		_parentCharacter.MyEventHandler.OnCurrentActionComplete += OnCurrentActionComplete;
		_parentCharacter.MyEventHandler.OnPerFrameTimer += PerFrameUpdate;

		//update parent character for each action
		foreach(GoapAction action in _actions)
		{
			action.ParentCharacter = _parentCharacter;
		}

		//BlackBoard.PatrolLoc = new Vector3(63.9f, 0.3f, -13.3f);
		//BlackBoard.PatrolRange = new Vector3(30, 10, 15);

		if(ControlType != AIControlType.Player)
		{
			BlackBoard.GuardLevel = 1;
			_parentCharacter.SendCommand(CharacterCommands.SetAlert);
		}

		_currentGoal = null;
		_currentAction = null;


		_parentCharacter.MyEventHandler.OnOneSecondTimer += OnOneSecondTimer;
	
	}
示例#4
0
    protected override void Awake()
    {
        InitStats();

        AISensor = GetComponentInChildren <AISensor>();
        if (AISensor != null)
        {
            AISensor.Initialize(this);
        }

        Brain = GetComponent <AIBrain>();
        if (Brain != null)
        {
            Brain.Initialize(this, AISensor);
        }

        base.Awake();
    }
示例#5
0
文件: AI.cs 项目: tegates/Warzone
    public void Initialize(Character character)
    {
        _parentCharacter = character;

        WorkingMemory = new WorkingMemory();
        WorkingMemory.Initialize(_parentCharacter);

        BlackBoard = new BlackBoard();
        Sensor = new AISensor();
        Sensor.Initialize(_parentCharacter);
        TargetingSystem = new AITargeting();
        TargetingSystem.Initialize(_parentCharacter);
        WeaponSystem = new AIWeapon();
        WeaponSystem.Initialize(_parentCharacter);
        Planner = new GoapPlanner(this);

        _goals = GameManager.Inst.DBManager.DBHandlerAI.GetCharacterGoalSet(_parentCharacter.ID);
        _actions = GameManager.Inst.DBManager.DBHandlerAI.GetCharacterActionSet(_parentCharacter.ID);
        _currentWorldStates = new List<GoapWorldState>();

        _parentCharacter.MyEventHandler.OnNewEnemyTargetFound += OnImportantEvent;
        _parentCharacter.MyEventHandler.OnCurrentActionComplete += OnCurrentActionComplete;

        //update parent character for each action
        foreach(GoapAction action in _actions)
        {
            action.ParentCharacter = _parentCharacter;
        }

        BlackBoard.PatrolLoc = new Vector3(-15, 0, -15);
        BlackBoard.PatrolRange = new Vector3(20, 10, 20);
        BlackBoard.HasPatrolInfo = true;

        if(ControlType != AIControlType.Player)
        {
            _currentGoal = null;
            _currentAction = null;

            FindAndExecuteAction();
        }
    }
示例#6
0
 /// <summary>
 /// Saves the starting position value. Initializes the <see cref="AISensor"/> and registers the agent in <see cref="BehaviourTreeRuntimeData"/>
 /// </summary>
 private void Start()
 {
     startPosition = transform.position;
     sensor.Initialize(this, navAgent);
     BehaviourTreeRuntimeData.RegisterAgentContext(behaviourTreeType, aiContext);
 }