int CTextAction::execute( CGameState * ) { HGE *hge = hgeCreate(HGE_VERSION); float dt = hge->Timer_GetDelta(); int ret = m_textbox->Update(dt); //DebugMsg("textbox ret: %d\n", ret); bool lbtndown = hge->Input_KeyDown(HGEK_LBUTTON); bool spacedown = hge->Input_KeyDown(HGEK_SPACE); if (ret > 0) { if (m_showText && lbtndown) { return m_textbox->GetID(); } if (spacedown) { m_showText = !m_showText; m_textbox->Show(m_showText); } } else { if (lbtndown) { //m_textbox->SpeedUpLine(); m_textbox->SpeedUpAll(); } } hge->Release(); return 0; }
void Button::action() { if (countdelay != 50) countdelay++; else SetDelayrender(false); if (!IsDelayrender()) { HGE *hge = hgeCreate(HGE_VERSION); float mousex, mousey; hge->Input_GetMousePos(&mousex, &mousey); if (countalpha<255) { countalpha += 5; SetChangeColor(countalpha, 0, 0, 0); } else SetChangeColor(255, 0, 0, 0); if (state != MouseDown) if (mousex > GetX() && mousex<GetX() + width && mousey>GetY() && mousey < GetY() + height) { state = MouseOver; if (!playsound) { playsound = true; SFXManager::GetSFXManager().PlaySFX(BUTTONSFX); } if (state == MouseOver && hge->Input_KeyDown(HGEK_LBUTTON)) { state = MouseDown; SFXManager::GetSFXManager().PlaySFX(BUTTONSFX2); } } else { state = MouseOff; playsound = false; } if (state == MouseDown) { if (!finishchangecolor) { if (!colorreverse) count += 50; else count -= 50; if (count == 250) colorreverse = true; SetChangeColor(count + 5, 255, 255, 255); if (count == 0 && colorreverse) { finishchangecolor = true; SetChangeColor(255, 0, 0, 0); finishmove = false; } } else { switch (buttonnum) { case BUTTON_1_OFF: if (!flag) { SceneManager::GetSceneManager().SetMenuStage(1); flag = true; } if (!finishmove && ObjectPool::GetObjPool().ChangeAllPos(Left, 853)) { finishmove = true; flag = false; state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; } break; case BUTTON_2_OFF: state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; break; case BUTTON_3_OFF: state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; break; case BUTTON_4_OFF: SceneManager::GetSceneManager().ExitGame(); state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; break; case BUTTON_5_OFF: if (!flag && SceneManager::GetSceneManager().ReturnMenuStage() == 2) { SceneManager::GetSceneManager().SetMenuStage(0); flag = true; } if (!finishmove &&SceneManager::GetSceneManager().ReturnMenuStage() == 0 && ObjectPool::GetObjPool().ChangeAllPos(Right, 853)) { flag = false; finishmove = true; state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; } break; case BUTTON_6_OFF: if (!flag&&SceneManager::GetSceneManager().ReturnMenuStage() == 2) { SceneManager::GetSceneManager().SetMenuStage(4); flag = true; } if (!finishmove&&SceneManager::GetSceneManager().ReturnMenuStage()==4 && ObjectPool::GetObjPool().ChangeAllPos(Left, 853)) { flag = false; finishmove = true; state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; } break; case BUTTON_7_OFF: if (!flag && SceneManager::GetSceneManager().ReturnMenuStage() == 2) { SceneManager::GetSceneManager().SetMenuStage(3); flag = true; } if (!finishmove &&SceneManager::GetSceneManager().ReturnMenuStage()==3 && ObjectPool::GetObjPool().ChangeAllPos(Left, 853)) { flag = false; finishmove = true; state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; } break; case BUTTON_8_OFF: state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; break; case BUTTON_9_OFF: state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; break; case BUTTON_10_OFF: state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; break; case BUTTON_11_OFF: state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; break; case BUTTON_12_OFF: state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; SceneManager::GetSceneManager().GoToOneScene(GameScene, false, true); break; case BUTTON_13_OFF: state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; SceneManager::GetSceneManager().GoToOneScene(GameScene); break; case BUTTON_14_OFF: state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; SceneManager::GetSceneManager().GoToOneScene(MenuScene); break; case BUTTON_15_OFF: state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; break; case BUTTON_16_OFF: state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; break; case BUTTON_17_OFF: state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; if (Hero::GetHero().AddStats(ADD_ATK)) SceneManager::GetSceneManager().GoToOneScene(GameScene, false, true); break; case BUTTON_18_OFF: state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; if (Hero::GetHero().AddStats(ADD_DEX)) SceneManager::GetSceneManager().GoToOneScene(GameScene, false, true); break; case BUTTON_19_OFF: state = MouseOff; finishchangecolor = false; buttondown = false; colorreverse = false; if (Hero::GetHero().AddStats(ADD_INT)) SceneManager::GetSceneManager().GoToOneScene(GameScene, false, true); break; } } } } }
void Robot::Action() { switch (GetType()) { case Left: if (!startattack) { if (!trigger) { if (coretype != Eternity) { HGE *hge = hgeCreate(HGE_VERSION); float x, y; hge->Input_GetMousePos(&x, &y); int dis = GetDistance(x, y); if (dis < 20) { if (hge->Input_KeyDown(HGEK_LBUTTON)) { trigger = true; backx = GetX(); backy = GetY(); } else { if (hge->Input_KeyDown(HGEK_RBUTTON)) Suicide(true); } } } } else { ObjectPool::GetObjPool().LockOnGameObject(this); if (runback) { if (GoToAnotherPos(backx,backy)) { trigger = false; runback = false; SetSpeed(0); } } else { HGE *hge = hgeCreate(HGE_VERSION); float x, y; hge->Input_GetMousePos(&x, &y); SetPos(x, y); if (hge->Input_KeyUp(HGEK_LBUTTON)) { if (x<ACT_START_X || x>ACT_END_X || y<ACT_START_Y || y>ACT_END_Y) { runback = true; SetSpeed(1200); } else { switch (coretype) { //攻击型 //开始攻击 case Attack: SetCollisionRange(40); SetSolid(true); SetBlock(true); break; //触发技能型 //跟hero做intercation将自身赋给hero然后自杀 case Magic: dynamic_cast<Hero*>(ObjectPool::GetObjPool().GetOurHero(GetType()))->SetSkill(GetInnerCode() + 300); Suicide(); break; //BUFF型 //施放技能 case Buff: { int count = 0; Hero *a = dynamic_cast<Hero*>(ObjectPool::GetObjPool().GetOurHero(GetType())); for (int i = 0; i < STD_CORES; i++) { Robot *b = dynamic_cast<Robot*>(a->GetCOREs(i)); if (b && b->IsActive()) { if (b->GetInnerCode() == GetInnerCode()) { b->Suicide(); a->Interaction(b); } else if (b->GetCoreType() == Buff) count++; } } SetSpeed(1500); SetAim(25+count * 50, 175); } break; } startattack = true; } } } } } else { switch (coretype) { case Attack: if (GetAim()) GetAngle(GetAim()); if (shootdelay) shootdelay--; else { if (!GetAim()) SetAim(ObjectPool::GetObjPool().GetRandomEnemyUnit(GetType())); else { Skill *skill = new Skill(this, CORESKILL); ObjectPool::GetObjPool().InsertObject(skill, true); } shootdelay = std_shootdelay; } break; case Buff: if (GoToAim()) { if (!buffstart) { ObjectPool::GetObjPool().GetOurHero(GetType())->Interaction(this); buffstart = true; } if (shootdelay) shootdelay--; else { Suicide(); if (host) host->Interaction(this); } } break; } HGE *hge = hgeCreate(HGE_VERSION); if (hge->Input_KeyDown(HGEK_RBUTTON)) { float x, y; hge->Input_GetMousePos(&x, &y); if (GetDistance(backx, backy, x, y) < 20) { Suicide(true); } } } break; case None: if (!GetSpeed()) { HGE *hge = hgeCreate(HGE_VERSION); float x, y; hge->Input_GetMousePos(&x, &y); int dis = GetDistance(x, y); if (dis < 50) { ObjectPool::GetObjPool().GetEnemyHero(GetType())->Scilence(); if (dis < 40) { if (hge->Input_KeyDown(HGEK_LBUTTON)) ObjectPool::GetObjPool().GetEnemyHero(GetType())->Interaction(this); else { if (hge->Input_KeyDown(HGEK_RBUTTON)) { Suicide(true); tremble = 0; } } } } else ObjectPool::GetObjPool().GetEnemyHero(GetType())->UnScilence(); } else ObjectPool::GetObjPool().GetEnemyHero(GetType())->UnScilence(); break; } if (tremble) { tremble--; int a = tremble / 5; int b = tremble % 5; if (a % 2) SetX(GetX() + (3 - b) * 2); else SetX(GetX() - (3 - b) * 2); } }