Mana implemented. When not enough mana is available for an ability, a notification appears.
This commit is contained in:
parent
6d4c069fe4
commit
77bd085908
@ -1,5 +1,5 @@
|
||||
#include "Ability.h"
|
||||
|
||||
Ability::Ability(){};
|
||||
Ability::Ability(std::string name,float cooldownTime,Pixel barColor1,Pixel barColor2)
|
||||
:name(name),cooldown(0),COOLDOWN_TIME(cooldownTime),barColor1(barColor1),barColor2(barColor2){}
|
||||
Ability::Ability(std::string name,float cooldownTime,int manaCost,Pixel barColor1,Pixel barColor2)
|
||||
:name(name),cooldown(0),COOLDOWN_TIME(cooldownTime),manaCost(manaCost),barColor1(barColor1),barColor2(barColor2){}
|
@ -1,11 +1,13 @@
|
||||
#pragma once
|
||||
#include "olcPixelGameEngine.h"
|
||||
|
||||
//Abilities are tied to class data which is defined in Class.cpp.
|
||||
struct Ability{
|
||||
std::string name="";
|
||||
float cooldown=0;
|
||||
float COOLDOWN_TIME=0;
|
||||
int manaCost=0;
|
||||
Pixel barColor1,barColor2;
|
||||
Ability();
|
||||
Ability(std::string name,float cooldownTime,Pixel barColor1=VERY_DARK_RED,Pixel barColor2=DARK_RED);
|
||||
Ability(std::string name,float cooldownTime,int manaCost,Pixel barColor1=VERY_DARK_RED,Pixel barColor2=DARK_RED);
|
||||
};
|
@ -3,55 +3,55 @@
|
||||
std::map<Class,ClassData>CLASS_DATA={
|
||||
{WARRIOR,{
|
||||
"Warrior",WARRIOR,
|
||||
{"Block",15,VERY_DARK_BLUE,DARK_BLUE},
|
||||
{"Battlecry",12},
|
||||
{"Ground Slam",15},
|
||||
{"Sonic Slash",40},
|
||||
{"Block",15,0,VERY_DARK_BLUE,DARK_BLUE},
|
||||
{"Battlecry",12,40},
|
||||
{"Ground Slam",15,50},
|
||||
{"Sonic Slash",40,60},
|
||||
WARRIOR_WALK_N,WARRIOR_WALK_E,WARRIOR_WALK_S,WARRIOR_WALK_W,
|
||||
WARRIOR_IDLE_N,WARRIOR_IDLE_E,WARRIOR_IDLE_S,WARRIOR_IDLE_W,
|
||||
}},
|
||||
{THIEF,{
|
||||
"Thief",THIEF,
|
||||
{"???",15,VERY_DARK_BLUE,DARK_BLUE},
|
||||
{"???",12},
|
||||
{"???",15},
|
||||
{"???",40},
|
||||
{"???",15,0,VERY_DARK_BLUE,DARK_BLUE},
|
||||
{"???",12,0},
|
||||
{"???",15,0},
|
||||
{"???",40,0},
|
||||
WARRIOR_WALK_N,WARRIOR_WALK_E,WARRIOR_WALK_S,WARRIOR_WALK_W,
|
||||
WARRIOR_IDLE_N,WARRIOR_IDLE_E,WARRIOR_IDLE_S,WARRIOR_IDLE_W,
|
||||
}},
|
||||
{RANGER,{
|
||||
"Ranger",RANGER,
|
||||
{"Retreat",7,VERY_DARK_BLUE,DARK_BLUE},
|
||||
{"Rapid Fire",12},
|
||||
{"Charged Shot",15},
|
||||
{"Multishot",25},
|
||||
{"Retreat",7,0,VERY_DARK_BLUE,DARK_BLUE},
|
||||
{"Rapid Fire",12,35},
|
||||
{"Charged Shot",15,40},
|
||||
{"Multishot",25,50},
|
||||
RANGER_WALK_N,RANGER_WALK_E,RANGER_WALK_S,RANGER_WALK_W,
|
||||
RANGER_IDLE_N,RANGER_IDLE_E,RANGER_IDLE_S,RANGER_IDLE_W,
|
||||
}},
|
||||
{BARD,{
|
||||
"Bard",BARD,
|
||||
{"???",7,VERY_DARK_BLUE,DARK_BLUE},
|
||||
{"???",12},
|
||||
{"???",15},
|
||||
{"???",25},
|
||||
{"???",7,0,VERY_DARK_BLUE,DARK_BLUE},
|
||||
{"???",12,0},
|
||||
{"???",15,0},
|
||||
{"???",25,0},
|
||||
WARRIOR_WALK_N,WARRIOR_WALK_E,WARRIOR_WALK_S,WARRIOR_WALK_W,
|
||||
WARRIOR_IDLE_N,WARRIOR_IDLE_E,WARRIOR_IDLE_S,WARRIOR_IDLE_W,
|
||||
}},
|
||||
{WIZARD,{
|
||||
"Wizard",WIZARD,
|
||||
{"Teleport",8,VERY_DARK_BLUE,DARK_BLUE},
|
||||
{"Firebolt",6},
|
||||
{"Lightning Bolt",6},
|
||||
{"Meteor",40},
|
||||
{"Teleport",8,5,VERY_DARK_BLUE,DARK_BLUE},
|
||||
{"Firebolt",6,30},
|
||||
{"Lightning Bolt",6,25},
|
||||
{"Meteor",40,75},
|
||||
WIZARD_WALK_N,WIZARD_WALK_E,WIZARD_WALK_S,WIZARD_WALK_W,
|
||||
WIZARD_IDLE_N,WIZARD_IDLE_E,WIZARD_IDLE_S,WIZARD_IDLE_W,
|
||||
}},
|
||||
{WITCH,{
|
||||
"Witch",WITCH,
|
||||
{"???",8,VERY_DARK_BLUE,DARK_BLUE},
|
||||
{"???",6},
|
||||
{"???",6},
|
||||
{"???",40},
|
||||
{"???",8,0,VERY_DARK_BLUE,DARK_BLUE},
|
||||
{"???",6,0},
|
||||
{"???",6,0},
|
||||
{"???",40,0},
|
||||
WARRIOR_WALK_N,WARRIOR_WALK_E,WARRIOR_WALK_S,WARRIOR_WALK_W,
|
||||
WARRIOR_IDLE_N,WARRIOR_IDLE_E,WARRIOR_IDLE_S,WARRIOR_IDLE_W,
|
||||
}},
|
||||
|
@ -42,6 +42,7 @@ bool Crawler::OnUserCreate(){
|
||||
GFX_Ranger_Sheet.Load("assets/nico-ranger.png");
|
||||
GFX_Wizard_Sheet.Load("assets/nico-wizard.png");
|
||||
GFX_Battlecry_Effect.Load("assets/battlecry_effect.png");
|
||||
GFX_Mana.Load("assets/mana.png");
|
||||
|
||||
//Animations
|
||||
InitializeAnimations();
|
||||
@ -352,24 +353,6 @@ void Crawler::HandleUserInput(float fElapsedTime){
|
||||
}break;
|
||||
}
|
||||
}
|
||||
if(player.ability2.cooldown==0&&GetKey(SPACE).bPressed){
|
||||
switch(player.cl){
|
||||
case WARRIOR:{
|
||||
player.Spin(Player::GROUND_SLAM_SPIN_TIME,14*PI);
|
||||
player.iframe_time=Player::GROUND_SLAM_SPIN_TIME+0.1;
|
||||
}break;
|
||||
case THIEF:{
|
||||
}break;
|
||||
case RANGER:{
|
||||
}break;
|
||||
case BARD:{
|
||||
}break;
|
||||
case WIZARD:{
|
||||
}break;
|
||||
case WITCH:{
|
||||
}break;
|
||||
}
|
||||
}
|
||||
if(player.GetVelocity()==vf2d{0,0}){
|
||||
if(RightHeld()){
|
||||
if(player.GetPos().x+12*player.GetSizeMult()+fElapsedTime*100*player.GetMoveSpdMult()<WORLD_SIZE.x*24){
|
||||
@ -682,7 +665,9 @@ void Crawler::RenderHud(){
|
||||
offset-=6;
|
||||
}
|
||||
DrawDecal({2,2},GFX_Heart.Decal());
|
||||
DrawDecal({2,20},GFX_Mana.Decal());
|
||||
std::string text=player.GetHealth()>0?std::to_string(player.GetHealth()):"X";
|
||||
std::string text_mana=std::to_string(player.GetMana());
|
||||
for(int y=-1;y<=1;y++){
|
||||
for(int x=-1;x<=1;x++){
|
||||
if(x!=0||y!=0){
|
||||
@ -690,7 +675,20 @@ void Crawler::RenderHud(){
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int y=-1;y<=1;y++){
|
||||
for(int x=-1;x<=1;x++){
|
||||
if(x!=0||y!=0){
|
||||
DrawStringPropDecal(vf2d{24,23}+vf2d{float(x),float(y)},text_mana,BLACK,{1.5,1.5});
|
||||
}
|
||||
}
|
||||
}
|
||||
DrawStringPropDecal({20,3},text,WHITE,{2,2});
|
||||
DrawStringPropDecal({24,23},text_mana,{192,192,255},{1.5,1.5});
|
||||
if(player.notEnoughManaDisplay.second>0){
|
||||
std::string displayText="Not enough mana for "+player.notEnoughManaDisplay.first+"!";
|
||||
DrawStringPropDecal(vf2d{float(ScreenWidth()/2),float(ScreenHeight()/4)}-GetTextSizeProp(displayText)/2+vf2d{1,1},displayText,VERY_DARK_RED);
|
||||
DrawStringPropDecal(vf2d{float(ScreenWidth()/2),float(ScreenHeight()/4)}-GetTextSizeProp(displayText)/2,displayText,DARK_RED);
|
||||
}
|
||||
std::string versionStr("v" + std::to_string(VERSION_MAJOR) + "." + std::to_string(VERSION_MINOR) + "." + std::to_string(VERSION_PATCH) + "." + std::to_string(VERSION_BUILD));
|
||||
DrawStringDecal(vf2d{ GetScreenSize() } - vf2d{ GetTextSize(versionStr) }*0.4 - vf2d{ 0.4,0 }, versionStr, WHITE, { 0.4,0.4 });
|
||||
DrawStringDecal(vf2d{ GetScreenSize() } - vf2d{ GetTextSize(versionStr) }*0.4 - vf2d{ 0,0.4 }, versionStr, WHITE, { 0.4,0.4 });
|
||||
|
@ -15,7 +15,7 @@ class Crawler : public olc::PixelGameEngine
|
||||
Renderable GFX_Warrior_Sheet,GFX_Slime_Sheet,GFX_Circle,
|
||||
GFX_Effect_GroundSlam_Back,GFX_Effect_GroundSlam_Front,
|
||||
GFX_Heart,GFX_BLOCK_BUBBLE,GFX_Ranger_Sheet,GFX_Wizard_Sheet,
|
||||
GFX_Battlecry_Effect;
|
||||
GFX_Battlecry_Effect,GFX_Mana;
|
||||
std::vector<Effect>foregroundEffects,backgroundEffects;
|
||||
|
||||
public:
|
||||
|
@ -1,3 +1,9 @@
|
||||
Mana: 100
|
||||
Mana Recovery: 1 mana every 0.2 (=5/s)
|
||||
|
||||
Mana can be increased but only slightly
|
||||
Mana recovery may an increased with legendary items in post game. but so far no plans in the base game.
|
||||
|
||||
Warrior
|
||||
Rightclick - Block
|
||||
1 - Battlecry
|
||||
@ -32,13 +38,13 @@ cd 7 seconds.
|
||||
Shoots 4 auto hits with 0.1 sec delay between each shot. Animation locked
|
||||
Normal auto hit Damage (x4)
|
||||
12 sec cd.
|
||||
2 Charged shot
|
||||
35 Mana
|
||||
2 Charged shot
|
||||
Shots an arrow that does Pierce dmg. 0.3 charge animation lock
|
||||
Damage: 2.5x Atk
|
||||
15 sec. cd
|
||||
3 Multishot
|
||||
40 Mana
|
||||
3 Multishot
|
||||
Shots 6 Arrows at once in a volley
|
||||
every arrow normal autohit dmg. (can be used as shotgun against large foes for 6x atk)
|
||||
25 sec. cd
|
||||
|
@ -66,6 +66,14 @@ int Player::GetMaxHealth(){
|
||||
return maxhp;
|
||||
}
|
||||
|
||||
int Player::GetMana(){
|
||||
return mana;
|
||||
}
|
||||
|
||||
int Player::GetMaxMana() {
|
||||
return maxmana;
|
||||
}
|
||||
|
||||
int Player::GetAttack(){
|
||||
float mod_atk=atk;
|
||||
for(Buff&b:GetBuffs(BuffType::ATTACK_UP)){
|
||||
@ -101,6 +109,12 @@ State Player::GetState(){
|
||||
void Player::Update(float fElapsedTime){
|
||||
attack_cooldown_timer=std::max(0.f,attack_cooldown_timer-fElapsedTime);
|
||||
iframe_time=std::max(0.f,iframe_time-fElapsedTime);
|
||||
notEnoughManaDisplay.second=std::max(0.f,notEnoughManaDisplay.second-fElapsedTime);
|
||||
manaTickTimer-=fElapsedTime;
|
||||
while(manaTickTimer<=0){
|
||||
manaTickTimer+=0.2;
|
||||
mana=std::min(maxmana,mana+1);
|
||||
}
|
||||
for(std::vector<Buff>::iterator it=buffList.begin();it!=buffList.end();++it){
|
||||
Buff&b=*it;
|
||||
b.duration-=fElapsedTime;
|
||||
@ -240,7 +254,7 @@ void Player::Update(float fElapsedTime){
|
||||
}break;
|
||||
}
|
||||
}
|
||||
if(ability1.cooldown==0&&game->GetKey(SHIFT).bHeld){
|
||||
if(ability1.cooldown==0&&GetMana()>=ability1.manaCost&&game->GetKey(SHIFT).bHeld){
|
||||
switch (cl) {
|
||||
case WARRIOR: {
|
||||
game->AddEffect(Effect(pos,0.1,AnimationState::BATTLECRY_EFFECT,1,0.3));
|
||||
@ -264,8 +278,55 @@ void Player::Update(float fElapsedTime){
|
||||
case WITCH: {
|
||||
}break;
|
||||
}
|
||||
mana-=ability1.manaCost;
|
||||
} else
|
||||
if(ability1.cooldown==0&&GetMana()<ability1.manaCost&&game->GetKey(SHIFT).bPressed){
|
||||
notEnoughManaDisplay={ability1.name,1};
|
||||
}
|
||||
if(rightClickAbility.cooldown==0&&game->GetMouse(1).bHeld){
|
||||
if(ability2.cooldown==0&&GetMana()>=ability2.manaCost&&game->GetKey(SPACE).bPressed){
|
||||
switch(cl){
|
||||
case WARRIOR:{
|
||||
Spin(GROUND_SLAM_SPIN_TIME,14*PI);
|
||||
iframe_time=GROUND_SLAM_SPIN_TIME+0.1;
|
||||
}break;
|
||||
case THIEF:{
|
||||
}break;
|
||||
case RANGER:{
|
||||
}break;
|
||||
case BARD:{
|
||||
}break;
|
||||
case WIZARD:{
|
||||
}break;
|
||||
case WITCH:{
|
||||
}break;
|
||||
}
|
||||
mana-=ability2.manaCost;
|
||||
} else
|
||||
if(ability2.cooldown==0&&GetMana()<ability2.manaCost&&game->GetKey(SPACE).bPressed){
|
||||
notEnoughManaDisplay={ability2.name,1};
|
||||
}
|
||||
if(ability3.cooldown==0&&GetMana()>=ability3.manaCost&&game->GetKey(CTRL).bPressed){
|
||||
switch(cl){
|
||||
case WARRIOR:{
|
||||
//TODO
|
||||
}break;
|
||||
case THIEF:{
|
||||
}break;
|
||||
case RANGER:{
|
||||
}break;
|
||||
case BARD:{
|
||||
}break;
|
||||
case WIZARD:{
|
||||
}break;
|
||||
case WITCH:{
|
||||
}break;
|
||||
}
|
||||
mana-=ability3.manaCost;
|
||||
} else
|
||||
if(ability3.cooldown==0&&GetMana()<ability3.manaCost&&game->GetKey(CTRL).bPressed){
|
||||
notEnoughManaDisplay={ability3.name,1};
|
||||
}
|
||||
if(rightClickAbility.cooldown==0&&GetMana()>=rightClickAbility.manaCost&&game->GetMouse(1).bHeld){
|
||||
switch (cl) {
|
||||
case WARRIOR: {
|
||||
if(GetState()==State::NORMAL){
|
||||
@ -285,6 +346,10 @@ void Player::Update(float fElapsedTime){
|
||||
case WITCH: {
|
||||
}break;
|
||||
}
|
||||
mana-=rightClickAbility.manaCost;
|
||||
} else
|
||||
if(rightClickAbility.cooldown==0&&GetMana()<rightClickAbility.manaCost&&game->GetMouse(1).bPressed){
|
||||
notEnoughManaDisplay={rightClickAbility.name,1};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ struct Player{
|
||||
private:
|
||||
Class cl=WARRIOR;
|
||||
int hp=100,maxhp=hp;
|
||||
int mana=100,maxmana=mana;
|
||||
int atk=10;
|
||||
vf2d pos;
|
||||
vf2d vel={0,0};
|
||||
@ -29,6 +30,8 @@ struct Player{
|
||||
float lastAnimationFlip=0;
|
||||
float swordSwingTimer=0;
|
||||
float iframe_time=0;
|
||||
float manaTickTimer=0;
|
||||
std::pair<std::string,float> notEnoughManaDisplay={"",0};
|
||||
State state=State::NORMAL;
|
||||
Animate2D::Animation<AnimationState>animation;
|
||||
Animate2D::AnimationState internal_animState;
|
||||
@ -57,6 +60,8 @@ struct Player{
|
||||
float GetZ();
|
||||
int GetHealth();
|
||||
int GetMaxHealth();
|
||||
int GetMana();
|
||||
int GetMaxMana();
|
||||
int GetAttack();
|
||||
float GetMoveSpdMult();
|
||||
float GetSizeMult();
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 0
|
||||
#define VERSION_BUILD 45
|
||||
#define VERSION_BUILD 53
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
BIN
Crawler/assets/mana.png
Normal file
BIN
Crawler/assets/mana.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 697 B |
Loading…
x
Reference in New Issue
Block a user