public override List <IStateful> GetAllTargets(GoapAgent agent) { if (!agentPositions.ContainsKey(agent)) { agentPositions[agent] = wanderPool.Borrow <WanderPosition>(); } WanderPosition wanderPos = agentPositions[agent]; DangerSensor dangerSensor = agent.GetComponent <DangerSensor>(); SightSensor sightSensor = agent.GetComponent <SightSensor>(); List <IStateful> threats = dangerSensor.GetThreats(); //Vector3 targetPosition = Vector3.zero; //foreach (IStateful threat in threats) { // Component threatComp = threat as Component; // targetPosition = targetPosition + (agent.transform.position - threatComp.transform.position); //} //targetPosition = (agent.transform.position + targetPosition) * runAwayDistance; //wanderPos.transform.position = sightSensor.GetRandomPosition(runAwayDistance, targetPosition); wanderPos.transform.position = sightSensor.GetRandomPosition(runAwayDistance, agent.transform.position); return(new List <IStateful> { wanderPos }); }
private void ContinueAction(GoapAgent agent) { if (monsterAnimationController == null) { monsterAnimationController = agent.GetComponent <MonsterAnimationController>(); } if (monsterBaseAbilities == null) { monsterBaseAbilities = agent.GetComponent <MonsterBaseAbilities>(); } if (abilityUser == null) { abilityUser = agent.GetComponent <AbilityUser>(); } if (!ActionPossible(agent)) { monsterAnimationController.attacking = false; } else { monsterAnimationController.attacking = true; HitPlayer(agent); } timer += Time.deltaTime; agent.transform.rotation = Quaternion.Slerp(originalRotation, targetLookRotation, timer / turnTime); if (timer >= turnTime) { timer = 0f; started = false; ApplyEffects(agent); } }
protected override bool OnDone(GoapAgent agent, WithContext context) { base.OnDone(agent, context); Container agentContainer = agent.GetComponent <Container>(); Axe axe = agentContainer.GetItem() as Axe; // Should probably error check this Component target = context.target as Component; Door targetDoor = target.GetComponent <Door>(); bool broke = targetDoor.Break(axe.Hit()); failMsg = "Didn't Break!"; if (!axe.gameObject.activeSelf) { // The axe broke so we'll drop it agentContainer.DropItem(); failMsg = "Axe Broke!"; } if (broke) { // Add the new room to memory Memory memory = agent.GetComponent <Memory>(); if (memory != null) { memory.AddLocationToMemory(targetDoor.leadsToRoom); } } return(broke); }
public override void Execute(GoapAgent agent) { if (monsterAnimationController == null) { monsterAnimationController = agent.GetComponent <MonsterAnimationController>(); } if (monsterBaseAbilities == null) { monsterBaseAbilities = agent.GetComponent <MonsterBaseAbilities>(); } if (abilityUser == null) { abilityUser = agent.GetComponent <AbilityUser>(); } if (!ActionPossible(agent)) { monsterAnimationController.attacking = false; Fail(agent); } else { monsterAnimationController.attacking = true; HitPlayer(agent); } }
protected override bool Enter(GoapAgent agent) { _time = 0; Target = agent.SearchActionData("targetHerb") as GameObject; _bar = agent.GetComponent <ProgressBar>(); _farmer = agent.GetComponent <Farmer>(); //Debug.Log("pick up enter"); return(true); }
protected override bool OnDone(GoapAgent agent, WithContext context) { base.OnDone(agent, context); Container container = agent.GetComponent <Container>(); Memory locationMemory = agent.GetComponent <Memory>(); container.DropItem(locationMemory.GetCurrentLocation().transform); return(true); }
protected override IEnumerator <SimpleActionExecutionControlElements> Execute(PrototypeActionSettings settings, Action fail) { Debug.Log("picking item"); //settings. GoapAgent agent = settings.agent as GoapAgent; Debug.Log(settings.effects.Get(WorldStates.STATE_HAND_RIGHT_ITEM)); Debug.Log(agent.GetComponent <RPGHands>()); agent.GetComponent <RPGHands>().PickItemRight(settings.effects.Get(WorldStates.STATE_HAND_RIGHT_ITEM)); yield break; }
public override void Run(GoapAgent agent) { if (abilityUser == null) { abilityUser = agent.GetComponent <AbilityUser>(); } if (monsterBaseAbilities == null) { monsterBaseAbilities = agent.GetComponent <MonsterBaseAbilities>(); } agent.state["meleeAttackAvailable"] = IsMeleeAttackAvailable(); agent.state["rangedAttackAvailable"] = IsRangedAttackAvailable(); }
public void Init(GoapAgent agent) { Debug.Log("Waiting For Path"); navMeshAgent = agent.GetComponent <NavMeshAgent>(); path = new NavMeshPath(); navMeshAgent.CalculatePath(goal, path); }
protected override bool OnDone(GoapAgent agent, WithContext context) { //destroy plant if finished Weed weed = context.target as Weed; var backpack = agent.GetComponent <Container>(); backpack.items[resource] += amountToHarvest; if (fromBros) { var bro = context.target as BroForReal; Container broBag = bro.GetComponent <Container>(); broBag.items[resource] -= amountToHarvest; } else if (weed != null && weed.ToString() != "Null" && weed.ToString() != "null") { weed.amount -= amountToHarvest; if (weed.amount <= 0) { GameObject weedObj = weed.gameObject; Destroy(weedObj); } } // Refresh list RefreshTargets(); return(base.OnDone(agent, context)); }
protected override bool OnDone(GoapAgent agent, WithContext context) { Container c = agent.GetComponent <Container>(); c.items[item] -= amountToUse; return(base.OnDone(agent, context)); }
private bool GetGcdState(GoapAgent agent) { if (agent.GetComponent <AbilityUser>().GCDTime > 0) { return(false); } return(true); }
protected override bool OnDone(GoapAgent agent, WithContext context) { // Done harvesting. var inventory = agent.GetComponent <Container>(); inventory.items[Item.Part2] += 1; return(base.OnDone(agent, context)); }
public override void Run(GoapAgent agent) { if (statusEffectHost == null) { statusEffectHost = agent.GetComponent <StatusEffectHost>(); } agent.state["paralyzed"] = IsParalyzed(); }
protected override bool OnDone(GoapAgent agent, WithContext context) { // Done harvesting. var backpack = agent.GetComponent <Container>(); backpack.items[resource] += amountToHarvest; return(base.OnDone(agent, context)); }
protected override bool OnDone(GoapAgent agent, WithContext context) { // Done harvesting. var inventory = agent.GetComponent <Container> (); inventory.items [resource] += amountToCollect; return(base.OnDone(agent, context)); }
protected override IEnumerator <SimpleActionExecutionControlElements> Execute(PrototypeActionSettings settings, Action fail) { Debug.Log("picking item"); //settings. GoapAgent agent = settings.agent as GoapAgent; agent.GetComponent <RPGHands>().DropItemRight(); yield break; }
public CombatGoal(GoapAgent agent) : base(agent) { GoalName = "Combat Goal"; RequiredWorldState.Add(new GoapState("Player Detected", true)); RequiredWorldState.Add(new GoapState("Shoot At Player", true)); myAI = agent.GetComponent <GoapAI>(); }
public override void Run(GoapAgent agent) { if (boss == null) { boss = agent.GetComponent <Boss>(); } agent.state["bossMeleeAttackAvailable"] = IsMeleeAttackAvailable(); agent.state["bossRangedAttackAvailable"] = IsRangedAttackAvailable(); agent.state["bossUtilityAbilityAvailable"] = IsUtilityAbilityAvailable(); }
public override List <IStateful> GetAllTargets(GoapAgent agent) { ZombieTargetSensor targetSensor = agent.GetComponent <ZombieTargetSensor>(); if (targetSensor != null) { return(targetSensor.FindTargets()); } return(GetTargets <EscapeDude>()); }
public override void Execute(GoapAgent agent) { if (monsterAnimationController == null) { monsterAnimationController = agent.GetComponent <MonsterAnimationController>(); } if (boss == null) { boss = agent.GetComponent <Boss>(); } if (!ActionPossible(agent)) { Fail(agent); } else { UseAbility(agent); } }
protected override bool OnDone(GoapAgent agent, WithContext context) { var backpack = agent.GetComponent <Container>(); var target = context.target as HarvestPoint; ++target.GetComponent <Container>().items[itemToDrop]; --backpack.items[itemToDrop]; return(base.OnDone(agent, context)); }
public static List <IStateful> GetTargetsFromMemory <T>(GoapAgent agent) where T : Component, IStateful { Memory memory = agent.GetComponent <Memory>(); if (memory == null) { return(GetTargets <T>()); } return(memory.GetTargets <T>()); }
protected override bool OnDone(GoapAgent agent, WithContext context) { base.OnDone(agent, context); targetPositions[agent].ReturnSelf(); SightSensor sight = agent.GetComponent <SightSensor>(); if (sight != null) { sight.LookAround(); } return(true); }
protected override bool OnDone(GoapAgent agent, WithContext context) { var backpack = agent.GetComponent <Container>(); var tool = backpack.tool.GetComponent <ToolComponent>(); tool.Use(toolDamage); if (tool.IsDestroyed) { Destroy(backpack.tool); backpack.tool = null; } return(base.OnDone(agent, context)); }
/// <summary> /// Implementation of <see cref="IAction"/> interface. Calls the Plan method of the <see cref="GoapPlanner"/>. /// </summary> public void Execute() { _agent.GetComponent <Rigidbody>().velocity = Vector3.zero; _agent.GetComponent <Rigidbody>().angularVelocity = Vector3.zero; // get the world state and the goal we want to plan for var worldState = _dataProvider.GetWorldState(); var goal = _dataProvider.CreateGoalState(); // Plan var plan = _planner.Plan(_agent.gameObject, _agent.GetAvailableActions(), worldState, goal); if (plan != null)// we have a plan, hooray! { _agent.SetCurrentActions(plan); _dataProvider.PlanFound(goal, plan); } else// ugh, we couldn't get a plan { _dataProvider.PlanFailed(goal); } }
protected override bool OnDone(GoapAgent agent, WithContext context) { var inventory = agent.GetComponent <Container>(); var tool = inventory.tool.GetComponent <ToolComponent>(); tool.use(toolDamage); if (tool.destroyed()) { Destroy(inventory.tool); inventory.tool = null; } return(base.OnDone(agent, context)); }
protected override bool Run(GoapAgent agent) { var target = agent.SearchActionData("targetHerb") as GameObject; if (target == null) { Debug.Log("farmer: target disappear while picking"); return(false); } _time += Time.deltaTime; agent.GetComponent <ProgressBar>().SetRate(_time / Duration); if (_time > Duration) { agent.GetComponent <ProgressBar>().SetValue(0); agent.GetComponent <Farmer>().ToolCount--; agent.GetComponent <Farmer>().HerbCount++; Destroy(target); ActionOver(); } return(true); }
private void UseRangedAbility(GoapAgent agent) { if (monsterBaseAbilities == null || abilityUser == null) { return; } foreach (var ability in monsterBaseAbilities.baseAbilities) { if (IsRangedAbility(ability) && ability.currentCooldown == 0) { agent.GetComponent <AbilityUser>().UseAbility(ability); return; } } foreach (var ability in abilityUser.soulGemActives) { if (IsRangedAbility(ability) && ability.currentCooldown == 0) { agent.GetComponent <AbilityUser>().UseAbility(ability); return; } } }
protected override bool Run(GoapAgent agent) { if (Target == null) { Debug.Log("farmer: target disappear while walking"); return(false); } if (agent.GetComponent <Farmer>().MoveTo(Target.transform.position, MoveSpeed)) { ActionOver(); } return(true); }