Skip to content

Commit

Permalink
Merge pull request #53 from jonylu7/buttonUpdate01
Browse files Browse the repository at this point in the history
update
  • Loading branch information
jonylu7 authored Apr 12, 2024
2 parents 8c46d7b + c1bdb69 commit 27d58ce
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 deletions.
1 change: 0 additions & 1 deletion include/Scene/MenuScene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class MenuScene : public Scene {
case (SceneMode::DEFAULT):
m_DefaultScene->Update();
break;
case (SceneMode::MENU):
}
}

Expand Down
13 changes: 11 additions & 2 deletions include/Unit/Avatar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class Avatar : public PathfindingUnit,
setNextCell(destination);

setMovementSpeed(4);
m_currentMode=UnitMode::MOVE;
m_Transform.scale={0.5,0.5};
}
virtual void aliveUpdate() {
if (walkTowardNextCell() || b_justStarted) {
Expand All @@ -40,9 +42,13 @@ class Avatar : public PathfindingUnit,
printf("(aliveUpdate) getting new dir\n");
}
// m_wayPointUnit.Update();
SetVisible(true);
m_Transform.translation = getCurrentLocation();

Draw();
printf("-----------------------------\n");

printf("Avatar cell={%d,%d}\n",getCurrentLocation().x,getCurrentLocation().y);
printf("-----------avatar------------------\n");
}

float getDistance(glm::vec2 cell) {
Expand Down Expand Up @@ -98,19 +104,22 @@ class Avatar : public PathfindingUnit,
}

virtual std::shared_ptr<Util::Image> customizeImage() {
return std::make_unique<Util::Image>("../assets/sprites/capybara.png");
return std::make_unique<Util::Image>("../assets/sprites/Hunter.png");
}
virtual void Update() override {
switch (m_currentMode) {
case (UnitMode::DEAD): {
SetVisible(false);
break;
}
case (UnitMode::MOVE): {
aliveUpdate();
break;
}
case (UnitMode::MOVE_ATTACK): {
aliveUpdate();
customizeUpdate();
break;
}
// attack
}
Expand Down
1 change: 1 addition & 0 deletions src/Map/YAMLReader.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//
// Created by 盧威任 on 3/18/24.
//
#include <iomanip>
#include "Map/YAMLReader.hpp"
#include "Map/Tile.hpp"

Expand Down
12 changes: 6 additions & 6 deletions src/Scene/DefaultScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ void DefaultScene::Start() {

// m_hunter->setCurrentCell({20,10});
// m_runner->setCurrentCell({10,10});
m_hunter->Start({20, 9});
m_runner->Start({9, 10});
m_hunter->setTarget(m_runner);
m_runner->setBeingChase(m_hunter);
// m_hunter->Start({20, 9});
// m_runner->Start({9, 10});
// m_hunter->setTarget(m_runner);
// m_runner->setBeingChase(m_hunter);
}

void DefaultScene::Update() {
m_hunter->Update();
m_runner->Update();
// m_hunter->Update();
// m_runner->Update();

m_GameObjectManager->Update();

Expand Down
2 changes: 1 addition & 1 deletion src/UI/UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ std::shared_ptr<Avatar> UIClass::getUnitFromUI() {
ButtonScript.setIfReadytoSpawn(false);
if (std::dynamic_pointer_cast<Infantry>(Avatar)) {

Avatar->Start(m_barrackCell);
Avatar->Start({m_barrackCell.x+1,m_barrackCell.y+1});
Avatar->setNewDestination(m_barrackTargetCell);
}
printf("(UI)return to GOM success\n");
Expand Down
6 changes: 3 additions & 3 deletions src/UI/UIScriptProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void UIScriptProcess::CountDown() {
b_isSpawningInCooldown) {
b_isReadyToSpawn = true;
b_isSpawningInCooldown = false;
// printf("(UISC)Unit Ready\n");
printf("(UISC)Unit Ready\n");
}
}

Expand All @@ -126,8 +126,8 @@ void UIScriptProcess::CountDown() {
// "False");
}
if (b_isSpawningInCooldown) {
// printf("(UISC) CD: %.2f,%s\n", unitElapsed.count(),
// elapsed.count() >= m_spawnCooldownTime ? "True" : "False");
printf("(UISC) CD: %.2f,%s\n", spawnElapsed.count(),spawnElapsed.count() >= spawnCoolDownTime ? "True" : "False");

}
}
void UIScriptProcess::SetBuildCountDown(float time) {
Expand Down

0 comments on commit 27d58ce

Please sign in to comment.