static void DrawLink(GameObject gameObject, ITraitData traitData, string field, float offset = 0.1f) { var linkObject = traitData.GetValue(field); if (linkObject != null) { var obj = GameObject.FindObjectsOfType <TraitComponent>(); foreach (var traitComponent in obj) { if (traitComponent.Name.Equals(linkObject)) { var offsetVector = Vector3.up * offset; var startPos = gameObject.transform.position + offsetVector; var endPos = traitComponent.gameObject.transform.position + offsetVector; Gizmos.DrawLine(startPos, endPos); var direction = endPos - startPos; Vector3 right = Quaternion.LookRotation(direction) * Quaternion.Euler(0, 180 + 20.0f, 0) * new Vector3(0, 0, 1); Vector3 left = Quaternion.LookRotation(direction) * Quaternion.Euler(0, 180 - 20.0f, 0) * new Vector3(0, 0, 1); Gizmos.DrawRay(startPos + direction, right * 0.25f); Gizmos.DrawRay(startPos + direction, left * 0.25f); } } } }
public void DrawGizmos(GameObject gameObject, ITraitData traitData, bool isSelected) { var type = (ActivationType)(long)traitData.GetValue(ActivationSwitch.FieldType); Gizmos.color = (type == ActivationType.Blue) ? Color.cyan : Color.magenta; Gizmos.DrawWireCube(gameObject.transform.position, UnityEngine.Vector3.one); }
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")); } }