public override void OnPickup() { PlayerData.instance.AddModule(Prefab); Qvent qvent = new Qvent(QventType.REMOVED_FROM_GAME_WORLD, typeof(FloatingItem), this); foreach (QventHandler l in Listeners) { l.HandleQvent(qvent); } Destroy(gameObject); }
public void HandleQvent(Qvent q) { switch (q.QventType) { case QventType.DESTROYED: if (q.PayloadType.IsAssignableFrom(typeof(Ship))) { Observers.Remove(((Ship)q.Payload).gameObject); } break; } }
public virtual void Repair(float time) { int repamt = Mathf.Max((int)((time / RepairTime) * maxhp), 1); DoHeal(repamt); Qvent q = new Qvent(QventType.HEALED); foreach (QventHandler handy in Listeners) { handy.HandleQvent(q); } }
} // switches to the idle subroutine public void HandleQvent(Qvent qvent) { // Gonna need some complex event handling logic... if (Triggers.ContainsKey(qvent.QventType)) { if (ActiveProcess) { ActiveProcess.OnInterrupt(); } StellarSubroutine result = Triggers [qvent.QventType]; Triggers [qvent.QventType].HandleQvent(qvent); } }
public void OnPortDisconnected(Module mod) { moduleConnectHelper(mod, false); moduleEnableHelper(mod, false, mod.portType == Port.PortType.MAIN); Qvent q = new Qvent(QventType.STRUCTURE_CHANGED); foreach (QventHandler handy in Listeners) { handy.HandleQvent(q); } mod.UnregisterListener(this); }
public override void OnPickup() { PlayerData.instance.AddScrap(ScrapValue); Qvent qvent = new Qvent(QventType.REMOVED_FROM_GAME_WORLD, typeof(FloatingItem), this); foreach (QventHandler l in Listeners) { l.HandleQvent(qvent); } WidgetManager.instance.CreateFloatingNumber(Color.gray, Color.clear, 1, 0.2f, ScrapValue.ToString()).transform.position = transform.position; Destroy(gameObject); }
public void HandleQvent(Qvent e) { Debug.Log("QVENT RECVD: " + e.QventType.ToString()); if (triggers.ContainsKey(e.QventType)) { Debug.Log("FOUND QVENT"); foreach (Decision dec in triggers[e.QventType]) { if (dec.EventRun(Time.fixedDeltaTime, e.PayloadType, e.Payload) == NodeStatus.RUNNING) { runningDecisions.Add(dec); } } } // @TODO: Think about how you can combine EventRun into Process }
public void HandleQvent(Qvent myQvent) { switch (myQvent.QventType) { case QventType.DAMAGED: Refresh(); break; case QventType.STRUCTURE_CHANGED: Refresh(); break; case QventType.HEALED: Refresh(); break; } }
public virtual void HandleQvent(Qvent qvent) { switch (qvent.QventType) { case QventType.DAMAGED: SetState(ShipState.COMBAT); CombatCooldownTimer = SpaceGameGlobal.COMBAT_COOLDOWN; break; case QventType.DESTROYED: if (qvent.PayloadType.IsAssignableFrom(typeof(Ship))) { Listeners.Remove((Ship)qvent.Payload); } break; } }
public override void HandleQvent(Qvent e) { Debug.Log("RECIEVED EVENT IN XOR GROUP"); if (e.QventType == QventType.DECISION_EVENT) { List <object> list = (List <object>)e.Payload; Decision decision = (Decision)list [0]; NodeStatus status = (NodeStatus)list [1]; foreach (Decision member in GroupMembers) { if (decision != member) { source.QueueRemove(member); } } } }
public virtual void DoDamage(int amt) { if (invincible || amt < 0) { return; } curhp = (curhp - amt <= 0)? 0 : curhp - amt; Qvent q = new Qvent(QventType.DAMAGED); foreach (QventHandler handy in Listeners) { handy.HandleQvent(q); } if (curhp <= 0) { Die(); } }
// QventHandler Interface Declaration public void HandleQvent(Qvent qvent) { switch (qvent.QventType) { case QventType.DESTROYED: // remove destroyed ship from tracking if (qvent.PayloadType == typeof(Ship)) { RemoveFromSector(((Ship)qvent.Payload).gameObject); } break; case QventType.REMOVED_FROM_GAME_WORLD: // remove destroyed object from tracking if (qvent.PayloadType == typeof(FloatingItem)) { RemoveFromSector(((FloatingItem)qvent.Payload).gameObject); } break; } }
public void Update() { Vector2 dir = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position; if (dir.magnitude <= range) { if (InRange) { return; } else { InRange = true; Qvent q = new Qvent(QventType); DispatchEvent(q); } } else { InRange = false; } }
public override void Die() { this.enabled = false; foreach (Port p in ports) { p.Eject(); } foreach (Port p in mainPorts) { p.Eject(); } int num = UnityEngine.Random.Range(1, 11); for (int i = 0; i < num; i++) { GameObject debris = WidgetManager.instance.CreateFloatingScrap(ScrapCost / 100, transform.position); Rigidbody2D rb = debris.GetComponent <Rigidbody2D> (); Vector2 away = UnityEngine.Random.insideUnitCircle; rb.velocity = away.normalized * UnityEngine.Random.value; gameObject.layer = LayerMask.NameToLayer("PlayerOnly"); rb.gravityScale = 0; } Qvent qvent = new Qvent(QventType.DESTROYED, typeof(Ship), this); foreach (QventHandler listeners in Listeners) { Debug.Log("Listener Found"); listeners.HandleQvent(qvent); } if (IsPlayer) { SpaceGameManager.instance.PlayerDied(); } GameObject.Destroy(this.gameObject); }
public virtual void HandleQvent(Qvent Qvent) { Debug.LogWarning("Unimplemented HandleQvent called in Group<NEW_AIBase>"); }