#pragma once #include "olcPixelGameEngine.h" #include "Constant.h" struct Marker{ size_t index; size_t size; }; enum MemoryType{ HEALTH, RANGE, ATKSPD, MOVESPD, PROCEDURE }; struct Memory{ MemoryType type; int size; }; struct Unit; struct UnitGroup{ std::vector>group; vf2d pos; }; struct Unit{ public: Unit(std::vectormemory,vf2d pos,Renderable&img,bool friendly=false); int GetHealth(); int GetRange(); int GetAtkSpd(); int GetMoveSpd(); int GetProcedure(); int GetMemorySize(); std::vectormemory; void Update(float fElapsedTime); virtual void Attack(Unit&victim)=0; virtual void Draw(PixelGameEngine*pge); bool IsFriendly(); bool IsSelected(); void Select(); void Deselect(); vf2d GetPos(); bool IsDead(); vf2d GetUnitSize(); void SetTargetUnit(std::weak_ptrtarget); void SetTargetLocation(vf2d targetLoc); void SetPos(vf2d newPos); protected: vf2d pos; bool friendly; Renderable&img; Marker health; Marker range; Marker atkSpd; Marker moveSpd; Marker procedure; std::weak_ptrtarget; vf2d targetLoc=CONSTANT::UNSELECTED; std::weak_ptrgroup; private: int GetBits(Marker&m); bool selected=false; bool dead=false; bool InRange(std::shared_ptrtarget); bool InRange(vf2d pos); }; struct BasicUnit:Unit{ BasicUnit(vf2d pos,Renderable&img,bool friendly=false); void Attack(Unit&victim)override; }; struct BasicUnit2:Unit{ BasicUnit2(vf2d pos,Renderable&img,bool friendly=false); void Attack(Unit&victim)override; };