|
From: <sir...@us...> - 2006-05-21 06:00:59
|
Revision: 53 Author: sirisian Date: 2006-05-20 23:00:48 -0700 (Sat, 20 May 2006) ViewCVS: http://svn.sourceforge.net/perceptioncrash/?rev=53&view=rev Log Message: ----------- Added Paths: ----------- trunk/perceptioncrash/src/Item System/cDATA_itemSystem.hpp trunk/perceptioncrash/src/Item System/cDATA_weaponItem.hpp trunk/perceptioncrash/src/Item System/c_itemSystem.hpp trunk/perceptioncrash/src/Item System/c_weaponItem.hpp Added: trunk/perceptioncrash/src/Item System/cDATA_itemSystem.hpp =================================================================== --- trunk/perceptioncrash/src/Item System/cDATA_itemSystem.hpp (rev 0) +++ trunk/perceptioncrash/src/Item System/cDATA_itemSystem.hpp 2006-05-21 06:00:48 UTC (rev 53) @@ -0,0 +1,192 @@ +class cDATA_buff +{ + struct s_statBuff + { + std::string attributeName; + int value; + int interval; + }; +public: + std::vector<s_statBuff> buffArray; + void addBuff(std::string attributeName,int value, int interval){ // you'd add a buff like itemData.editLastCreated().addBuff("health rejuvenation", 10,100); meaning a buff of 10 to health rujevenation over 100 time + buffArray[buffArray.size()].value = value; + buffArray[buffArray.size()].attributeName = attributeName; + buffArray[buffArray.size()].interval = interval; + buffArray.push_back(s_statBuff()); + } + std::vector<cDATA_buff::s_statBuff> & getBuffs(){ + return buffArray; + } +}; + +class cDATA_item +{ +public: + virtual cDATA_item::~cDATA_item(){} + + std::string name; + std::string classification; + int size; + int rareness; + int questNumber; +}; + +class cDATA_supplyItem: public cDATA_item +{ +public: + enumSupplyType supplyType; +}; + +class cDATA_usuableItem: public cDATA_item +{ +public: + enumUsuableType usuableType; + int baseAmount; + int cooldownPerUse; + cDATA_buff attributeBuffs; +}; + +class cDATA_ammoItem: public cDATA_item +{ +public: + enumAmmoType ammoType; + + cDATA_ammoItem::cDATA_ammoItem(){ + + } +}; + +class cDATA_equipableItem: public cDATA_item +{ +public: + enumEquipableType equipableType; + cDATA_buff attributeBuffs; + + cDATA_equipableItem::cDATA_equipableItem(){ + + } + cDATA_equipableItem::~cDATA_equipableItem(){ + + } +}; +#include "cDATA_weaponItem.hpp" + +class cDATA_itemDataFactory +{ +public: + cDATA_item *Create(std::string classification) + { + if(classification=="supply") + return new cDATA_supplyItem; + else if(classification=="usuable") + return new cDATA_usuableItem; + else if(classification=="ammo") + return new cDATA_ammoItem; + else if(classification=="equipable") + return new cDATA_equipableItem; + else if(classification=="weapon") + return new cDATA_weaponItem; + } +}; +class cDATA_itemData +{ +private: +cDATA_itemDataFactory itemDataFactory; +int listIndex; +int listSize; +int listCounter; +public: + vector<cDATA_item*> itemData; + int lastIndex; + + cDATA_itemData::cDATA_itemData(){ + listIndex = 0; + listSize = 10; + } + + cDATA_itemData::~cDATA_itemData(){ + while(!itemData.empty()){ + delete itemData[itemData.size()-1]; + itemData.pop_back(); + } + } + + void addItem(std::string classification, std::string name, int size, int rareness, int questNumber) + { + itemData.push_back(itemDataFactory.Create(classification)); + + itemData[itemData.size()-1]->name = name; + itemData[itemData.size()-1]->classification = classification; + itemData[itemData.size()-1]->size = size; + itemData[itemData.size()-1]->rareness = rareness; + itemData[itemData.size()-1]->questNumber = questNumber; + lastIndex=itemData.size()-1; + } + + cDATA_item & editLastCreated(){ + return * itemData[lastIndex]; + } + + cDATA_item & editItemData(int index){ + return *itemData[index]; + } + int getListIndex(){ + return listIndex; + } + int getListSize(){ + return listSize; + } + void checkClick(int mouseX, int mouseY, bool mouseDown, int offsetX, int offsetY){ + if(listCounter<10) + listCounter++; + if(mouseDown==true && listCounter == 10){ + listCounter = 0; + if(mouseX>offsetX && mouseX<offsetX+200 && mouseY>offsetY && mouseY<offsetY+20) + if(listIndex > 0) listIndex--; + + if(mouseX>offsetX && mouseX<offsetX+200 && mouseY>offsetY+(listSize+1)*20 && mouseY<offsetY+20+(listSize+1)*20) + if(listIndex+listSize < itemData.size()) listIndex++; + } + } + + void show(int offsetX, int offsetY){ + glBegin(GL_QUADS); + glColor4ub(200, 200, 200, 255); + glVertex2f(offsetX, offsetY); + glVertex2f(200+offsetX, offsetY); + glVertex2f(200+offsetX, 20+offsetY); + glVertex2f(offsetX, 20+offsetY); + glEnd(); + for(int cycleDataItems = listIndex, drawY = 0; cycleDataItems<(listIndex + listSize > itemData.size() ? itemData.size() : listIndex + listSize); ++cycleDataItems, ++drawY){ + glBegin(GL_QUADS); + glColor4ub(150, 150, 150, 255); + glVertex2f(offsetX, drawY*20+20+offsetY); + glVertex2f(200+offsetX, drawY*20+20+offsetY); + glVertex2f(200+offsetX, drawY*20+40+offsetY); + glVertex2f(offsetX, drawY*20+40+offsetY); + glEnd(); + switch(itemData[cycleDataItems]->rareness){ + case 0: + drawglyphs(itemData[cycleDataItems]->name, 60, 100+offsetX, 5+drawY*20+20+offsetY, 0, 3, 0, 204, 0, 255); + break; + case 1: + drawglyphs(itemData[cycleDataItems]->name, 60, 100+offsetX, 5+drawY*20+20+offsetY, 0, 3, 255, 255, 0, 255); + break; + case 2: + drawglyphs(itemData[cycleDataItems]->name, 60, 100+offsetX, 5+drawY*20+20+offsetY, 0, 3, 204, 0, 255, 255); + break; + } + } + glBegin(GL_QUADS); + glColor4ub(200, 200, 200, 255); + glVertex2f(offsetX, (listSize+1)*20+offsetY); + glVertex2f(200+offsetX, (listSize+1)*20+offsetY); + glVertex2f(200+offsetX, (listSize+1)*20+20+offsetY); + glVertex2f(offsetX, (listSize+1)*20+20+offsetY); + glEnd(); + + drawglyphs("up", 60, 100+offsetX, 5+offsetY, 0, 3, 0, 204, 0, 255); + drawglyphs("down", 60, 100+offsetX, 5+(listSize+1)*20+offsetY, 0, 3, 0, 204, 0, 255); + } +}; + Added: trunk/perceptioncrash/src/Item System/cDATA_weaponItem.hpp =================================================================== --- trunk/perceptioncrash/src/Item System/cDATA_weaponItem.hpp (rev 0) +++ trunk/perceptioncrash/src/Item System/cDATA_weaponItem.hpp 2006-05-21 06:00:48 UTC (rev 53) @@ -0,0 +1,121 @@ +struct s_color +{ + int r, g, b, a;//red,green,blue,alpha +}; +struct s_dataRange +{ + int min, max;//The minimum and maximum of the range. +}; +class cDATA_weaponItem : public cDATA_equipableItem +{ + struct s_modeAccuracy + { + int value;//Accuracy of the Gun -(value) to value modifier + int add;//Amount to add to accuracy when firing + int delay;//How many bullets have to be fired before the COF goes up + int delayTime;//The amount of time for the delay to reset + int cooldownTime;//The time it takes for the accuracy modifier to go down + int cooldownAmount;//The amount the accuracy will go down after the counter equals the time + //add crouch values later + }; + struct s_modeFireRate + { + int value;//Rate at which bullets are fired + int fireModeIndex; + int reFireRate; + int reFireModeIndex; + }; + struct s_modeChargeRate + { + int chargeType;//Charge for Each Bullet, Only Burst Fire, Only ShotGun + int value;//The amount the gun has to charge before firing + bool lockTheGun;//When performing the structures action is the gun locked from doing other things? + }; + struct s_modeStatMod + { + s_dataRange speed; + s_dataRange range; + //ect to have all the mods possible + int fireModeIndex; + }; + struct s_modeReload + { + int value;//The time it takes to reload + bool lockTheGun;//When performing the structures action is the gun locked from doing other things? + int fireModeIndex;//redirects to another firing mode if not its own + }; + struct s_modeBurstShot + { + int value;//How many times the Gun burst shots. + bool lockTheGun;//When performing the structures action is the gun locked from doing other things? + int fireModeIndex;//redirects to another firing mode if not its own + }; + struct s_modeSpreadShot//The number of projectiles fired at one time + { + int value; + bool lockTheGun;//When performing the structures action is the gun locked from doing other things? + int fireModeIndex;//redirects to another firing mode if not its own + }; + struct s_modeAmmoAndClip + { + int ammoType;//Solid, Energy, Grenade, Rocket + int caliber;//The size of the Rounds + int clipType;//Normal Magazine, Banana Clip, Shell Clip, Top-Load Magazine, Canister + s_dataRange speed;//Ammo has different speed classifications, 0-100, and the gun can only use ammo between two values + s_dataRange damageClass;//Ammo has different damage classifications, 0-100, and the gun can only use ammo between two values + s_dataRange range;//Ammo has different range classifications, 0-100, and the gun can only use ammo between two values + s_dataRange ammoCapacity;//Ammo has different ammo capacity classifications, 0-100, and the gun can only use ammo between two values + int fireModeIndex;//redirects to another firing mode if not its own + }; + struct s_modeParticles //When gun is fired, the particles that are created + { + s_color color; + int image; + int interval; + int amount; + int range; + int speed; + s_dataRange angle; + int fireModeIndex;//redirects to another firing mode if not its own + }; + struct s_modeMelee + { + bool value;//Whether the gun can melee + int range;//The range of the melee attack + int baseDamage;//The normal damage of the melee + int modDamage;//Any extra damage the gun may do + int interval;//The time it takes to melee with the weapon + }; + struct s_firingMode + { + s_modeAccuracy accuracy; + s_modeFireRate fireRate; + s_modeChargeRate chargeRate; + s_modeStatMod statMod; + s_modeReload reload; + s_modeBurstShot burstShot; + s_modeSpreadShot spreadShot; + s_modeAmmoAndClip ammoAndClip; + s_modeParticles fireParticles; + }; + +private: + s_modeMelee melee; + std::vector<s_firingMode> firingModes; + +public: + cDATA_weaponItem::cDATA_weaponItem(){ + + } + void Initialize(int numberOfFiringModes){ + for(int expandFiringModes = 0; expandFiringModes < numberOfFiringModes; ++expandFiringModes){ + firingModes.push_back(s_firingMode()); + } + } + s_firingMode & cDATA_weaponItem::editFiringMode(int firingMode){ + return firingModes[firingMode]; + } + s_modeMelee & cDATA_weaponItem::editMelee(int firingMode){ + return melee; + } +}; Added: trunk/perceptioncrash/src/Item System/c_itemSystem.hpp =================================================================== --- trunk/perceptioncrash/src/Item System/c_itemSystem.hpp (rev 0) +++ trunk/perceptioncrash/src/Item System/c_itemSystem.hpp 2006-05-21 06:00:48 UTC (rev 53) @@ -0,0 +1,186 @@ +class c_item +{ +public: + virtual c_item::~c_item(){} + int itemDataIndex; + int quantity; + bool slotUsed; +}; + +class c_supplyItem: public c_item +{ +public: + +}; + +class c_usuableItem: public c_item +{ +public: + enumUsuableType usuableType; + int amountLeft; + int cooldownCounter; + c_usuableItem::c_usuableItem(){ + amountLeft = 0; + cooldownCounter = 0; + } +}; + +class c_ammoItem: public c_item +{ +public: + enumAmmoType ammoType; + + c_ammoItem::c_ammoItem(){ + + } +}; + +class c_equipableItem: public c_item +{ +public: + c_equipableItem::c_equipableItem(){ + + } + c_equipableItem::~c_equipableItem(){ + + } +}; +#include "c_weaponItem.hpp" +class c_itemDataFactory +{ +public: + c_item *Create(std::string classification) + { + if(classification=="supply") + return new c_supplyItem; + else if(classification=="usuable") + return new c_usuableItem; + else if(classification=="ammo") + return new c_ammoItem; + else if(classification=="equipable") + return new c_equipableItem; + else if(classification=="weapon") + return new c_weaponItem; + } +}; + +class c_itemInventory +{ +private: +c_itemDataFactory itemDataFactory; +int listIndex; +int listSize; +int listCounter; +public: + vector<c_item*> itemInventoryData; + + c_itemInventory::c_itemInventory(){ + listIndex = 0; + listSize = 10; + } + + c_itemInventory::~c_itemInventory(){ + while(!itemInventoryData.empty()){ + delete itemInventoryData[itemInventoryData.size()-1]; + itemInventoryData.pop_back(); + } + } + + void addItem(int itemDataIndex, int quantity, cDATA_itemData & itemData) + { + + for(int cycleItems = 0; cycleItems < itemInventoryData.size(); ++cycleItems){ + if(itemInventoryData[cycleItems]->slotUsed == false){ + delete itemInventoryData[cycleItems]; + itemInventoryData[cycleItems] = itemDataFactory.Create(itemData.itemData[itemDataIndex]->classification); + itemInventoryData[cycleItems]->slotUsed = true; + itemInventoryData[cycleItems]->itemDataIndex = itemDataIndex; + itemInventoryData[cycleItems]->quantity = quantity; + return; + } + } + + itemInventoryData.push_back(itemDataFactory.Create(itemData.itemData[itemDataIndex]->classification)); + itemInventoryData[itemInventoryData.size()-1]->slotUsed = true; + itemInventoryData[itemInventoryData.size()-1]->itemDataIndex = itemDataIndex; + itemInventoryData[itemInventoryData.size()-1]->quantity = quantity; + } + + c_item & editItemData(int index){ + return *itemInventoryData[index]; + } + + void checkClick(int mouseX, int mouseY, bool mouseDown, int offsetX, int offsetY){ + if(listCounter<10) + listCounter++; + if(mouseDown==true && listCounter == 10){ + listCounter = 0; + if(mouseX>offsetX && mouseX<offsetX+200 && mouseY>offsetY && mouseY<offsetY+20) + if(listIndex > 0) listIndex--; + + if(mouseX>offsetX && mouseX<offsetX+200 && mouseY>offsetY+(listSize+1)*20 && mouseY<offsetY+20+(listSize+1)*20) + if(listIndex+listSize < itemInventoryData.size()) listIndex++; + + for(int cycleItems = listIndex, checkY = 0; cycleItems < (listIndex+listSize<itemInventoryData.size() ? listIndex+listSize : itemInventoryData.size()); ++cycleItems, ++checkY){ + if(itemInventoryData[cycleItems]->slotUsed == true){ + if(mousex>offsetX && mousex<offsetX+200 && mousey>offsetY+20+checkY*20 && mousey<offsetY+40+checkY*20){ + itemInventoryData[cycleItems]->slotUsed = false; + itemInventoryData.erase(itemInventoryData.begin()+cycleItems ); + break; + } + } + } + } + } + + void show(int offsetX, int offsetY, cDATA_itemData & itemData){ + glBegin(GL_QUADS); + glColor4ub(200, 200, 200, 255); + glVertex2f(offsetX, offsetY); + glVertex2f(200+offsetX, offsetY); + glVertex2f(200+offsetX, 20+offsetY); + glVertex2f(offsetX, 20+offsetY); + glEnd(); + for(int cycleDataItems = listIndex, drawY = 0; cycleDataItems<(listIndex + listSize > itemInventoryData.size() ? itemInventoryData.size() : listIndex + listSize); ++cycleDataItems, ++drawY){ + if(itemInventoryData[cycleDataItems]->slotUsed == true){ + glBegin(GL_QUADS); + glColor4ub(150, 150, 150, 255); + glVertex2f(offsetX, drawY*20+20+offsetY); + glVertex2f(200+offsetX, drawY*20+20+offsetY); + glVertex2f(200+offsetX, drawY*20+40+offsetY); + glVertex2f(offsetX, drawY*20+40+offsetY); + glEnd(); + + switch(itemData.itemData[itemInventoryData[cycleDataItems]->itemDataIndex]->rareness){ + case 0: + drawglyphs(itemData.itemData[itemInventoryData[cycleDataItems]->itemDataIndex]->name, 60, 100+offsetX, 5+drawY*20+20+offsetY, 0, 3, 0, 204, 0, 255); + break; + case 1: + drawglyphs(itemData.itemData[itemInventoryData[cycleDataItems]->itemDataIndex]->name, 60, 100+offsetX, 5+drawY*20+20+offsetY, 0, 3, 255, 255, 0, 255); + break; + case 2: + drawglyphs(itemData.itemData[itemInventoryData[cycleDataItems]->itemDataIndex]->name, 60, 100+offsetX, 5+drawY*20+20+offsetY, 0, 3, 204, 0, 255, 255); + break; + } + }else{ + glBegin(GL_QUADS); + glColor4ub(255, 0, 255, 255); + glVertex2f(offsetX, drawY*20+20+offsetY); + glVertex2f(200+offsetX, drawY*20+20+offsetY); + glVertex2f(200+offsetX, drawY*20+40+offsetY); + glVertex2f(offsetX, drawY*20+40+offsetY); + glEnd(); + } + } + glBegin(GL_QUADS); + glColor4ub(200, 200, 200, 255); + glVertex2f(offsetX, (listSize+1)*20+offsetY); + glVertex2f(200+offsetX, (listSize+1)*20+offsetY); + glVertex2f(200+offsetX, (listSize+1)*20+20+offsetY); + glVertex2f(offsetX, (listSize+1)*20+20+offsetY); + glEnd(); + + drawglyphs("up", 60, 100+offsetX, 5+offsetY, 0, 3, 0, 204, 0, 255); + drawglyphs("down", 60, 100+offsetX, 5+(listSize+1)*20+offsetY, 0, 3, 0, 204, 0, 255); + } +}; Added: trunk/perceptioncrash/src/Item System/c_weaponItem.hpp =================================================================== --- trunk/perceptioncrash/src/Item System/c_weaponItem.hpp (rev 0) +++ trunk/perceptioncrash/src/Item System/c_weaponItem.hpp 2006-05-21 06:00:48 UTC (rev 53) @@ -0,0 +1,78 @@ +class c_weaponItem : public c_equipableItem +{ + struct s_modeAccuracy + { + int delayCounter; + int cooldownCounter; + //add crouch values later + }; + struct s_modeFireRate + { + int rateCounter; + int reFireRateCounter; + }; + struct s_modeChargeRate + { + int chargeCounter; + }; + struct s_modeStatMod + { + int speedMod; + int rangeMod; + //ect to have all the mods possible + }; + struct s_modeReload + { + int counter; + }; + struct s_modeBurstShot + { + int counter; + }; + struct s_modeSpreadShot//The number of projectiles fired at one time + { + int counter; + }; + struct s_modeAmmoAndClip + { + int itemNumber; + }; + struct s_modeParticles //When gun is fired, the particles that are created + { + int intervalCounter; + }; + struct s_modeMelee + { + int modDamage;//Any extra damage the gun may do + int intervalCounter;//a counter to keep track of when the gun can melee again + }; + struct s_firingMode + { + s_modeAccuracy accuracy; + s_modeFireRate fireRate; + s_modeChargeRate chargeRate; + s_modeStatMod statMod; + s_modeReload reload; + s_modeBurstShot burstShot; + s_modeSpreadShot spreadShot; + s_modeAmmoAndClip ammoAndClip; + }; +private: + s_modeMelee melee; + std::vector<s_firingMode> firingModes; +public: + c_weaponItem::c_weaponItem(){ + + } + void Initialize(int numberOfFiringModes){ + for(int expandFiringModes = 0; expandFiringModes < numberOfFiringModes; ++expandFiringModes){ + firingModes.push_back(s_firingMode()); + } + } + c_weaponItem::s_firingMode & editFiringMode(int firingMode){ + return firingModes[firingMode]; + } + c_weaponItem::s_modeMelee & editMeleeMode(int firingMode){ + return melee; + } +}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |