Commit 3a9e6437 authored by 魔大农's avatar 魔大农 🍀

Made Quatter indicator arrow length depend on row/column

parent b3462005
No preview for this file type
......@@ -94,19 +94,23 @@ Board::Board(): Object(MC->GetContext()),
arrowNode1->SetPosition(Vector3::LEFT * (2.3f + 0.95f * (i == 2 || i == 3)) + Vector3::FORWARD * (i >= 4));
arrowNode1->Rotate(Quaternion(-90.0f, Vector3::UP));
indicator->model1_ = arrowNode1->CreateComponent<AnimatedModel>();
if (i < 4)
if (i < 4){
indicator->model1_->SetModel(MC->GetModel("Arrow"));
else
indicator->model1_->SetMorphWeight(0, static_cast<float>(i < 2));
} else {
indicator->model1_->SetModel(MC->GetModel("BlockIndicator"));
}
indicator->model1_->SetMaterial(indicator->glow_);
Node* arrowNode2{indicator->rootNode_->CreateChild("Arrow")};
arrowNode2->SetPosition(Vector3::RIGHT * (2.3f + 0.95f * (i == 2 || i == 3)));
arrowNode2->Rotate(Quaternion(90.0f, Vector3::UP));
indicator->model2_ = arrowNode2->CreateComponent<AnimatedModel>();
if (i < 4)
if (i < 4){
indicator->model2_->SetModel(MC->GetModel("Arrow"));
else
indicator->model2_->SetMorphWeight(0, static_cast<float>(i < 2));
} else {
indicator->model2_->SetModel(MC->GetModel("BlockIndicator"));
}
indicator->model2_->SetMaterial(indicator->glow_);
indicator->model2_->GetMaterial()->SetShaderParameter("MatDiffColor", Color(0.0f, 0.0f, 0.0f, 0.0f));
//Create light
......@@ -456,10 +460,14 @@ void Board::Indicate(IntVector2 first, IntVector2 last)
} else if (first.y_ == last.y_){
FX->FadeTo(indicators_[0]->glow_, COLOR_GLOW, 2.3f, 1.0f);
indicators_[0]->rootNode_->SetPosition(CoordsToPosition(first) * Vector3(0.0f, 1.0f, 1.0f));
indicators_[0]->model1_->SetMorphWeight(1, static_cast<float>(first.y_ > 0 && first.y_ < 3));
indicators_[0]->model2_->SetMorphWeight(1, static_cast<float>(first.y_ > 0 && first.y_ < 3));
//Indicate column
} else if (first.x_ == last.x_){
FX->FadeTo(indicators_[1]->glow_, COLOR_GLOW, 2.3f, 1.0f);
indicators_[1]->rootNode_->SetPosition(CoordsToPosition(first) * Vector3(1.0f, 1.0f, 0.0f));
indicators_[1]->model1_->SetMorphWeight(1, static_cast<float>(first.x_ > 0 && first.x_ < 3));
indicators_[1]->model2_->SetMorphWeight(1, static_cast<float>(first.x_ > 0 && first.x_ < 3));
//Indicate first diagonal
} else if (first.x_ == 0 && last.y_ == 0){
FX->FadeTo(indicators_[3]->glow_, COLOR_GLOW, 2.3f, 1.0f);
......
......@@ -57,6 +57,7 @@ void InputMaster::ConstructYad()
yad_->model_->SetMaterial(yad_->material_);
yad_->light_ = lightNode->CreateComponent<Light>();
yad_->light_->SetLightType(LIGHT_POINT);
yad_->light_->SetCastShadows(true);
yad_->light_->SetColor(COLOR_GLOW);
yad_->light_->SetRange(1.0f);
yad_->light_->SetBrightness(YAD_FULLBRIGHT);
......@@ -85,13 +86,16 @@ void InputMaster::HandleUpdate(StringHash eventType, VariantMap &eventData)
void InputMaster::UpdateYad()
{
Vector3 yadPos{YadRaycast()};
bool hide{false};
Vector3 yadPos{YadRaycast(hide)};
if (yadPos.Length())
yad_->node_->SetPosition(Vector3(0.5f * (yadPos.x_ + yad_->node_->GetPosition().x_),
yadPos.y_,
0.5f * (yadPos.z_ + yad_->node_->GetPosition().z_)));
if (!yad_->hidden_
&& mouseIdleTime_ > IDLE_THRESHOLD * 0.5f ){
&& (mouseIdleTime_ > IDLE_THRESHOLD * 0.5f
|| hide))
{
HideYad();
}
}
......@@ -106,7 +110,7 @@ void InputMaster::RevealYad()
yad_->hidden_ = false;
RestoreYad();
}
Vector3 InputMaster::YadRaycast()
Vector3 InputMaster::YadRaycast(bool& none)
{
Ray cameraRay{MouseRay()};
......@@ -135,7 +139,6 @@ Vector3 InputMaster::YadRaycast()
}
}
Vector3 pos{yad_->node_->GetPosition()};
for (RayQueryResult r : results){
if (MC->InPickState()){
MC->DeselectPiece();
......@@ -147,6 +150,8 @@ Vector3 InputMaster::YadRaycast()
RevealYad();
return r.position_;
}
none = true;
return Vector3::ZERO;
}
void InputMaster::DimYad()
{
......@@ -185,7 +190,7 @@ void InputMaster::HandleKeyDown(StringHash eventType, VariantMap &eventData)
pressedKeys_.Insert(key);
switch (key){
case KEY_ESC:{
case KEY_ESCAPE:{
if (!BOARD->IsEmpty()
|| MC->GetSelectedPiece()
|| MC->GetPickedPiece())
......
......@@ -90,7 +90,7 @@ private:
void HandleUpdate(StringHash eventType, VariantMap &eventData);
void UpdateMousePos(bool delta);
void UpdateYad();
Vector3 YadRaycast();
Vector3 YadRaycast(bool& none);
void HandleKeyDown(StringHash eventType, VariantMap &eventData);
void HandleKeyUp(StringHash eventType, VariantMap &eventData);
......
......@@ -123,7 +123,7 @@ void MasterControl::CreateScene()
tableModel->SetCastShadows(true);
Node* hitNode{world_.scene_->CreateChild("HitPlane")};
hitNode->SetPosition(Vector3::DOWN * 1.23f);
hitNode->SetScale(42.0f);
hitNode->SetScale(128.0f);
StaticModel* hitPlane{hitNode->CreateComponent<StaticModel>()};
hitPlane->SetModel(MC->GetModel("Plane"));
hitPlane->SetMaterial(MC->GetMaterial("Invisible"));
......
......@@ -66,7 +66,8 @@ void Piece::Reset()
MC->AttributesToPosition(ToInt()),
Quaternion(Random(360.0f), Vector3::UP),
attributes_[0] ? 2.0f : 1.3f + attributes_[1] ? 0.5f : 1.0f + Random(0.23f),
RESET_DURATION, Random(0.42f) + 0.23f * (ToInt()/NUM_PIECES));
RESET_DURATION,
Random(0.42f) + 0.23f * (ToInt()/NUM_PIECES));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment