public static ObjectiveTrigger Create(Vector3 position, float radius) { GameObject go = new GameObject("ObjectiveTrigger"); go.transform.position = position; SphereCollider sc = go.AddComponent <SphereCollider>(); sc.radius = radius; sc.isTrigger = true; ObjectiveTrigger ot = go.AddComponent <ObjectiveTrigger>(); return(ot); }
public override void OnBegin() { this.Triggers = new ObjectiveTrigger[this.OrbitCollidersCount]; float orbitRadius = Mathf.Lerp(this.InnerBoundry, this.OuterBoundry, 0.5f); float triggerRadius = this.OuterBoundry - this.InnerBoundry; Vector3 OrbitCenter = Vector3.zero; Debug.Log("orbitRadius=" + orbitRadius + " triggerRadius=" + triggerRadius); for (int i = 0; i < this.OrbitCollidersCount; i++) { float radians = 2.0f * Mathf.PI * ((float)i / (float)this.OrbitCollidersCount); float x = orbitRadius * Mathf.Cos(radians); float z = orbitRadius * Mathf.Sin(radians); Debug.Log("i=" + i + " radians=" + radians + " x=" + x + " z=" + z + " (float)(i/this.OrbitCollidersCount)=" + ((float)i / (float)this.OrbitCollidersCount)); ObjectiveTrigger ot = ObjectiveTrigger.Create(OrbitCenter + new Vector3(x, 0.0f, z), triggerRadius); this.Triggers[i] = ot; } }
public override bool IsCompleted() { if ((this.Triggers == null) || (this.Triggers.Length == 0)) { return(false); } ObjectiveTrigger firstTrigger = this.Triggers[0]; for (int i = 0; i < firstTrigger.Triggered.Count; i++) { Orbiter ob = firstTrigger.Triggered[i]; for (int j = 0; j < this.Triggers.Length; j++) { if (!this.Triggers[j].HasTriggered(ob)) { return(false); } } } return(true); }