So, I have many objects with materials, each of which has different properties (brick, glass, etc.), and each of them affects elementary effects in different ways. For example, a brick material will be exposed to fire or acid differently than a cement material. A brick that burns or melts will have a different effect when a different burning / melting effect is applied.
At this point in my game I have FSM, but it is very simple. If I remove the fire element on the brick, it will go into the Burning state. However, if I then dropped the water element onto the brick, I might want the fire to go out, take / add health and change the texture (or not depending on the current combination).
The bottom line is that I have many combinations without commonality between them, so I can not create something monotonous. Sometimes I need to change the texture, and sometimes not. Do damage sometimes, and in other cases add health. Sometimes I just need to do nothing in a function. For now, I can only create a global mapping, for example:
FunctionMap [ObjectMaterial] [CurrentObjectState] [ElementBeingApplied]
(those.
Function Map [Brick] [Burning] [Acid]
FunctionMap [Brick] [melting] [acid]
)
The problem is that this is obviously a ton of features due to the number of combinations available with materials and types of effects. Can anyone recommend a route to take or a pattern to look at?
Although this is not entirely relevant for discussion, this is done in AS3 and Away3D.
Here are some of my classes for one example:
public class Brick extends AbstractBlock implements IFireable { public function Brick() { super(this); this.material = new BitmapMaterial(_spriteManager.GetBlockMaterial(BlockUtilities.GetMaterialMap["brick_new"])); _type = "Brick"; } public override function render():void { super.render(); } } public class OnFire extends AbstractDamage { protected var _timeStart:Number = 0; private var _damageAccumulated:Number = 0; public function OnFire(block:AbstractBlock,bombType:String) { super(block,bombType); } public override function enter():void { super.enter(); } public override function exit():void { super.exit(); } public override function update(time:Number):void { super.update(time); if(_timeStart == 0) _timeStart = time; var time_delta:Number = (time - _timeStart)/_waitTime; var damageToSubtract:Number = (time_delta * _damageDone); _damageAccumulated += damageToSubtract; _self.Integrity = _self.Integrity - _damageAccumulated; } }
}
Thus, the element of fire can be applied to a combination of applications. One of these blocks, currently frozen, has now fallen and is now entering the OnFire state. Each block has its own state machine, and the states themselves are objects that you can see.
block.FSM.changeState(new OnFire(block));