public void Consume(EntityState state) { Record rec = null; if (Records.TryGetValue(state, out rec)) { rec.Heap = MathLambda.SubtractTillZero(rec.Heap, Heap_Loss); if (rec.Heap <= 0) { Records.Remove(state); } } }
// public void Sweep public void Update() { if (HitRefreshProgress >= HitRefreshTime) { HitRefreshProgress = 0; // AlliesHit.Clear (); EnemiesHit.Clear(); } else { HitRefreshProgress = MathLambda.AddTillEqualTo(HitRefreshProgress, Time.deltaTime, HitRefreshTime); } }
//public Shape shape; //public float height; //public 2Dimensions StartDimensions; //public 2Dimensions EndDimensions; public new void Update() { if (Persistance > 0) { Destroy(gameObject); } else { if (PersistanceProgress >= Persistance) { PersistanceProgress = MathLambda.AddTillEqualTo(PersistanceProgress, Time.deltaTime, Persistance); } } base.Update(); }
// public void Collect(EntityState state) { Record rec = null; if (Records.TryGetValue(state, out rec)) { rec.Heap = MathLambda.AddTillEqualTo(rec.Heap, Heap_Gain, Maximum_Heap); if (Refreshable) { rec.Progress = 0; } } else { rec = CreateInstance(); // state.Death_Handler += rec.DeathLoss; Records.Add(state, rec); } }
// // // public void Attach (IState state) // { // state.Update_Handler += Refresh; // state.Death_Handler += DeathLoss; // // } // // public void Detach (IState state) // { // state.Update_Handler -= Refresh; // state.Death_Handler -= DeathLoss; // } // public void Update() { foreach (KeyValuePair <EntityState, Record> entry in Records) { if (entry.Value.Heap > 0) { if (Maximum_Progress != 0) { entry.Value.Progress = MathLambda.AddTillEqualTo(entry.Value.Progress, Time.deltaTime, (float)Maximum_Progress); if (entry.Value.Progress >= Maximum_Progress) { entry.Value.Heap = MathLambda.SubtractTillZero(entry.Value.Heap, Heap_Loss); } } } else { Records.Remove(entry.Key); } } }
public void DeathLoss() { Heap = MathLambda.SubtractTillZero(Heap, Heap_Lost_On_Death); }