public override void reset() { distributed = false; startTime = 0; closest = null; sortedSupplies = null; }
public override bool checkProceduralPrecondition(GameObject agent) { if (supplies == null) { supplies = FindObjectsOfType(typeof(SupplyPileComponent)) as SupplyPileComponent[]; } if (randomSortedSupplies == null) { // use linq orderby new guid to generate random order randomSortedSupplies = from s in supplies orderby Guid.NewGuid() ascending select s; } if (closest == null) { foreach (SupplyPileComponent supply in randomSortedSupplies) { if (supply.numFirewood > 10 || supply.numFood > 10 || supply.numLogs > 10 || supply.numOre > 10 || supply.numRawFood > 10) { closest = supply; break; } } } if (closest != null) { target = closest.gameObject; } return(closest != null); }
public override bool checkProceduralPrecondition (GameObject agent) { // find the nearest supply pile that has spare ore SupplyPileComponent[] supplyPiles = (SupplyPileComponent[]) UnityEngine.GameObject.FindObjectsOfType ( typeof(SupplyPileComponent) ); SupplyPileComponent closest = null; float closestDist = 0; foreach (SupplyPileComponent supply in supplyPiles) { if (closest == null) { // first one, so choose it for now closest = supply; closestDist = (supply.gameObject.transform.position - agent.transform.position).magnitude; } else { // is this one closer than the last? float dist = (supply.gameObject.transform.position - agent.transform.position).magnitude; if (dist < closestDist) { // we found a closer one, use it closest = supply; closestDist = dist; } } } if (closest == null) return false; targetSupplyPile = closest; target = targetSupplyPile.gameObject; return closest != null; }
public override bool checkProceduralPrecondition(GameObject agent) { if (supplyPiles == null) { supplyPiles = FindObjectsOfType(typeof(SupplyPileComponent)) as SupplyPileComponent[]; } if (sortedSupplyPiles == null) { sortedSupplyPiles = supplyPiles.OrderBy(t => Vector3.Distance(transform.position, t.transform.position)); } if (closest == null) { foreach (SupplyPileComponent supply in sortedSupplyPiles) { if (supply.numFood >= noOfFood) { closest = supply; break; } } } if (closest != null) { target = closest.gameObject; } return(closest != null); }
public override void reset() { collected = false; startTime = 0; closest = null; randomSortedSupplies = null; }
protected override void Awake() { base.Awake(); AddPrecondition("hasOre", false); // don't get a ore if we already have one AddEffect("hasOre", true); // we now have a ore ActionName = General_Scripts.Enums.Actions.PickUpOre; _myTeamSupply = GameObject.Find("SupplyPile team A").GetComponent <SupplyPileComponent>(); }
protected override void Awake() { base.Awake(); AddPrecondition("hasNewTools", true); // can't drop off tools if we don't already have some AddEffect("hasNewTools", false); // we now have no tools AddEffect("collectTools", true); // we collected tools ActionName = General_Scripts.Enums.Actions.DropOffTools; _myTeamSupply = GameObject.Find("SupplyPile team A").GetComponent <SupplyPileComponent>(); }
/// <summary> /// Checks if there is a <see cref="SupplyPileComponent"/> close to the agent with at least 1 ore. /// </summary> /// <param name="agent"></param> /// <returns></returns> public override bool CheckProceduralPrecondition(GameObject agent) { if (_myTeamSupply.NumOre < 1) { return(false); } _targetSupplyPile = _myTeamSupply; Target = _myTeamSupply.gameObject; return(true); }
public override bool checkProceduralPrecondition(GameObject agent) { if (supplyPiles == null) { supplyPiles = FindObjectsOfType(typeof(SupplyPileComponent)) as SupplyPileComponent[]; } if (closest == null) { closest = supplyPiles.OrderBy(t => Vector3.Distance(transform.position, t.transform.position)).FirstOrDefault(); } if (closest != null) { target = closest.gameObject; } return(closest != null); }
/// <summary> /// 检查程序前提条件 /// </summary> /// <param name="agent"></param> /// <param name="bb"></param> /// <returns></returns> public override bool CheckProceduralPrecondition(GameObject agent, BlackBoard bb) { // find the nearest supply pile that has spare tools //找到最近的有备用工具的供应堆 SupplyPileComponent[] supplyPiles = (SupplyPileComponent[])bb.GetData("supplyPiles"); SupplyPileComponent closest = null; float closestDist = 0; foreach (SupplyPileComponent supply in supplyPiles) { if (closest == null) { // first one, so choose it for now //第一个,所以现在选择它 closest = supply; closestDist = (supply.gameObject.transform.position - agent.transform.position).magnitude; } else { // is this one closer than the last? //这个比最后一个更近吗? float dist = (supply.gameObject.transform.position - agent.transform.position).magnitude; if (dist < closestDist) { // we found a closer one, use it //我们找到了一个更近的,使用它 closest = supply; closestDist = dist; } } } if (closest == null) { return(false); } targetSupplyPile = closest; target = targetSupplyPile.gameObject; return(closest != null); }
public override bool CheckProceduralPrecondition(GameObject agent, BlackBoard bb) { // find the nearest supply pile that has spare ores SupplyPileComponent[] supplyPiles = (SupplyPileComponent[])bb.GetData("supplyPiles"); SupplyPileComponent closest = null; float closestDist = 0; foreach (SupplyPileComponent supply in supplyPiles) { if (supply.numOre >= 3) // we need to take 3 ore { if (closest == null) { // first one, so choose it for now closest = supply; closestDist = (supply.gameObject.transform.position - agent.transform.position).magnitude; } else { // is this one closer than the last? float dist = (supply.gameObject.transform.position - agent.transform.position).magnitude; if (dist < closestDist) { // we found a closer one, use it closest = supply; closestDist = dist; } } } } if (closest == null) { return(false); } targetSupplyPile = closest; target = targetSupplyPile.gameObject; return(closest != null); }
public override bool checkProceduralPrecondition(GameObject agent) { // find the nearest supply pile that has spare logs SupplyPileComponent[] supplyPiles = (SupplyPileComponent[])UnityEngine.GameObject.FindObjectsOfType(typeof(SupplyPileComponent)); SupplyPileComponent closest = null; float closestDist = 0; foreach (SupplyPileComponent supply in supplyPiles) { if (supply.numLogs > 0) { if (closest == null) { // first one, so choose it for now closest = supply; closestDist = (supply.gameObject.transform.position - agent.transform.position).magnitude; } else { // is this one closer than the last? float dist = (supply.gameObject.transform.position - agent.transform.position).magnitude; if (dist < closestDist) { // we found a closer one, use it closest = supply; closestDist = dist; } } } } if (closest == null) { return(false); } targetSupplyPile = closest; target = targetSupplyPile.gameObject; return(closest != null); }
public override bool checkProceduralPrecondition(GameObject agent) { // find furthest supply pile if (supplies == null) { supplies = FindObjectsOfType(typeof(SupplyPileComponent)) as SupplyPileComponent[]; } if (sortedSupplies == null) { sortedSupplies = supplies.OrderByDescending(t => Vector3.Distance(transform.position, t.transform.position)); } if (closest == null) { foreach (SupplyPileComponent supply in sortedSupplies) { if (supply.numFirewood < 10 || supply.numFood < 10 || supply.numLogs < 10 || supply.numOre < 10 || supply.numRawFood < 10) { closest = supply; break; } } } if (closest != null) { target = closest.gameObject; } return(closest != null); }
public override void Reset() { droppedOffOre = false; targetSupplyPile = null; }
public override void reset() { droppedOffFirewood = false; targetSupplyPile = null; }
public override void VarReset() { droppedOffLogs = false; targetSupplyPile = null; }
/// <summary> /// Resets the action to its default values, so it can be used again. /// </summary> public override void Reset() { _droppedOffTools = false; _targetSupplyPile = null; StartTime = 0; }
public override void Reset() { hasOre = false; targetSupplyPile = null; }
public override void reset () { hasOre = false; targetSupplyPile = null; }
public override void reset() { hasTool = false; closest = null; }
public override void reset() { hasFirewood = false; targetSupplyPile = null; }
public override void reset() { hasLogs = false; closest = null; }
public override void reset() { droppedOffTools = false; targetSupplyPile = null; }
public override void Reset() { _hasLogs = false; _targetSupplyPile = null; }
/// <summary> /// Resets the action to its default values, so it can be used again. /// </summary> public override void Reset() { StartTime = 0; _hasTool = false; _targetSupplyPile = null; }
public override void reset() { hasLogs = false; targetSupplyPile = null; }
public override void Reset() { _droppedOffLogs = false; _targetSupplyPile = null; }
public override void reset() { hasFood = false; closest = null; }
public override void reset() { droppedOffTools = false; closest = null; }
public override void reset () { droppedOffOre = false; targetSupplyPile = null; }
public override void VarReset() { hasTool = false; targetSupplyPile = null; }
public override void reset() { finishEat = false; targetSupplyPile = null; }
/// <summary> /// Resets the action to its default values, so it can be used again. /// </summary> public override void Reset() { _hasOre = false; _targetSupplyPile = null; StartTime = 0; }