void UpdateParams() { ITraitData agent = traitComponent.GetTraitData <Agent>(); agent.SetValue("Health", health.health); agent.SetValue("Ammo", ammo.ammo); agent.SetValue("Navigating", botUtility.IsNavigating()); }
void UpdateParams() { ITraitData collectible = traitComponent.GetTraitData <Collectible>(); if (ammoBox != null) { collectible.SetValue("Active", ammoBox.IsActive); } else if (healthBox != null) { collectible.SetValue("Active", healthBox.IsActive); } }
public void DrawGizmos(GameObject gameObject, ITraitData traitData, bool isSelected) { Gizmos.color = isSelected ? Color.white : Color.grey; Gizmos.DrawWireSphere(gameObject.transform.position + Vector3.up * 0.15f, 0.2f); Gizmos.color = isSelected ? Color.green : Color.green.Opacity(0.5f); DrawLink(gameObject, traitData, Waypoint.FieldUp); Gizmos.color = isSelected ? Color.red : Color.red.Opacity(0.5f); DrawLink(gameObject, traitData, Waypoint.FieldRight); Gizmos.color = isSelected ? Color.blue : Color.blue.Opacity(0.5f); DrawLink(gameObject, traitData, Waypoint.FieldDown, 0.2f); Gizmos.color = isSelected ? Color.yellow : Color.yellow.Opacity(0.5f); DrawLink(gameObject, traitData, Waypoint.FieldLeft, 0.2f); }
void Start() { botUtility = GetComponent <BotUtility>(); health = botUtility.GetComponent <PlayerHealth>(); ammo = botUtility.GetComponent <PlayerAmmo>(); traitComponent = GetComponent <TraitComponent>(); int uniqueId = (TryGetComponent <AIPlannerTarget>(out var target) ? target.UniqueId : -1); ITraitData agent = traitComponent.GetTraitData <Agent>(); agent.SetValue("UniqueId", uniqueId); UpdateParams(); }
public void DrawGizmos(GameObject gameObject, ITraitData traitData, bool isSelected) { Gizmos.color = isSelected ? Color.white : Color.grey; Gizmos.DrawWireSphere(gameObject.transform.position + Vector3.up * 0.15f, 0.2f); var waypoint = gameObject.GetComponent<Waypoint>(); if (waypoint == null) return; Gizmos.color = isSelected ? Color.green : Opacity(Color.green, 0.5f); DrawLink(gameObject, waypoint.Up); Gizmos.color = isSelected ? Color.red : Opacity( Color.red,0.5f); DrawLink(gameObject, waypoint.Right); Gizmos.color = isSelected ? Color.blue : Opacity(Color.blue, 0.5f); DrawLink(gameObject, waypoint.Down, 0.2f); Gizmos.color = isSelected ? Color.yellow : Opacity(Color.yellow, 0.5f); DrawLink(gameObject, waypoint.Left, 0.2f); }
public IEnumerator Seek(GameObject treasure, GameObject copGO, GameObject robberGO) { Debug.Log("Approach"); agent.SetDestination(treasure.transform.position); while ((Vector3.Distance(treasure.transform.position, transform.position) > 2f) && (Vector3.Distance(treasure.transform.position, copGO.transform.position) >= 10f)) { yield return(null); } if (Vector3.Distance(treasure.transform.position, copGO.transform.position) < 10f) { // Go to Wander: cop.farAway TraitComponent tc = copGO.GetComponent <TraitComponent>(); ITraitData tdt = tc.GetTraitData <Cop>(); tdt.SetValue("farAway", false); } else { // Go to Steal: robber.ready2steal TraitComponent tc = robberGO.GetComponent <TraitComponent>(); Debug.Log(tc.name); ITraitData tdt = tc.GetTraitData <Robber>(); tdt.SetValue("ready2steal", true); Debug.Log(tdt.GetValue("ready2steal")); } }