Commit a370fe31 authored by 16도재형's avatar 16도재형

Unit moving available

parent 8ff54c16
......@@ -62,6 +62,21 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!1 &1247625737478276
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4747943670451590}
m_Layer: 0
m_Name: Ocean
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!1 &1333826791649270
GameObject:
m_ObjectHideFlags: 0
......@@ -95,6 +110,51 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!1 &1514589081352494
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4157427397233106}
m_Layer: 0
m_Name: Forest
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!1 &1535947348689886
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4312907416615170}
m_Layer: 0
m_Name: Ice
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!1 &1679681735439964
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4752134810276488}
m_Layer: 0
m_Name: Plain
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!1 &1823159130722898
GameObject:
m_ObjectHideFlags: 0
......@@ -132,6 +192,36 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!1 &1938409798695032
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4567653727305688}
m_Layer: 0
m_Name: Tundra
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!1 &1987814173296546
GameObject:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4690190399569276}
m_Layer: 0
m_Name: Swamp
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &4094104317531802
Transform:
m_ObjectHideFlags: 1
......@@ -145,6 +235,19 @@ Transform:
m_Father: {fileID: 4436999106154904}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4157427397233106
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1514589081352494}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4297799600058746}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4245987888127746
Transform:
m_ObjectHideFlags: 1
......@@ -168,11 +271,30 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4985084088936646}
- {fileID: 4752134810276488}
- {fileID: 4747943670451590}
- {fileID: 4648394291209932}
- {fileID: 4157427397233106}
- {fileID: 4690190399569276}
- {fileID: 4567653727305688}
- {fileID: 4312907416615170}
- {fileID: 4985084088936646}
m_Father: {fileID: 4624084589808502}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4312907416615170
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1535947348689886}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4297799600058746}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4436999106154904
Transform:
m_ObjectHideFlags: 1
......@@ -188,6 +310,19 @@ Transform:
m_Father: {fileID: 4624084589808502}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4567653727305688
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1938409798695032}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4297799600058746}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4624084589808502
Transform:
m_ObjectHideFlags: 1
......@@ -214,8 +349,47 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4297799600058746}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4690190399569276
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1987814173296546}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4297799600058746}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4747943670451590
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1247625737478276}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4297799600058746}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4752134810276488
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1679681735439964}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4297799600058746}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4985084088936646
Transform:
m_ObjectHideFlags: 1
......@@ -227,7 +401,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4297799600058746}
m_RootOrder: 0
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &23070297376802330
MeshRenderer:
......@@ -511,3 +685,4 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 784c3f2942f405c47bd30667f0395f5a, type: 3}
m_Name:
m_EditorClassIdentifier:
isFlickering: 0
......@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44657844, g: 0.49641222, b: 0.57481694, a: 1}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
......@@ -14237,13 +14237,13 @@ MonoBehaviour:
m_EditorClassIdentifier:
mainCamera: {fileID: 1006940699}
cameraMoveSpeed: 3
isMoveState: 0
isAttackState: 0
isSkillState: 0
IsThereTodos: 0
outerRadius: 1
innerRadius: 0
cellPrefab: {fileID: 1823159130722898, guid: ef12b8f6d512e104b979d4a75f3e60c0, type: 2}
IsThereTodos: 0
onMoveState: 0
onAttackState: 0
onSkillState: 0
--- !u!4 &1056054509
Transform:
m_ObjectHideFlags: 0
......@@ -27542,7 +27542,18 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 2060510816}
m_OnClick:
m_PersistentCalls:
m_Calls: []
m_Calls:
- m_Target: {fileID: 1056054510}
m_MethodName: MoveActive
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 &2060510816
......
......@@ -19,27 +19,30 @@ public class GameManager : MonoBehaviour {
float cameraMoveSpeed;
enum CameraMoveDirection { Up, Down, Left, Right }
// For drawing hex tile
public float outerRadius = 1f; // Outer&inner radius of hex tile.
public float innerRadius; // These variables can be deleted if there are no use.
// Hex tile cells
public GameObject cellPrefab;
private GameObject[,] _cells;
// Current game
private CivModel.Game _game;
// Selected actor
private CivModel.Unit _selectedActor = null;
// For unit order
public bool isMoveState = false;
public bool isAttackState = false;
public bool isSkillState = false;
// Variables from Presenter.cs
public bool IsThereTodos;
private CivModel.Unit[] _standbyUnits;
private int _standbyUnitIndex = -1;
public float outerRadius = 1f; // Outer&inner radius of hex tile.
public float innerRadius; // These variables can be deleted if there are no use.
// For pseudo-FSM
public bool onMoveState = false;
public bool onAttackState = false;
public bool onSkillState = false;
// Hex tile cells
public GameObject cellPrefab;
private GameObject[,] _cells;
private CivModel.Terrain.Point?[] _parameterPoints;
// Use this for initialization
void Start() {
......@@ -84,7 +87,17 @@ public class GameManager : MonoBehaviour {
if (Physics.Raycast(ray, out hit))
{
Unit unit = hit.collider.gameObject.GetComponent<HexTile>().point.Unit;
HexTile tile = hit.collider.gameObject.GetComponent<HexTile>();
if (onMoveState)
{
if (tile.isFlickering)
{
Move(tile.point);
}
}
Unit unit = tile.point.Unit;
if (unit != null)
{
SelectUnit(unit);
......@@ -225,11 +238,11 @@ public class GameManager : MonoBehaviour {
}
// Method that gives "(x,y)" string with input of CivModel.Position or 2 ints
string Pos2Str(CivModel.Position pos)
public string Pos2Str(CivModel.Position pos)
{
return Pos2Str(pos.X, pos.Y);
}
string Pos2Str(int x, int y)
public string Pos2Str(int x, int y)
{
return "(" + x + "," + y + ")";
}
......@@ -253,4 +266,68 @@ public class GameManager : MonoBehaviour {
break;
}
}
// For state change of pseudo-FSM
// There are enter, exit methods for move and attack states. Enter methods are public, exit methods are default.
// NormalStateEnter() simply resets all state condition.
public void NormalStateEnter()
{
if (onMoveState) MoveStateExit();
if (onAttackState) AttackStateExit();
if (onSkillState) SkillStateExit();
}
// When move state, coloring movable adjacent tiles
// Current MoveStateEnter() shows only adjacent tiles. If moving mechanism of model changes, this should be changed.
public void MoveStateEnter()
{
// State change
if (onAttackState) AttackStateExit();
if (onSkillState) SkillStateExit();
onMoveState = true;
// Select movable adjacent tiles
_parameterPoints = _selectedActor.PlacedPoint.Value.Adjacents();
for (int i = 0; i < _parameterPoints.Length; i++)
{
if (_selectedActor.MoveAct.IsActable(_parameterPoints[i]))
{
CivModel.Position pos = _parameterPoints[i].Value.Position;
_cells[pos.X, pos.Y].GetComponent<HexTile>().FlickerBlue();
}
}
}
void MoveStateExit()
{
for (int i = 0; i < _parameterPoints.Length; i++)
{
if (_parameterPoints != null)
{
CivModel.Position pos = _parameterPoints[i].Value.Position;
_cells[pos.X, pos.Y].GetComponent<HexTile>().StopFlickering();
}
}
_parameterPoints = null;
onMoveState = false;
// TODO
}
void AttackStateExit()
{
onAttackState = false;
// TODO
}
void SkillStateExit()
{
onSkillState = false;
// TODO
}
// Move _selectedActor
void Move(CivModel.Terrain.Point point)
{
_selectedActor.MoveAct.Act(point);
NormalStateEnter();
}
}
......@@ -11,6 +11,8 @@ public class HexTile : MonoBehaviour {
Transform terrains;
Transform units;
public bool isFlickering;
// Use this for initialization
void Start () {
terrains = transform.GetChild(0).transform;
......@@ -25,14 +27,7 @@ public class HexTile : MonoBehaviour {
// Render tile terrain
public void ChangeTile()
{
if (point.Type == CivModel.TerrainType.Hill)
{
terrains.Find("Hill").gameObject.SetActive(true);
}
else if (point.Type == CivModel.TerrainType.Mount)
{
terrains.Find("Mount").gameObject.SetActive(true);
}
terrains.GetChild((int)point.Type).gameObject.SetActive(true);
}
// This method should be changed when unit type increses
......@@ -60,4 +55,24 @@ public class HexTile : MonoBehaviour {
}
}
}
// Flicker with blue color. This is used for parametered move and skill.
public void FlickerBlue()
{
isFlickering = true;
Debug.Log(GameManager.I.Pos2Str(point.Position) + " 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");
}
public void StopFlickering()
{
isFlickering = false;
Debug.Log(GameManager.I.Pos2Str(point.Position) + " stopped flickering");
}
}
......@@ -49,12 +49,14 @@ public class UIManager : MonoBehaviour {
}
public void ManagementUIActive() // Management UI tab
{
SkillSet.SetActive(false);
ManagementUI.SetActive(true);
MapUI.SetActive(false);
QuestUI.SetActive(false);
}
public void QuestUIActive() // Quest UI tab
{
SkillSet.SetActive(false);
QuestUI.SetActive(true);
MapUI.SetActive(false);
ManagementUI.SetActive(false);
......@@ -121,10 +123,13 @@ public class UIManager : MonoBehaviour {
//// Map UI ////
public void MoveActive()
{
SkillSet.SetActive(false);
GameManager.I.MoveStateEnter();
}
public void AttackActive()
{
SkillSet.SetActive(false);
}
......@@ -134,10 +139,15 @@ public class UIManager : MonoBehaviour {
}
public void EndTurnActive()
{
SkillSet.SetActive(false);
if (GameManager.I.IsThereTodos)
{
GameManager.I.SelectNextUnit();
}
else
{
}
}
//// Management UI (Production Selection) ////
......
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