Commit 65da7f1f authored by redsuncore's avatar redsuncore

Deployment Activate

유닛 배치 가능.
PseudoFSM에 Deploy state추가
현재 Deploy가능한 지역은 파란색(move랑 동일한 색)으로 반짝임.
UIManager 싱글톤 추가
parent badfc72c
...@@ -96,7 +96,15 @@ public class GameManager : MonoBehaviour { ...@@ -96,7 +96,15 @@ public class GameManager : MonoBehaviour {
Move(tile.point); Move(tile.point);
} }
} }
if (PseudoFSM.I.DepState)
{
if (tile.isFlickering)
{
Deploy(tile.point, PseudoFSM.I.Deployment);
}
else
PseudoFSM.I.NormalStateEnter();
}
Unit unit = tile.point.Unit; Unit unit = tile.point.Unit;
if (unit != null) if (unit != null)
{ {
...@@ -276,12 +284,33 @@ public class GameManager : MonoBehaviour { ...@@ -276,12 +284,33 @@ public class GameManager : MonoBehaviour {
_selectedActor.MoveAct.Act(point); _selectedActor.MoveAct.Act(point);
PseudoFSM.I.NormalStateEnter(); PseudoFSM.I.NormalStateEnter();
} }
void Deploy(CivModel.Terrain.Point point, Production dep)
{
dep.Place(point);
PseudoFSM.I.NormalStateEnter();
}
} }
public static class ProductionFactoryTraits public static class ProductionFactoryTraits
{ {
public static string GetFactoryName(CivModel.IProductionFactory Factory) public static string GetFactoryName(CivModel.IProductionFactory Factory)
{ {
return Factory.ToString(); char[] sep = { '.' };
string name = Factory.ToString().Split(sep)[2];
string result;
switch(name)
{
case "PioneerProductionFactory":
result = "개척자";
break;
case "JediKnightProductionFactory":
result = "제다이 기사";
break;
default:
result = "unknown : " + name;
break;
}
return result;
} }
} }
\ No newline at end of file
...@@ -85,6 +85,8 @@ public class HexTile : MonoBehaviour { ...@@ -85,6 +85,8 @@ public class HexTile : MonoBehaviour {
Debug.Log(gameObject.name + " stopped flickering"); Debug.Log(gameObject.name + " stopped flickering");
if (terrains.GetChild((int)point.Type).GetComponent<Renderer>() == null) if (terrains.GetChild((int)point.Type).GetComponent<Renderer>() == null)
return; return;
if (_coroutine == null)
return;
StopCoroutine(_coroutine); StopCoroutine(_coroutine);
Material mat = terrains.GetChild((int)point.Type).GetComponent<Renderer>().material; Material mat = terrains.GetChild((int)point.Type).GetComponent<Renderer>().material;
mat.SetColor("_Color", Color.white); mat.SetColor("_Color", Color.white);
......
...@@ -109,30 +109,8 @@ public class DepPrefab : MonoBehaviour { ...@@ -109,30 +109,8 @@ public class DepPrefab : MonoBehaviour {
{ {
if (dep.Completed) if (dep.Completed)
{ {
CivModel.Terrain terrain = GameManager.I.Game.Terrain; PseudoFSM.I.DepStateEnter(dep);
for (int i = 0; i < terrain.Width; i++) UIManager.I.MapUIActive();
{
for (int j = 0; j < terrain.Height; j++)
{
CivModel.Terrain.Point point = terrain.GetPoint(i, j);
if(dep.IsPlacable(point))
{
GameManager.I.Cells[point.Position.X, point.Position.Y].GetComponent<HexTile>().FlickerBlue();
}
}
}
for (int i = 0; i < terrain.Width; i++)
{
for (int j = 0; j < terrain.Height; j++)
{
CivModel.Terrain.Point point = terrain.GetPoint(i, j);
if (dep.IsPlacable(point))
{
GameManager.I.Cells[point.Position.X, point.Position.Y].GetComponent<HexTile>().StopFlickering();
}
}
}
} }
else else
{ {
......
...@@ -15,7 +15,11 @@ public class PseudoFSM : MonoBehaviour { ...@@ -15,7 +15,11 @@ public class PseudoFSM : MonoBehaviour {
public bool AttackState { get { return _inAttackState; } } public bool AttackState { get { return _inAttackState; } }
private bool _inSkillState = false; private bool _inSkillState = false;
public bool SkillState { get { return _inSkillState; } } public bool SkillState { get { return _inSkillState; } }
private bool _inDepState = false;
public bool DepState { get { return _inDepState; } }
private int _currentSkill = -1; private int _currentSkill = -1;
private Production _deployment;
public Production Deployment { get { return _deployment; } }
private CivModel.Terrain.Point?[] _parameterPoints; private CivModel.Terrain.Point?[] _parameterPoints;
...@@ -47,6 +51,7 @@ public class PseudoFSM : MonoBehaviour { ...@@ -47,6 +51,7 @@ public class PseudoFSM : MonoBehaviour {
if (_inMoveState) MoveStateExit(); if (_inMoveState) MoveStateExit();
if (_inAttackState) AttackStateExit(); if (_inAttackState) AttackStateExit();
if (_inSkillState) SkillStateExit(); if (_inSkillState) SkillStateExit();
if (_inDepState) DepStateExit();
} }
// When move state, coloring movable adjacent tiles // When move state, coloring movable adjacent tiles
...@@ -57,6 +62,7 @@ public class PseudoFSM : MonoBehaviour { ...@@ -57,6 +62,7 @@ public class PseudoFSM : MonoBehaviour {
if (_inMoveState) return; if (_inMoveState) return;
if (_inAttackState) AttackStateExit(); if (_inAttackState) AttackStateExit();
if (_inSkillState) SkillStateExit(); if (_inSkillState) SkillStateExit();
if (_inDepState) DepStateExit();
_inMoveState = true; _inMoveState = true;
// Select movable adjacent tiles // Select movable adjacent tiles
...@@ -94,8 +100,11 @@ public class PseudoFSM : MonoBehaviour { ...@@ -94,8 +100,11 @@ public class PseudoFSM : MonoBehaviour {
if (_inAttackState) return; if (_inAttackState) return;
if (_inMoveState) MoveStateExit(); if (_inMoveState) MoveStateExit();
if (_inSkillState) SkillStateExit(); if (_inSkillState) SkillStateExit();
if (_inDepState) DepStateExit();
_inAttackState = true; _inAttackState = true;
if (GameManager.I.SelectedActor == null)
return;
// If GameManager.I.SelectedActor cannot attack // If GameManager.I.SelectedActor cannot attack
if (GameManager.I.SelectedActor.MovingAttackAct == null) if (GameManager.I.SelectedActor.MovingAttackAct == null)
return; return;
...@@ -135,6 +144,7 @@ public class PseudoFSM : MonoBehaviour { ...@@ -135,6 +144,7 @@ public class PseudoFSM : MonoBehaviour {
if (_inSkillState && _currentSkill == index) return; if (_inSkillState && _currentSkill == index) return;
if (_inMoveState) MoveStateExit(); if (_inMoveState) MoveStateExit();
if (_inAttackState) AttackStateExit(); if (_inAttackState) AttackStateExit();
if (_inDepState) DepStateExit();
_inSkillState = true; _inSkillState = true;
_currentSkill = index; _currentSkill = index;
...@@ -187,8 +197,41 @@ public class PseudoFSM : MonoBehaviour { ...@@ -187,8 +197,41 @@ public class PseudoFSM : MonoBehaviour {
} }
} }
} }
public bool CheckNormalState() public void DepStateEnter(Production dep)
{ {
return !(_inMoveState || _inAttackState || _inSkillState); // State change
if (dep == null || _inDepState) return;
if (_inMoveState) MoveStateExit();
if (_inAttackState) AttackStateExit();
if (_inSkillState) SkillStateExit();
_inDepState = true;
_deployment = dep;
// Select deploy tile
CivModel.Terrain terrain = GameManager.I.Game.Terrain;
for (int i = 0; i < terrain.Width; i++)
{
for (int j = 0; j < terrain.Height; j++)
{
CivModel.Terrain.Point point = terrain.GetPoint(i, j);
if (dep.IsPlacable(point))
{
GameManager.I.Cells[point.Position.X, point.Position.Y].GetComponent<HexTile>().FlickerBlue();
}
}
}
}
void DepStateExit()
{
_inDepState = false;
_deployment = null;
CivModel.Terrain terrain = GameManager.I.Game.Terrain;
for (int i = 0; i < terrain.Width; i++)
{
for (int j = 0; j < terrain.Height; j++)
{
CivModel.Terrain.Point point = terrain.GetPoint(i, j);
GameManager.I.Cells[point.Position.X, point.Position.Y].GetComponent<HexTile>().StopFlickering();
}
}
} }
} }
...@@ -29,7 +29,23 @@ public class UIManager : MonoBehaviour { ...@@ -29,7 +29,23 @@ public class UIManager : MonoBehaviour {
public GameObject CityTab, CityBuildingTab, NormalBuildingTab; // Building production public GameObject CityTab, CityBuildingTab, NormalBuildingTab; // Building production
private ManagementUIController uicontroller; private ManagementUIController uicontroller;
private static UIManager _uimanager;
public static UIManager I { get { return _uimanager; } }
void Awake()
{
// Singleton
if (_uimanager != null)
{
Destroy(this);
return;
}
else
{
_uimanager = this;
}
// Use this when scene changing exists
// DontDestroyOnLoad(gameObject);
}
void Start() void Start()
{ {
uicontroller = ManagementUIController.GetManagementUIController(); uicontroller = ManagementUIController.GetManagementUIController();
......
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