Game frame, Effect's abstraction

xiaoxiao2021-03-06  76

1. You can abstract Effect alone, and use two-way polymorphism mode (Visitor®) to implement "action".

Class Effect {

INT EffectStart; // the time effect started

INT Effect Duration; // The Time Effect Holds

INT Effecton (Creature C) {};

}

Class Creature {

...

ArrayList Effects; // The Effects Creature Is Suffering.

Public void Takeeffect (Effect Effect);

Public void updateeffect (Effect Effect); // NEED BE inherited

Public void update ()

{// Iterate Effects

//if (ITERATOR.EFFECTStAtterator.effect Duration) iterator.remove ();

// Execute Updateeffect (Iterator)

}

}

As above, the inheritance class of Effect can freely change Creature's EffectSList (usually added), and Creature's inheritance class can react to Effect of the Updateeffect method.

转载请注明原文地址:https://www.9cbs.com/read-121233.html

New Post(0)