Commit a19dde53 authored by Seungwon Ju's avatar Seungwon Ju

Deployment Completedgit add -A

parent def92683
[Ll]ibrary/
[Tt]emp/
[Oo]bj/
[Bb]uild/
[Bb]uilds/
Assets/AssetStoreTools*
# Visual Studio 2015 cache directory
/.vs/
# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
# Unity3D Generated File On Crash Reports
sysinfo.txt
# Builds
*.apk
*.unitypackage
# MacOS
.DS_Store
This diff is collapsed.
......@@ -1148,7 +1148,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 1841507268}
m_HandleRect: {fileID: 1841507267}
m_Direction: 2
m_Value: 0.99998355
m_Value: 0.9999992
m_Size: 0.87019
m_NumberOfSteps: 0
m_OnValueChanged:
......@@ -2547,7 +2547,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0.000030517578, y: -0.00004841719}
m_AnchoredPosition: {x: 0.000030517578, y: -0.0000026408234}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 1}
--- !u!114 &191355288
......@@ -5088,7 +5088,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -0.000053677646, y: -0.00003277704}
m_AnchoredPosition: {x: -0.000053677646, y: -0.0000148695635}
m_SizeDelta: {x: 0, y: 300}
m_Pivot: {x: 0, y: 1}
--- !u!1 &454209707
......@@ -6493,8 +6493,8 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 733846993}
m_HandleRect: {fileID: 733846992}
m_Direction: 2
m_Value: 1
m_Size: 0.9999999
m_Value: 0
m_Size: 0.9999998
m_NumberOfSteps: 0
m_OnValueChanged:
m_PersistentCalls:
......@@ -9689,7 +9689,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0.000036194124, y: -0.00003277704}
m_AnchoredPosition: {x: 0.000030258068, y: -0.0000148695635}
m_SizeDelta: {x: 0, y: 300}
m_Pivot: {x: 0, y: 1}
--- !u!1 &1001046761
......@@ -9794,7 +9794,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: -0.000015258789}
m_AnchoredPosition: {x: 0, y: -0.000030517578}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 1}
--- !u!114 &1004629748
......@@ -11763,7 +11763,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0.00006514437, y: -0.000010127624}
m_AnchoredPosition: {x: 0.00006514437, y: 0.000020389954}
m_SizeDelta: {x: 0, y: 300}
m_Pivot: {x: 0, y: 1}
--- !u!1 &1173066205
......@@ -13150,7 +13150,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: "\uAE30\uC2201"
m_Text: "\uD3EC\uACA9"
--- !u!222 &1321951785
CanvasRenderer:
m_ObjectHideFlags: 0
......@@ -14151,7 +14151,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -0.00001036023, y: 0.0005912781}
m_AnchoredPosition: {x: -0.00001036023, y: 0.000022888184}
m_SizeDelta: {x: 0, y: 300}
m_Pivot: {x: 0, y: 1}
--- !u!1 &1465630758
......
......@@ -5,6 +5,7 @@ using UnityEngine;
using CivModel;
using System.Threading.Tasks;
using System.IO;
using UnityEngine.EventSystems;
public class GameManager : MonoBehaviour {
......@@ -30,6 +31,16 @@ public class GameManager : MonoBehaviour {
private List<GameObject> _units = new List<GameObject>();
public List<GameObject> Units { get { return _units; } }
//Deploy를 위한 추가
private bool _inDepState = false;
public bool DepState { get { return _inDepState; } }
private Production _deployment;
public Production Deployment { get { return _deployment; } }
///Deploy를 위한 추가 끝
public Material[] materials;
public CivModel.Terrain.Point selectedPoint;
......@@ -298,5 +309,81 @@ public class GameManager : MonoBehaviour {
}
}
// Deploy 하는 부분
public void DepStateEnter(Production dep, DeployPrefab deployprefab)
{
// State change
if (dep == null || _inDepState) return;
_inDepState = true;
_deployment = dep;
// Select deploy tile
CivModel.Terrain terrain = Instance.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))
{
Instance.Tiles[point.Position.X, point.Position.Y].GetComponent<HexTile>().FlickerBlue();
}
}
}
CivModel.Terrain.Point StartPoint = Instance.selectedPoint;
IEnumerator _coroutine = DeployUnit(StartPoint, dep, deployprefab);
StartCoroutine(_coroutine);
}
IEnumerator DeployUnit(CivModel.Terrain.Point point, Production dep, DeployPrefab deployprefab)
{
while (true)
{
CivModel.Terrain.Point destPoint = Instance.selectedPoint;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (!EventSystem.current.IsPointerOverGameObject() && Input.GetMouseButtonDown(0))
{
// Flicker하고 있는 Tile을 선택했을 때
if (Instance.selectedTile.isFlickering)
{
if (dep.IsPlacable(destPoint))
{
Game.PlayerInTurn.Deployment.Remove(dep);
dep.Place(destPoint);
DepStateExit(deployprefab);
GameManager.Instance.UpdateUnit();
GameManager.Instance.UpdateMap();
break;
}
else
{
DepStateExit(deployprefab);
break;
}
}
DepStateExit(deployprefab);
break;
}
yield return null;
}
}
void DepStateExit(DeployPrefab deployprefab)
{
_inDepState = false;
_deployment = null;
CivModel.Terrain terrain = Instance.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);
Instance.Tiles[point.Position.X, point.Position.Y].GetComponent<HexTile>().StopFlickering();
}
}
GameManager.Instance.UpdateUnit();
GameManager.Instance.UpdateMap();
}
}
\ No newline at end of file
......@@ -125,10 +125,10 @@ public class DeployPrefab : MonoBehaviour
{
if (dep.IsCompleted)
{
gameManager.DepStateEnter(dep, this);
UIManager.Instance.mapUI.SetActive(true);
UIManager.Instance.managementUI.SetActive(false);
UIManager.Instance.questUI.SetActive(false);
DepStateEnter(dep);
}
else
{
......@@ -136,75 +136,4 @@ public class DeployPrefab : MonoBehaviour
throw new AccessViolationException();
}
}
public void DepStateEnter(Production dep)
{
// State change
if (dep == null || _inDepState) return;
_inDepState = true;
_deployment = dep;
// Select deploy tile
CivModel.Terrain terrain = GameManager.Instance.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.Instance.Tiles[point.Position.X, point.Position.Y].GetComponent<HexTile>().FlickerBlue();
}
}
IEnumerator _coroutine = DeployUnit(GameManager.Instance.selectedPoint, dep);
StartCoroutine(_coroutine);
}
}
IEnumerator DeployUnit(CivModel.Terrain.Point point, Production dep)
{
while (true)
{
CivModel.Terrain.Point destPoint = GameManager.Instance.selectedPoint;
// 새로운 Point 을 선택했을 때
if (point != destPoint)
{
// Flicker하고 있는 Tile을 선택했을 때
if (GameManager.Instance.selectedTile.isFlickering)
{
if (dep.IsPlacable(destPoint))
{
game.PlayerInTurn.Deployment.Remove(dep);
dep.Place(destPoint);
//여기에 유닛을 생성하는 걸 추가해야 함
GameManager.Instance.UpdateUnit();
break;
}
else
{
DepStateExit();
}
}
// Flicker 하지 않는 타일 선택
else
{
DepStateExit();
}
}
yield return null;
}
}
void DepStateExit()
{
_inDepState = false;
_deployment = null;
CivModel.Terrain terrain = GameManager.Instance.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.Instance.Tiles[point.Position.X, point.Position.Y].GetComponent<HexTile>().StopFlickering();
}
}
}
}
......@@ -459,7 +459,7 @@ public class ProductionFactoryTraits : MonoBehaviour {
result = "연구소";
break;
default:
result = "Unknown: " + name;
result = name;
break;
}
return result;
......@@ -480,7 +480,7 @@ public class ProductionFactoryTraits : MonoBehaviour {
result = "hwan_jedi";
else if (unit.Owner == GameManager.Instance.Game.Players[CivModel.Finno.FinnoPlayerConstant.FinnoPlayer])
result = "finno_jedi";
else result = "unknown : " + name;
else result = name;
}
break;
case "FakeKnight":
......@@ -495,7 +495,7 @@ public class ProductionFactoryTraits : MonoBehaviour {
result = "hwan_decentralized_soldier";
else if (unit.Owner == GameManager.Instance.Game.Players[CivModel.Finno.FinnoPlayerConstant.FinnoPlayer])
result = "finno_decentralized_soldier";
else result = "unknown : " + name;
else result = name;
}
break;
case "JackieChan":
......@@ -510,7 +510,7 @@ public class ProductionFactoryTraits : MonoBehaviour {
result = "hwan_ninja";
else if (unit.Owner == GameManager.Instance.Game.Players[CivModel.Finno.FinnoPlayerConstant.FinnoPlayer])
result = "finno_ninja";
else result = "unknown : " + name;
else result = name;
}
break;
case "UnicornOrder":
......@@ -522,7 +522,7 @@ public class ProductionFactoryTraits : MonoBehaviour {
result = "hwan_spy";
else if (unit.Owner == GameManager.Instance.Game.Players[CivModel.Finno.FinnoPlayerConstant.FinnoPlayer])
result = "finno_spy";
else result = "unknown : " + name;
else result = name;
}
break;
case "AncientSorcerer":
......@@ -553,7 +553,7 @@ public class ProductionFactoryTraits : MonoBehaviour {
result = "닌자";
break;
default:
result = "unknown : " + name;
result = name;
break;
}
return result;
......
......@@ -123,16 +123,21 @@ public class UIManager : MonoBehaviour
StartCoroutine(_tileCoroutine);
}
}
if (questUI.activeSelf == false && managementUI.activeSelf == false)
{
if (GameManager.Instance.selectedActor != null)
{
unitInfo.SetActive(true);
UnitPortrait.sprite = Resources.Load(("Portraits/" + (ProductionFactoryTraits.GetPortName(GameManager.Instance.selectedActor)).ToLower()), typeof(Sprite)) as Sprite;
if(GameManager.Instance.selectedActor is CivModel.Unit) {
if (GameManager.Instance.selectedActor is CivModel.Actor)
{
GameObject.Find("UnitName").GetComponent<Text>().text = ProductionFactoryTraits.GetName(GameManager.Instance.selectedActor);
} else if(GameManager.Instance.selectedActor is CivModel.CityBase) {
}
if (GameManager.Instance.selectedActor is CivModel.CityBase)
{
GameObject.Find("UnitName").GetComponent<Text>().text = GameManager.Instance.selectedActor.Name;
}
GameObject.Find("UnitAttack").GetComponent<Text>().text = GameManager.Instance.selectedActor.AttackPower.ToString();
GameObject.Find("UnitDefence").GetComponent<Text>().text = GameManager.Instance.selectedActor.DefencePower.ToString();
GameObject.Find("UnitEffect").GetComponent<Text>().text = GameManager.Instance.selectedActor.RemainHP.ToString() + "/" + GameManager.Instance.selectedActor.MaxHP;
......@@ -147,6 +152,7 @@ public class UIManager : MonoBehaviour
GameObject.Find("SpecialSpecText").GetComponent<Text>().text = specialText;
}
}
}
IEnumerator FlickerSelectedTile(HexTile prevTile)
{
......
......@@ -83,18 +83,19 @@ public class Unit : MonoBehaviour {
Debug.Log("Selected Actor is NULL");
return;
}
else if (GameManager.Instance.selectedActor is CivModel.Unit)
{
// Select movable adjacent tiles
_parameterPoints = GameManager.Instance.selectedActor.PlacedPoint.Value.Adjacents();
for (int i = 0; i < _parameterPoints.Length; i++)
{
if (GameManager.Instance.selectedActor.MovingAttackAct.IsActable(_parameterPoints[i]))
if (GameManager.Instance.selectedActor.MovingAttackAct != null && GameManager.Instance.selectedActor.MovingAttackAct.IsActable(_parameterPoints[i]))
{
CivModel.Position pos = _parameterPoints[i].Value.Position;
GameManager.Instance.Tiles[pos.X, pos.Y].GetComponent<HexTile>().FlickerRed();
}
else if (GameManager.Instance.selectedActor.MoveAct.IsActable(_parameterPoints[i]))
else if (GameManager.Instance.selectedActor.MoveAct != null && GameManager.Instance.selectedActor.MoveAct.IsActable(_parameterPoints[i]))
{
CivModel.Position pos = _parameterPoints[i].Value.Position;
GameManager.Instance.Tiles[pos.X, pos.Y].GetComponent<HexTile>().FlickerBlue();
......@@ -146,7 +147,7 @@ public class Unit : MonoBehaviour {
else
{
CivModel.Position pos = _parameterPoints[i].Value.Position;
Debug.Log("Cannot Attack to (" + pos.X + ", " + pos.Y + ")");
//Debug.Log("Cannot Attack to (" + pos.X + ", " + pos.Y + ")");
}
}
IEnumerator _coroutine = AttackUnit(GameManager.Instance.selectedActor);
......@@ -214,12 +215,17 @@ public class Unit : MonoBehaviour {
GameManager.Instance.UpdateUnit();
break;
}
else {
else if (unitToMove.MoveAct != null && unitToMove.MoveAct.IsActable(destPoint)){
unitToMove.MoveAct.Act(destPoint);
MoveStateExit();
GameManager.Instance.UpdateUnit();
break;
}
else {
Debug.Log("The Unit Cannot Move");
MoveStateExit();
break;
}
}
// Flicker 하지 않는 타일 선택
else {
......@@ -309,7 +315,6 @@ public class Unit : MonoBehaviour {
public void SkillStateExit(CivModel.Actor unitToSkill) {
foreach (CivModel.Terrain.Point pnt in _skillParameterPoints) {
Debug.Log(pnt);
CivModel.Position pos = pnt.Position;
GameManager.Instance.Tiles[pos.X, pos.Y].GetComponent<HexTile>().StopFlickering();
}
......
19;0;4;0;0
\ No newline at end of file
2;0;196608;0;0
\ No newline at end of file
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
using CivModel;
......@@ -32,29 +31,23 @@ public class GameUI : MonoBehaviour {
else
{
mapUI.transform.Find("EndTurn").GetComponentInChildren<Button>().enabled = true;
/* for testing only
foreach(CivModel.Unit x in GameManager.Instance.Game.PlayerInTurn.Units)
{
x.RemainAP = 0;
}
*/
if (!GameManager.Instance.Game.PlayerInTurn.Units.All(u => u.RemainAP == 0 || u.SkipFlag))
/*
if (GameManager.Instance.isThereTodos && !PseudoFSM.Instance.DepState)
{
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().text = "유닛이 명령을 기다리고 있습니다";
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().fontSize = 35;
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().fontSize = 30;
}
else if (GameManager.Instance.selectedActor != null)
else if (PseudoFSM.Instance.DepState)
{
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().text = "배치 취소";
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().fontSize = 40;
}
else
{
*/
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().text = "다음 턴";
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().fontSize = 40;
}
//}
updatePanel();
}
......
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using CivModel;
using CivModel.Common;
public class DeployPrefab : MonoBehaviour
{
public static GameObject DeployingObject;
private Text[] textarguments;
private Image unitPrt;
private Button[] buttons;
// Use this for initialization
private bool _inDepState = false;
public bool DepState { get { return _inDepState; } }
private Production _deployment;
public Production Deployment { get { return _deployment; } }
void Awake()
{
//Debug.Log("call DepPre");
textarguments = gameObject.GetComponentsInChildren<Text>();
foreach (Image unt in gameObject.GetComponentsInChildren<Image>())
{
if (unt.name == "Portrait")
{
unitPrt = unt;
}
}
buttons = gameObject.GetComponentsInChildren<Button>();
}
void Start()
{
}
public GameObject MakeItem(Production prod)
{
string nameofProduction = ProductionFactoryTraits.GetFactoryName(prod.Factory);
unitPrt.sprite = Resources.Load(("Portraits/" + (ProductionFactoryTraits.GetFacPortName(prod.Factory)).ToLower()), typeof(Sprite)) as Sprite;
foreach (Text txt in textarguments)
{
switch (txt.name)
{
case "UnitName":
txt.text = nameofProduction;
break;
case "NumberOfUnits":
txt.text = "X 1";
break;
}
}
return this.gameObject;
}
public GameObject MakeItem()
{
unitPrt.enabled = false;
foreach (Text txt in textarguments)
{
switch (txt.name)
{
case "UnitName":
txt.text = "비었음";
break;
case "NumberOfUnits":
txt.text = "";
break;
}
}
foreach (Button but in buttons)
{
but.gameObject.SetActive(false);
}
return this.gameObject;
}
// Update is called once per frame
void Update()
{
}
public void SetButton(int i)
{
if (i == -1)
{
foreach (Button but in buttons)
{
but.enabled = false;
}
}
else
{
LinkedListNode<Production> dep = GameManager.Instance.Game.PlayerInTurn.Deployment.First;
for (int k = 0; k < i; k++)
{
dep = dep.Next;
}
foreach (Button but in buttons)
{
switch (but.name)
{
case "Deploy":
but.onClick.AddListener(delegate () { DeployItem(dep.Value); DeployingObject = this.gameObject; });
break;
}
}
}
}
public void DeployItem(Production dep)
{
if (dep.IsCompleted)
{
DepStateEnter(dep);
UIManager.Instance.mapUI.SetActive(true);
UIManager.Instance.managementUI.SetActive(false);
UIManager.Instance.questUI.SetActive(false);
}
else
{
//Debug.Log("Error : not finished product");
throw new AccessViolationException();
}
}
public void DepStateEnter(Production dep)
{
// State change
if (dep == null || _inDepState) return;
_inDepState = true;
_deployment = dep;
// Select deploy tile
CivModel.Terrain terrain = GameManager.Instance.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.Instance.Tiles[point.Position.X, point.Position.Y].GetComponent<HexTile>().FlickerBlue();
}
}
IEnumerator _coroutine = DeployUnit(GameManager.Instance.selectedPoint, dep);
StartCoroutine(_coroutine);
}
}
IEnumerator DeployUnit(CivModel.Terrain.Point point, Production dep)
{
while (true)
{
CivModel.Terrain.Point destPoint = GameManager.Instance.selectedPoint;
// 새로운 Point 을 선택했을 때
if (point != destPoint)
{
// Flicker하고 있는 Tile을 선택했을 때
if (GameManager.Instance.selectedTile.isFlickering)
{
if (dep.IsPlacable(destPoint))
{
//여기에 유닛을 생성하는 걸 추가해야 함
GameManager.Instance.UpdateUnit();
break;
}
else
{
DepStateExit();
}
}
// Flicker 하지 않는 타일 선택
else
{
DepStateExit();
}
}
yield return null;
}
}
void DepStateExit()
{
_inDepState = false;
_deployment = null;
CivModel.Terrain terrain = GameManager.Instance.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.Instance.Tiles[point.Position.X, point.Position.Y].GetComponent<HexTile>().StopFlickering();
}
}
}
}
# ===========================
# Default Collab Ignore Rules
# ===========================
# OS Generated
# ============
.DS_Store
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
[Tt]humbs.db
[Dd]esktop.ini
# Visual Studio / MonoDevelop generated
# =====================================
[Ee]xported[Oo]bj/
*.userprefs
*.csproj
*.pidb
*.suo
*.sln
*.user
*.unityproj
*.booproj
# Unity generated
# ===============
[Oo]bj/
[Bb]uild
sysinfo.txt
*.stackdump
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using CivModel;
using System.Threading.Tasks;
public class GameUI : MonoBehaviour {
public GameObject mapUI;
public Text goldText, populationText, happinessText, researchText, laborText;
private UIController uicontroller;
private ManagementController managementcontroller;
// Use this for initialization
void Start () {
mapUI = GameObject.Find("MapUI");
uicontroller = UIController.GetUIController();
managementcontroller = ManagementController.GetManagementController();
}
// Update is called once per frame
void Update () {
if (GameManager.Instance.Game.PlayerInTurn.IsAIControlled)
{
mapUI.transform.Find("EndTurn").GetComponentInChildren<Button>().enabled = false;
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().text = "다른 플레이어가 턴 진행 중입니다. 기다려 주십시오.";
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().fontSize = Screen.height / 20;
}
else
{
mapUI.transform.Find("EndTurn").GetComponentInChildren<Button>().enabled = true;
if (GameManager.Instance.isThereTodos)
{
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().text = "유닛이 명령을 기다리고 있습니다";
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().fontSize = 30;
}
else
{
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().text = "다음 턴";
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().fontSize = 40;
}
updatePanel();
}
}
public void updatePanel()
{
double gold = GameManager.Instance.Game.PlayerInTurn.Gold;
double goldTurn = GameManager.Instance.Game.PlayerInTurn.GoldIncome;
goldText.text = "금: " + gold + "\n(턴당 " + goldTurn + ")";
double population = GameManager.Instance.Game.PlayerInTurn.Population;
populationText.text = "인구: " + population;
double happiness = GameManager.Instance.Game.PlayerInTurn.Happiness;
double happinessTurn = GameManager.Instance.Game.PlayerInTurn.HappinessIncome;
happinessText.text = "행복: " + happiness + "\n(턴당 " + happinessTurn + ")";
double research = GameManager.Instance.Game.PlayerInTurn.Research;
double researchTurn = GameManager.Instance.Game.PlayerInTurn.ResearchIncome;
researchText.text = "기술력: " + research + "\n(턴당 " + researchTurn + ")";
double labor = GameManager.Instance.Game.PlayerInTurn.Labor;
laborText.text = "노동력: " + labor;
}
public void updateQuest()
{
uicontroller.MakeQuestQueue();
}
public void updateManagement()
{
managementcontroller.begin();
}
public void onClickNextTurn()
{
if (GameManager.Instance.isThereTodos)
{
GameManager.Instance.FocusOnActableUnit();
}
else
{
// Debug.Log(Game.PlayerNumberInTurn);
if (GameManager.Instance.Game.PlayerInTurn == GameManager.Instance.Game.Players[0])
GameManager.Instance.Game.EndTurn();
GameManager.Instance.Game.StartTurn();
while (GameManager.Instance.Game.PlayerInTurn.IsAIControlled)
{
// Debug.Log(Game.PlayerNumberInTurn);
GameManager.Instance.Game.PlayerInTurn.DoAITurnAction().GetAwaiter().GetResult();
GameManager.Instance.Game.EndTurn();
GameManager.Instance.Game.StartTurn();
}
GameManager.Instance.UpdateMap();
GameManager.Instance.UpdateUnit();
UIManager.Instance.ButtonInteractChange();
}
}
}
\ No newline at end of file
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using CivModel;
using CivModel.Common;
public class DeployPrefab : MonoBehaviour
{
public static GameObject DeployingObject;
private Text[] textarguments;
private Image unitPrt;
private Button[] buttons;
private GameManager gameManager;
private Game game;
// Use this for initialization
private bool _inDepState = false;
public bool DepState { get { return _inDepState; } }
private Production _deployment;
public Production Deployment { get { return _deployment; } }
void Awake()
{
//Debug.Log("call DepPre");
textarguments = gameObject.GetComponentsInChildren<Text>();
foreach (Image unt in gameObject.GetComponentsInChildren<Image>())
{
if (unt.name == "Portrait")
{
unitPrt = unt;
}
}
buttons = gameObject.GetComponentsInChildren<Button>();
}
void Start()
{
gameManager = GameManager.Instance;
game = gameManager.Game;
}
public GameObject MakeItem(Production prod)
{
string nameofProduction = ProductionFactoryTraits.GetFactoryName(prod.Factory);
unitPrt.sprite = Resources.Load(("Portraits/" + (ProductionFactoryTraits.GetFacPortName(prod.Factory)).ToLower()), typeof(Sprite)) as Sprite;
foreach (Text txt in textarguments)
{
switch (txt.name)
{
case "UnitName":
txt.text = nameofProduction;
break;
case "NumberOfUnits":
txt.text = "X 1";
break;
}
}
return this.gameObject;
}
public GameObject MakeItem()
{
unitPrt.enabled = false;
foreach (Text txt in textarguments)
{
switch (txt.name)
{
case "UnitName":
txt.text = "비었음";
break;
case "NumberOfUnits":
txt.text = "";
break;
}
}
foreach (Button but in buttons)
{
but.gameObject.SetActive(false);
}
return this.gameObject;
}
// Update is called once per frame
void Update()
{
}
public void SetButton(int i)
{
if (i == -1)
{
foreach (Button but in buttons)
{
but.enabled = false;
}
}
else
{
LinkedListNode<Production> dep = GameManager.Instance.Game.PlayerInTurn.Deployment.First;
for (int k = 0; k < i; k++)
{
dep = dep.Next;
}
foreach (Button but in buttons)
{
switch (but.name)
{
case "Deploy":
but.onClick.AddListener(delegate () { DeployItem(dep.Value); DeployingObject = this.gameObject; });
break;
}
}
}
}
public void DeployItem(Production dep)
{
if (dep.IsCompleted)
{
UIManager.Instance.mapUI.SetActive(true);
UIManager.Instance.managementUI.SetActive(false);
UIManager.Instance.questUI.SetActive(false);
DepStateEnter(dep);
}
else
{
//Debug.Log("Error : not finished product");
throw new AccessViolationException();
}
}
public void DepStateEnter(Production dep)
{
// State change
if (dep == null || _inDepState) return;
_inDepState = true;
_deployment = dep;
// Select deploy tile
CivModel.Terrain terrain = GameManager.Instance.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.Instance.Tiles[point.Position.X, point.Position.Y].GetComponent<HexTile>().FlickerBlue();
}
}
IEnumerator _coroutine = DeployUnit(GameManager.Instance.selectedPoint, dep);
StartCoroutine(_coroutine);
}
}
IEnumerator DeployUnit(CivModel.Terrain.Point point, Production dep)
{
while (true)
{
CivModel.Terrain.Point destPoint = GameManager.Instance.selectedPoint;
// 새로운 Point 을 선택했을 때
if (point != destPoint)
{
// Flicker하고 있는 Tile을 선택했을 때
if (GameManager.Instance.selectedTile.isFlickering)
{
if (dep.IsPlacable(destPoint))
{
game.PlayerInTurn.Deployment.Remove(dep);
dep.Place(destPoint);
//여기에 유닛을 생성하는 걸 추가해야 함
GameManager.Instance.UpdateUnit();
break;
}
else
{
DepStateExit();
}
}
// Flicker 하지 않는 타일 선택
else
{
DepStateExit();
}
}
yield return null;
}
}
void DepStateExit()
{
_inDepState = false;
_deployment = null;
CivModel.Terrain terrain = GameManager.Instance.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.Instance.Tiles[point.Position.X, point.Position.Y].GetComponent<HexTile>().StopFlickering();
}
}
}
}
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
using CivModel;
......@@ -23,44 +22,28 @@ public class GameUI : MonoBehaviour {
// Update is called once per frame
void Update () {
updateEndTurn();
updatePanel();
}
public void updateEndTurn()
{
if (GameManager.Instance.Game.PlayerInTurn.IsAIControlled)
{
mapUI.transform.Find("EndTurn").GetComponentInChildren<Button>().enabled = false;
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().text = "다른 플레이어가 턴 진행 중입니다.\n잠시만 기다려 주십시오.";
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().fontSize = 25;
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().text = "다른 플레이어가 턴 진행 중입니다. 기다려 주십시오.";
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().fontSize = Screen.height / 20;
}
else
{
mapUI.transform.Find("EndTurn").GetComponentInChildren<Button>().enabled = true;
// for testing only
foreach(CivModel.Unit x in GameManager.Instance.Game.PlayerInTurn.Units)
{
x.RemainAP = 0;
}
if (!GameManager.Instance.Game.PlayerInTurn.Units.All(u => (u.RemainAP == 0 || u.SkipFlag)))
if (GameManager.Instance.isThereTodos)
{
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().text = "유닛이 명령을 기다리고 있습니다";
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().fontSize = 35;
}
else if (GameManager.Instance.selectedActor != null)
{
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().text = "배치 취소";
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().fontSize = 40;
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().fontSize = 30;
}
else
{
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().text = "다음 턴";
mapUI.transform.Find("EndTurn").GetComponentInChildren<Text>().fontSize = 40;
}
updatePanel();
}
}
......@@ -97,6 +80,26 @@ public class GameUI : MonoBehaviour {
public void onClickNextTurn()
{
GameManager.Instance.ProceedTurn();
if (GameManager.Instance.isThereTodos)
{
GameManager.Instance.FocusOnActableUnit();
}
else
{
// Debug.Log(Game.PlayerNumberInTurn);
if (GameManager.Instance.Game.PlayerInTurn == GameManager.Instance.Game.Players[0])
GameManager.Instance.Game.EndTurn();
GameManager.Instance.Game.StartTurn();
while (GameManager.Instance.Game.PlayerInTurn.IsAIControlled)
{
// Debug.Log(Game.PlayerNumberInTurn);
GameManager.Instance.Game.PlayerInTurn.DoAITurnAction().GetAwaiter().GetResult();
GameManager.Instance.Game.EndTurn();
GameManager.Instance.Game.StartTurn();
}
GameManager.Instance.UpdateMap();
GameManager.Instance.UpdateUnit();
UIManager.Instance.ButtonInteractChange();
}
}
}
\ No newline at end of file
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using CivModel;
using CivModel.Common;
public class DeployPrefab : MonoBehaviour
{
public static GameObject DeployingObject;
private Text[] textarguments;
private Image unitPrt;
private Button[] buttons;
// Use this for initialization
private bool _inDepState = false;
public bool DepState { get { return _inDepState; } }
private Production _deployment;
public Production Deployment { get { return _deployment; } }
void Awake()
{
//Debug.Log("call DepPre");
textarguments = gameObject.GetComponentsInChildren<Text>();
foreach (Image unt in gameObject.GetComponentsInChildren<Image>())
{
if (unt.name == "Portrait")
{
unitPrt = unt;
}
}
buttons = gameObject.GetComponentsInChildren<Button>();
}
void Start()
{
}
public GameObject MakeItem(Production prod)
{
string nameofProduction = ProductionFactoryTraits.GetFactoryName(prod.Factory);
unitPrt.sprite = Resources.Load(("Portraits/" + (ProductionFactoryTraits.GetFacPortName(prod.Factory)).ToLower()), typeof(Sprite)) as Sprite;
foreach (Text txt in textarguments)
{
switch (txt.name)
{
case "UnitName":
txt.text = nameofProduction;
break;
case "NumberOfUnits":
txt.text = "X 1";
break;
}
}
return this.gameObject;
}
public GameObject MakeItem()
{
unitPrt.enabled = false;
foreach (Text txt in textarguments)
{
switch (txt.name)
{
case "UnitName":
txt.text = "비었음";
break;
case "NumberOfUnits":
txt.text = "";
break;
}
}
foreach (Button but in buttons)
{
but.gameObject.SetActive(false);
}
return this.gameObject;
}
// Update is called once per frame
void Update()
{
}
public void SetButton(int i)
{
if (i == -1)
{
foreach (Button but in buttons)
{
but.enabled = false;
}
}
else
{
LinkedListNode<Production> dep = GameManager.Instance.Game.PlayerInTurn.Deployment.First;
for (int k = 0; k < i; k++)
{
dep = dep.Next;
}
foreach (Button but in buttons)
{
switch (but.name)
{
case "Deploy":
but.onClick.AddListener(delegate () { DeployItem(dep.Value); DeployingObject = this.gameObject; });
break;
}
}
}
}
public void DeployItem(Production dep)
{
if (dep.IsCompleted)
{
DepStateEnter(dep);
UIManager.Instance.mapUI.SetActive(true);
UIManager.Instance.managementUI.SetActive(false);
UIManager.Instance.questUI.SetActive(false);
}
else
{
//Debug.Log("Error : not finished product");
throw new AccessViolationException();
}
}
public void DepStateEnter(Production dep)
{
// State change
if (dep == null || _inDepState) return;
_inDepState = true;
_deployment = dep;
// Select deploy tile
CivModel.Terrain terrain = GameManager.Instance.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.Instance.Tiles[point.Position.X, point.Position.Y].GetComponent<HexTile>().FlickerBlue();
}
}
IEnumerator _coroutine = DeployUnit(GameManager.Instance.selectedPoint, dep);
StartCoroutine(_coroutine);
}
}
IEnumerator DeployUnit(CivModel.Terrain.Point point, Production dep)
{
while (true)
{
CivModel.Terrain.Point destPoint = GameManager.Instance.selectedPoint;
// 새로운 Point 을 선택했을 때
if (point != destPoint)
{
// Flicker하고 있는 Tile을 선택했을 때
if (GameManager.Instance.selectedTile.isFlickering)
{
if (dep.IsPlacable(destPoint))
{
//여기에 유닛을 생성하는 걸 추가해야 함
Debug.Log("Type A");
GameManager.Instance.UpdateUnit();
break;
}
else
{
Debug.Log("Type B");
DepStateExit();
}
}
// Flicker 하지 않는 타일 선택
else
{
Debug.Log("Type C");
DepStateExit();
}
}
yield return null;
}
}
void DepStateExit()
{
_inDepState = false;
_deployment = null;
CivModel.Terrain terrain = GameManager.Instance.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.Instance.Tiles[point.Position.X, point.Position.Y].GetComponent<HexTile>().StopFlickering();
}
}
}
}
This diff is collapsed.
This diff is collapsed.
No preview for this file type
08d5d2c3fa255700.08d5d2c3d19d5d00
\ No newline at end of file
08d5dff4ee8c9c80.08d5dff4ee8c9c80
\ No newline at end of file
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
No preview for this file type
No preview for this file type
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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