public override void Init(AIMemory aiMemory, BaseAIRoutine aiRoutine) { this.aiMemory = aiMemory ?? new AIMemory(); this.aiRoutine = aiRoutine ?? new SimpleAIRoutine(); this.lastTick = DateTime.Now; this.guideCommandByVobInst = new Dictionary <VobInst, GuideCommandInfo>(); }
public override void Execute(AIMemory memory, AIBrainSenses senses, StateStatus stateStatus) { base.Result = base.Inverted; IAIAttack iAIAttack = base.Owner as IAIAttack; if (iAIAttack == null) { return; } BaseEntity bestTarget = iAIAttack.GetBestTarget(); if (base.Inverted) { if (bestTarget == null && base.ShouldSetOutputEntityMemory) { memory.Entity.Remove(base.OutputEntityMemorySlot); } base.Result = bestTarget == null; } else { if (bestTarget != null && base.ShouldSetOutputEntityMemory) { memory.Entity.Set(bestTarget, base.OutputEntityMemorySlot); } base.Result = bestTarget != null; } }
public AIBrain( List <AISensor> _sensors, List <AISystem> _systems, List <AIAction> _actions, List <AIGoal> _goals, List <State> _states, List <AIStateSystem> _allStateSystems, AIBrainProps _brainProps, Transform _transform, AIMemory _memory, ref GlobalEvents.OnDeadHandler _onDead ) { allSensors = _sensors; allSystems = _systems; allActions = _actions; AllGoals = _goals; allStates = _states; allStateSystems = _allStateSystems; brain = _brainProps; Memory = _memory; Transform = _transform; Animator = _transform.GetComponent <Animator>(); Agent = _transform.GetComponent <NavMeshAgent>(); onDead = _onDead; _onDead += OnDead; pollingSensors = allSensors.OfType <AISensorPolling>().ToList(); }
public TransitionClaculator(AIMemory aiMem, IJumpRequest aiLocalSolver) { this.aiMem = aiMem; this.aiLocalSolver = aiLocalSolver; leftToRight = TransitionType.NONE; rightToLeft = TransitionType.NONE; InitialisePatterns(); }
void Start() { aiMem = new AIMemory(WindowX, WindowY, transform.position, new EnvironmentAnalyser(), this, 3.1f); Camera.main.GetComponent <DebugGraph>().AiMapGraph = aiMem; aiMem.UpdateMemory(transform.position); lastWinX = WindowX; lastWinY = WindowY; }
private void OnMessageReceived(object sender, InformationEventArgs eArgs) { AIMemory memSender = (AIMemory)sender; foreach (var message in eArgs.Messages) { message.DispatchTo(messageHandlers, memSender); } }
protected void DynamicDispatch(IHandlerP handler, MessageType mS, AIMemory memSender) { IMessageHandler <MessageType> matchingHandler = handler as IMessageHandler <MessageType>; if (matchingHandler != null) { matchingHandler.ProcessMessage(mS, memSender); } }
public void DispatchTo(IHandlerP handler, AIMemory memSender) { MessageType messageAsType = this as MessageType; if (messageAsType != null) { DynamicDispatch(handler, messageAsType, memSender); } }
public void ProcessMessage(AIMessageSuspicionLost message, AIMemory memSender) { var susps = memory.Items.OfType <InformationSuspicion>().Where(x => x.BaseTransform != null && x.BaseTransform == message.lostTarget).ToList().OrderByDescending(x => x.UpdateTime).ToList(); if (susps.Count > 0) { memory.BroadcastToListeners(new AIMessageSuspicionPosition(message.lostTarget, susps[0].lastKnownPosition.Value, susps[0].UpdateTime)); } }
public override void Execute(AIMemory memory, AIBrainSenses senses, StateStatus stateStatus) { BaseEntity baseEntity = memory.Entity.Get(base.InputEntityMemorySlot); base.Result = false; if (!(baseEntity == null)) { bool flag = Vector3Ex.Distance2D(base.Owner.transform.position, baseEntity.transform.position) <= Range; base.Result = (base.Inverted ? (!flag) : flag); } }
public void ProcessMessage(AIMessageTargetDead message, AIMemory memSender) { var memInfo = memory.GetSuspicionWithBaseTransform <InformationAlive>(message.deadTarget); var relatedInfos = memory.Items.OfType <InformationSuspicion>().Where(x => x != memInfo).ToList(); memory.Remove(relatedInfos); if (memInfo != null) { memInfo.IsDead = true; } }
public override void Execute(AIMemory memory, AIBrainSenses senses, StateStatus stateStatus) { base.Result = false; BaseEntity baseEntity = memory.Entity.Get(base.InputEntityMemorySlot); if (!(baseEntity == null) && base.Owner is IAIAttack) { bool flag = senses.Memory.IsLOS(baseEntity); base.Result = (base.Inverted ? (!flag) : flag); } }
public override void Execute(AIMemory memory, AIBrainSenses senses, StateStatus stateStatus) { base.Result = base.Inverted; if (base.Inverted) { base.Result = senses.TimeInAgressiveState < Value; } else { base.Result = senses.TimeInAgressiveState >= Value; } }
public void ProcessMessage(AIMessageSuspicionPosition message, AIMemory memSender) { var susps = memory.Items.OfType <InformationSuspicion>().Where(x => x.BaseTransform != null && x.BaseTransform == message.FoundTransform).ToList(); foreach (var susp in susps) { if (message.FoundTime > susp.UpdateTime) { susp.Update(message.FoundPos, susp.lastKnownPosition.Confidence); } } }
public override void Execute(AIMemory memory, AIBrainSenses senses, StateStatus stateStatus) { base.Result = base.Inverted; IAIAttack iAIAttack = base.Owner as IAIAttack; if (iAIAttack != null) { BaseEntity baseEntity = memory.Entity.Get(base.InputEntityMemorySlot); iAIAttack.AttackTick(deltaTime, baseEntity, senses.Memory.IsLOS(baseEntity)); base.Result = !base.Inverted; } }
public override void Execute(AIMemory memory, AIBrainSenses senses, StateStatus stateStatus) { base.Result = base.Inverted; bool flag = Random.Range(0f, 1f) <= Chance; if (base.Inverted) { base.Result = !flag; } else { base.Result = flag; } }
public override void Execute(AIMemory memory, AIBrainSenses senses, StateStatus stateStatus) { base.Result = base.Inverted; combatEntity = memory.Entity.Get(base.InputEntityMemorySlot) as BaseCombatEntity; float num = lastExecuteTime; lastExecuteTime = Time.time; if (!(combatEntity == null) && combatEntity.lastAttackedTime >= num && !(combatEntity.lastAttacker == null) && !(combatEntity.lastAttacker == combatEntity)) { if (base.ShouldSetOutputEntityMemory) { memory.Entity.Set(combatEntity.lastAttacker, base.OutputEntityMemorySlot); } base.Result = !base.Inverted; } }
// Use this for initialization void Start() { SetPlayer2StartPosition(); x = player2.transform.position.x - 0.1f; y = 2f; projectile = Instantiate(projectilePrefab); projectile.gameObject.SetActive(false); compAttack = player2.GetComponent <CalculationPlayerAttack>(); compAttack.TakeTurn(projectile); compAttack.AnimalPosition = new Vector3(x, y, 0); compAttack.CreateCow(); compAttack.CanShoot = true; memory = new AIMemory(); Time.timeScale = 100f; }
public void SetupAI(AISettings settings) { aiEnabled = false; this.maxLP = settings.MaxLP; this.minimumDistance = settings.MinDistance; GetComponent <AIWeaponController>().accuracy = settings.Accuracy; GetComponent <AIWeaponController>().cooldown = settings.CoolDown; GetComponent <AIWeaponController>().maxExtraCooldown = settings.MaxExtraCooldown; GetComponent <AIWeaponController>().shootDistance = settings.ShootDistance; GetComponent <AIWeaponController>().Setup(); if (target == null) { GameObject go = GameObject.FindGameObjectWithTag(enemyTag); if (go != null) { target = go.transform; } } lp = maxLP; this.transform.position = new Vector3(RoundedMath.Mult(Mathf.RoundToInt(this.transform.position.x / boxFactor), boxFactor), this.transform.position.y); aiMovement = GetComponent <AIMovement>(); aiWeaponController = GetComponent <AIWeaponController>(); ea = new EnvironmentAnalyser(); aiMemory = new AIMemory(windowSizeX, windowSizeY, this.transform.position, ea, this, boxFactor); generalSolver = new GeneralSolver(aiMemory); aiMemory.MaxAreaWidth = settings.MaxAreaWidth; aiToTarget = new AIGetToTargetActions(aiMemory, generalSolver, aiMovement, this.transform, target, this, minimumDistance, this); aiWeaponActions = new AIWeaponActions(aiWeaponController); projectileDetector = new ProjectileDetector(this.transform, 10, projectileLayer); aiBehaviorTree = new AIBehaviorTree(aiToTarget, aiWeaponActions, this, projectileDetector); if (aiType == AIType.AGGRESSIVE) { aiBehaviorTree.CreateAndStartAggrassiveAI(); } if (aiType == AIType.DEFENSIVE) { aiBehaviorTree.CreateAndStartDefensiveAI(); } aiEnabled = true; }
public override void Execute(AIMemory memory, AIBrainSenses senses, StateStatus stateStatus) { base.Result = base.Inverted; combatEntity = memory.Entity.Get(base.InputEntityMemorySlot) as BaseCombatEntity; if (!(combatEntity == null)) { bool flag = combatEntity.healthFraction < HealthFraction; if (base.Inverted) { base.Result = !flag; } else { base.Result = flag; } } }
public override void Execute(AIMemory memory, AIBrainSenses senses, StateStatus stateStatus) { base.Result = base.Inverted; IAIAttack iAIAttack = base.Owner as IAIAttack; if (iAIAttack != null) { bool flag = iAIAttack.GetAmmoFraction() < Value; if (base.Inverted) { base.Result = !flag; } else { base.Result = flag; } } }
public void ProcessMessage(AIMessageSuspicionFound message, AIMemory memSender) { var memInfo = memory.GetSuspicionWithBaseTransform <InformationAlive>(message.Info.BaseTransform); if (memInfo != null) { if (memInfo.UpdateTime < message.Info.UpdateTime) { memInfo.Update(message.Info.lastKnownPosition.Value, memInfo.lastKnownPosition.Confidence); } } else { var n = new InformationSuspicion(message.Info); //n.SuspicionFirm = 1; //n.IsSure = true; memory.Add(n); } }
public override void Execute(AIMemory memory, AIBrainSenses senses, StateStatus stateStatus) { IAIHungerAbove iAIHungerAbove = base.Owner as IAIHungerAbove; if (iAIHungerAbove == null) { base.Result = false; return; } bool flag = iAIHungerAbove.IsHungerAbove(Value); if (base.Inverted) { base.Result = !flag; } else { base.Result = flag; } }
public override void Execute(AIMemory memory, AIBrainSenses senses, StateStatus stateStatus) { IAIMounted iAIMounted = memory.Entity.Get(base.InputEntityMemorySlot) as IAIMounted; base.Result = false; if (iAIMounted != null) { if (base.Inverted && !iAIMounted.IsMounted()) { base.Result = true; } if (!base.Inverted && iAIMounted.IsMounted()) { base.Result = true; } if (base.Result && base.ShouldSetOutputEntityMemory) { memory.Entity.Set(memory.Entity.Get(base.InputEntityMemorySlot), base.OutputEntityMemorySlot); } } }
public AIGetToTargetActions(AIMemory aiMemory, GeneralSolver generalSolver, AIMovement aiMovement, Transform aiTransform, Transform target, ITargetAroundRequest targetAroundCheck, float minDist, AIController aiController) { this.aiMemory = aiMemory; this.generalSolver = generalSolver; this.aiMovement = aiMovement; this.aiTransform = aiTransform; targetTransform = target; this.targetAroundCheck = targetAroundCheck; this.aiController = aiController; minimumDistance = minDist; minDistTmp = minDist; path = new LinkedList <AStarNode>(); if (graphDebug) { if (Camera.main.GetComponent <DebugGraph>() != null) { Camera.main.GetComponent <DebugGraph>().AiMapGraph = aiMemory; debugCam = Camera.main; } } }
private void Awake() { memory = new AIMemory(); memory.LoadMemoryFromFile("emr"); }
private void Start() { memory = GetComponent <AIMemory>(); }
public virtual void Execute(AIMemory memory, AIBrainSenses senses, StateStatus stateStatus) { }
public AIMessageHandlerShooter(AIMemory _aiMemory) { memory = _aiMemory; }
abstract public void Init(AIMemory aiMemory, BaseAIRoutine aiRoutine);