1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #include <Textur.h>
- #include "Block.h"
- #include "Globals.h"
- Block::Block(const BlockType* zType, Framework::Vec3<int> pos, Model3DData* model, Model3DTextur* texture, int maxHP)
- : Model3D(),
- zType(zType),
- location(pos),
- maxHP((float)maxHP)
- {
- transparent = 0;
- hp = (float)maxHP;
- memset(sideVisible, 1, 6);
- Model3D::setPosition((Framework::Vec3<float>)pos + Framework::Vec3<float>{0.5f, 0.5f, 0.5f});
- setModelDaten(model);
- setModelTextur(texture);
- breakTextur = uiFactory.initParam.bildschirm->zGraphicsApi()->createOrGetTextur("blocks.ltdb/crack.png", 0);
- }
- Block::~Block()
- {
- breakTextur->release();
- }
- void Block::api(char* message)
- {
- // TODO: implement api
- switch (message[0])
- {
- case 0: // hp change
- hp = *(float*)(message + 1);
- break;
- }
- }
- bool Block::isTransparent() const
- {
- return transparent;
- }
- void Block::setSideVisible(Direction dir, bool visible)
- {
- sideVisible[getDirectionIndex(dir)] = visible;
- }
- Vec3<int> Block::getLocation() const
- {
- return location;
- }
- const BlockType* Block::zBlockType() const
- {
- return zType;
- }
- Textur* Block::zEffectTextur()
- {
- if (hp < maxHP)
- return breakTextur;
- return 0;
- }
- float Block::getEffectPercentage()
- {
- return 1 - hp / maxHP;
- }
|