Commit 0d91b115 authored by 16도재형's avatar 16도재형

Movable/Atackable tile really flickers!

parent 796b7017
......@@ -18524,7 +18524,18 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 1365235311}
m_OnClick:
m_PersistentCalls:
m_Calls: []
m_Calls:
- m_Target: {fileID: 1056054510}
m_MethodName: EndTurnActive
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 &1365235311
......
......@@ -65,7 +65,6 @@ public class GameManager : MonoBehaviour {
// Instantiate game
_game = new CivModel.Game( GameInfo.mapWidth, GameInfo.mapHeight, GameInfo.numOfPlayer, new CivModel.Common.GameSchemeFactory());
_game.StartTurn();
Debug.Log(_game.PlayerNumberInTurn);
// Map tiling
innerRadius = outerRadius * Mathf.Sqrt(3.0f) / 2;
......@@ -182,7 +181,7 @@ public class GameManager : MonoBehaviour {
}
int idx = _standbyUnitIndex + 1;
Debug.Log(_standbyUnits);
Debug.Log(_standbyUnits.Length);
for (; idx < _standbyUnits.Length; ++idx)
{
var unit = _standbyUnits[idx];
......
......@@ -12,6 +12,7 @@ public class HexTile : MonoBehaviour {
Transform units;
public bool isFlickering;
private IEnumerator _coroutine;
// Use this for initialization
void Start () {
......@@ -61,6 +62,10 @@ public class HexTile : MonoBehaviour {
{
isFlickering = true;
Debug.Log(gameObject.name + " is flickering with blue");
if (terrains.GetChild((int)point.Type).GetComponent<Renderer>() == null)
return;
_coroutine = Flicker(Color.blue);
StartCoroutine(_coroutine);
}
// Blink with red color. This is used for attack.
......@@ -68,11 +73,51 @@ public class HexTile : MonoBehaviour {
{
isFlickering = true;
Debug.Log(gameObject.name + " is flickering with red");
if (terrains.GetChild((int)point.Type).GetComponent<Renderer>() == null)
return;
_coroutine = Flicker(Color.red);
StartCoroutine(_coroutine);
}
public void StopFlickering()
{
isFlickering = false;
Debug.Log(gameObject.name + " stopped flickering");
if (terrains.GetChild((int)point.Type).GetComponent<Renderer>() == null)
return;
StopCoroutine(_coroutine);
Material mat = terrains.GetChild((int)point.Type).GetComponent<Renderer>().material;
mat.SetColor("_Color", Color.white);
}
// Make tile flicker with color c. Don't need to read this method.
IEnumerator Flicker(Color c)
{
Material mat = terrains.GetChild((int)point.Type).GetComponent<Renderer>().material;
Color delta = Color.white - c;
while(true)
{
// From white to c
for (float i = 0; i <= 1f; i += 1.5f * Time.deltaTime)
{
mat.SetColor("_Color", Color.white - delta * (1 - Mathf.Cos(Mathf.PI * i)) / 2);
yield return null;
}
mat.SetColor("_Color", c);
// From c to white
for (float i = 0; i <= 1f; i += 1.5f * Time.deltaTime)
{
mat.SetColor("_Color", c + delta * (1 - Mathf.Cos(Mathf.PI * i)) / 2);
yield return null;
}
mat.SetColor("_Color", Color.white);
if (!isFlickering)
{
break;
}
yield return new WaitForSeconds(0.2f);
}
}
}
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