Commit 796b7017 authored by 16도재형's avatar 16도재형

Skill 1 available (#7): have to fix SelectNextUnit bug

parent 5d1b1fb4
......@@ -14241,7 +14241,7 @@ MonoBehaviour:
outerRadius: 1
innerRadius: 0
cellPrefab: {fileID: 1823159130722898, guid: ef12b8f6d512e104b979d4a75f3e60c0, type: 2}
IsThereTodos: 0
isThereTodos: 0
onMoveState: 0
onAttackState: 0
onSkillState: 0
......@@ -23352,12 +23352,12 @@ MonoBehaviour:
callback:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1056054507}
m_MethodName:
- m_Target: {fileID: 1056054510}
m_MethodName: Skill1Active
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName:
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
......@@ -27951,7 +27951,18 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 2085815513}
m_OnClick:
m_PersistentCalls:
m_Calls: []
m_Calls:
- m_Target: {fileID: 1056054510}
m_MethodName: AttackActive
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!114 &2085815513
......
......@@ -43,6 +43,7 @@ public class GameManager : MonoBehaviour {
public bool onMoveState = false;
public bool onAttackState = false;
public bool onSkillState = false;
private int _currentSkill = -1;
private CivModel.Terrain.Point?[] _parameterPoints;
......@@ -129,16 +130,6 @@ public class GameManager : MonoBehaviour {
CameraZoom();
}
// Method that gives "(x,y)" string with input of CivModel.Position or 2 ints
public string Pos2Str(CivModel.Position pos)
{
return Pos2Str(pos.X, pos.Y);
}
public string Pos2Str(int x, int y)
{
return "(" + x + "," + y + ")";
}
// Instantiate hex tiles
void DrawMap()
{
......@@ -154,7 +145,7 @@ public class GameManager : MonoBehaviour {
pos.x -= innerRadius;
}
_cells[i, j] = Instantiate(cellPrefab, pos, Quaternion.identity);
_cells[i, j].name = Pos2Str(i, j);
_cells[i, j].name = String.Format("({0},{1})", i, j);
_cells[i, j].GetComponent<HexTile>().point = _game.Terrain.GetPoint(i, j);
}
}
......@@ -236,7 +227,7 @@ public class GameManager : MonoBehaviour {
}
void Focus(CivModel.Unit unit)
{
if (unit == null)
if (unit.PlacedPoint == null)
{
return;
}
......@@ -244,7 +235,7 @@ public class GameManager : MonoBehaviour {
}
void Focus(CivModel.Terrain.Point point)
{
GameObject tile = GameObject.Find(Pos2Str(point.Position));
GameObject tile = _cells[point.Position.X, point.Position.Y];
Vector3 tilePos = tile.transform.position;
float x = tilePos.x;
float z = tilePos.z - (6.75f / Mathf.Tan(40 * Mathf.Deg2Rad));
......@@ -354,10 +345,63 @@ public class GameManager : MonoBehaviour {
_parameterPoints = null;
}
public void SkillStateEnter(int index)
{
// State change
if (onSkillState && _currentSkill == index) return;
if (onMoveState) MoveStateExit();
if (onAttackState) AttackStateExit();
onSkillState = true;
_currentSkill = index;
// If SpecialActs[_currentSkill] is not parametered skill, this skill is immediately activated.
if (!_selectedActor.SpecialActs[_currentSkill].IsParametered)
{
_selectedActor.SpecialActs[_currentSkill].Act(null);
SkillStateExit();
return;
}
else
{
for (int i = 0; i < GameInfo.mapWidth; i++)
{
for (int j = 0; j < GameInfo.mapHeight; j++)
{
CivModel.Terrain.Point? point = _game.Terrain.GetPoint(i, j);
if (_selectedActor.SpecialActs[_currentSkill].IsActable(point))
{
CivModel.Position pos = point.Value.Position;
_cells[pos.X, pos.Y].GetComponent<HexTile>().FlickerBlue();
}
}
}
}
}
void SkillStateExit()
{
int index = _currentSkill;
onSkillState = false;
// TODO
_currentSkill = -1;
if (!_selectedActor.SpecialActs[index].IsParametered)
{
return;
}
else
{
for (int i = 0; i < GameInfo.mapWidth; i++)
{
for (int j = 0; j < GameInfo.mapHeight; j++)
{
CivModel.Terrain.Point? point = _game.Terrain.GetPoint(i, j);
if (_selectedActor.SpecialActs[index].IsActable(point))
{
CivModel.Position pos = point.Value.Position;
_cells[pos.X, pos.Y].GetComponent<HexTile>().StopFlickering();
}
}
}
}
}
// Move _selectedActor
......
......@@ -60,19 +60,19 @@ public class HexTile : MonoBehaviour {
public void FlickerBlue()
{
isFlickering = true;
Debug.Log(GameManager.I.Pos2Str(point.Position) + " is flickering with blue");
Debug.Log(gameObject.name + " is flickering with blue");
}
// Blink with red color. This is used for attack.
public void FlickerRed()
{
isFlickering = true;
Debug.Log(GameManager.I.Pos2Str(point.Position) + " is flickering with red");
Debug.Log(gameObject.name + " is flickering with red");
}
public void StopFlickering()
{
isFlickering = false;
Debug.Log(GameManager.I.Pos2Str(point.Position) + " stopped flickering");
Debug.Log(gameObject.name + " stopped flickering");
}
}
......@@ -70,7 +70,30 @@ public class UIManager : MonoBehaviour {
{
SpecialSpec.SetActive(false);
}
/*
//// Map UI ////
public void MoveActive()
{
SkillSet.SetActive(false);
GameManager.I.MoveStateEnter();
}
public void AttackActive()
{
SkillSet.SetActive(false);
GameManager.I.AttackStateEnter();
}
public void SkillSetActive()
{
SkillSet.SetActive(!SkillSet.activeSelf);
}
public void Skill1Active()
{
GameManager.I.SkillStateEnter(0);
}
/*
public void SkillSpec1MouseOver() // 특수 명령
{
SkillSpec1.SetActive(true);
......@@ -119,24 +142,7 @@ public class UIManager : MonoBehaviour {
{
SkillSpec6.SetActive(false);
}
*/
//// Map UI ////
public void MoveActive()
{
SkillSet.SetActive(false);
GameManager.I.MoveStateEnter();
}
public void AttackActive()
{
SkillSet.SetActive(false);
GameManager.I.AttackStateEnter();
}
public void SkillSetActive()
{
SkillSet.SetActive(!SkillSet.activeSelf);
}
*/
public void EndTurnActive()
{
SkillSet.SetActive(false);
......
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