Commit 5c2d64d8 authored by 16도재형's avatar 16도재형

Camera improved

parent a63474e2
...@@ -11612,6 +11612,8 @@ MonoBehaviour: ...@@ -11612,6 +11612,8 @@ MonoBehaviour:
mainCamera: {fileID: 1006940699} mainCamera: {fileID: 1006940699}
cameraMoveSpeed: 4 cameraMoveSpeed: 4
cameraZoomSpeed: 6 cameraZoomSpeed: 6
cameraZoomAmount: 5
cameraZoomLimit: 5
outerRadius: 1 outerRadius: 1
innerRadius: 0 innerRadius: 0
cellPrefab: {fileID: 1823159130722898, guid: ef12b8f6d512e104b979d4a75f3e60c0, type: 2} cellPrefab: {fileID: 1823159130722898, guid: ef12b8f6d512e104b979d4a75f3e60c0, type: 2}
......
...@@ -6,9 +6,9 @@ using UnityEngine; ...@@ -6,9 +6,9 @@ using UnityEngine;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
using CivModel; using CivModel;
using CivModel.Common; using CivModel.Common;
using System.Threading.Tasks;
public class GameManager : MonoBehaviour { public class GameManager : MonoBehaviour
{
private static GameManager _manager = null; private static GameManager _manager = null;
public static GameManager I { get { return _manager; } } public static GameManager I { get { return _manager; } }
...@@ -20,6 +20,10 @@ public class GameManager : MonoBehaviour { ...@@ -20,6 +20,10 @@ public class GameManager : MonoBehaviour {
float cameraMoveSpeed; float cameraMoveSpeed;
[SerializeField] [SerializeField]
float cameraZoomSpeed; float cameraZoomSpeed;
[SerializeField]
float cameraZoomAmount;
[SerializeField]
float cameraZoomLimit;
// For drawing hex tile // For drawing hex tile
public float outerRadius = 1f; // Outer&inner radius of hex tile. public float outerRadius = 1f; // Outer&inner radius of hex tile.
...@@ -60,19 +64,12 @@ public class GameManager : MonoBehaviour { ...@@ -60,19 +64,12 @@ public class GameManager : MonoBehaviour {
// Use this when scene changing exists // Use this when scene changing exists
// DontDestroyOnLoad(gameObject); // DontDestroyOnLoad(gameObject);
//_game = new CivModel.Game(GameInfo.mapWidth, GameInfo.mapHeight, GameInfo.numOfPlayer, new GameSchemeFactory()/*, new IGameSchemeFactory[] { new CivModel.AI.GameSchemeFactory()}*/); //_game = new CivModel.Game(GameInfo.mapWidth, GameInfo.mapHeight, GameInfo.numOfPlayer, new GameSchemeFactory()/*, new IGameSchemeFactory[] { new CivModel.AI.GameSchemeFactory()}*/);
var factories = new IGameSchemeFactory[] { _game = new CivModel.Game(".\\Assets\\map.txt", new IGameSchemeFactory[] { new CivModel.Common.GameSchemeFactory() });
new CivModel.Common.GameSchemeFactory(),
new CivModel.Hwan.GameSchemeFactory(),
new CivModel.Finno.GameSchemeFactory(),
new CivModel.Quests.GameSchemeFactory(),
new CivModel.Zap.GameSchemeFactory(),
new CivModel.AI.GameSchemeFactory()
};
_game = new CivModel.Game(".\\Assets\\map.txt", factories);
_game.StartTurn(); _game.StartTurn();
} }
void Start() { void Start()
{
// Instantiate game // Instantiate game
// Map tiling // Map tiling
...@@ -81,15 +78,15 @@ public class GameManager : MonoBehaviour { ...@@ -81,15 +78,15 @@ public class GameManager : MonoBehaviour {
ObserverSet(); ObserverSet();
DrawMap(); DrawMap();
_game.Players[1].IsAIControlled = true;
ProceedTurn(); ProceedTurn();
UIManager.I.MakeUnitInfo();
} }
// Update is called once per frame // Update is called once per frame
void Update() { void Update()
{
Render(_game.Terrain); Render(_game.Terrain);
Debug.Log(Game.PlayerNumberInTurn);
//Debug.Log("Gold:" + _game.PlayerInTurn.Gold + "(+" + _game.PlayerInTurn.GoldIncome +")"); //Debug.Log("Gold:" + _game.PlayerInTurn.Gold + "(+" + _game.PlayerInTurn.GoldIncome +")");
//Debug.Log("Pop:" + _game.PlayerInTurn.Population); //Debug.Log("Pop:" + _game.PlayerInTurn.Population);
//Debug.Log("Happ:" + _game.PlayerInTurn.Happiness); //Debug.Log("Happ:" + _game.PlayerInTurn.Happiness);
...@@ -209,11 +206,25 @@ public class GameManager : MonoBehaviour { ...@@ -209,11 +206,25 @@ public class GameManager : MonoBehaviour {
} }
} }
} }
void ContinuousMap()
/*public void BuildBuilding(CivModel.Terrain.Point pos, TileBuilding building)
{ {
/*
float cameraX = mainCamera.transform.position.x;
int times = (int)(cameraX / (GameInfo.mapWidth * 2 * innerRadius));
int from = (int)(cameraX / (2 * innerRadius) - times * GameInfo.mapWidth);
}*/ for (int i = GameInfo.mapWidth + from - 30; i < GameInfo.mapWidth + from + 30; i++)
{
for (int j = 0; j < GameInfo.mapHeight; j++)
{
i %= GameInfo.mapWidth;
float x = (times + i) * GameInfo.mapWidth * 2 * innerRadius - innerRadius * ((i + 1) % 2);
Vector3 pos = new Vector3(x, 0, _cells[i, j].transform.position.z);
_cells[i, j].transform.position = pos;
}
}
*/
}
// Read game terrain and update hex tile resource // Read game terrain and update hex tile resource
void Render(CivModel.Terrain terrain) void Render(CivModel.Terrain terrain)
{ {
...@@ -282,35 +293,23 @@ public class GameManager : MonoBehaviour { ...@@ -282,35 +293,23 @@ public class GameManager : MonoBehaviour {
isThereTodos = true; isThereTodos = true;
Focus(); Focus();
} }
public async Task ProceedTurn() public void ProceedTurn()
{ {
while (true) if (_game.IsInsideTurn)
{ _game.EndTurn();
if (_game.IsInsideTurn) _game.StartTurn();
_game.EndTurn();
_game.StartTurn();
if (_game.PlayerInTurn.IsAIControlled) SelectNextUnit();
{ if (_selectedActor == null)
await _game.PlayerInTurn.DoAITurnAction(); {
} if (_game.PlayerInTurn.Cities.FirstOrDefault() is CivModel.CityBase)
else
{ {
SelectNextUnit(); CityBase city = _game.PlayerInTurn.Cities.FirstOrDefault();
if (_selectedActor == null) if (city.PlacedPoint is CivModel.Terrain.Point)
{ Focus(city.PlacedPoint.Value);
if (_game.PlayerInTurn.Cities.FirstOrDefault() is CivModel.CityBase)
{
CityBase city = _game.PlayerInTurn.Cities.FirstOrDefault();
if (city.PlacedPoint is CivModel.Terrain.Point)
Focus(city.PlacedPoint.Value);
}
}
PseudoFSM.I.NormalStateEnter();
UIManager.I.MakeUnitInfo();
break;
} }
} }
PseudoFSM.I.NormalStateEnter();
} }
// Camera focus // Camera focus
...@@ -318,13 +317,13 @@ public class GameManager : MonoBehaviour { ...@@ -318,13 +317,13 @@ public class GameManager : MonoBehaviour {
{ {
Focus(_selectedActor); Focus(_selectedActor);
} }
void Focus(CivModel.Unit unit) void Focus(CivModel.Actor actor)
{ {
if (unit.PlacedPoint == null) if (actor.PlacedPoint == null)
{ {
return; return;
} }
Focus(unit.PlacedPoint.Value); Focus(actor.PlacedPoint.Value);
} }
void Focus(CivModel.Terrain.Point point) void Focus(CivModel.Terrain.Point point)
{ {
...@@ -340,13 +339,23 @@ public class GameManager : MonoBehaviour { ...@@ -340,13 +339,23 @@ public class GameManager : MonoBehaviour {
void CameraMove(Vector3 vec) void CameraMove(Vector3 vec)
{ {
mainCamera.transform.Translate(vec * cameraMoveSpeed * Time.deltaTime, Space.World); mainCamera.transform.Translate(vec * cameraMoveSpeed * Time.deltaTime, Space.World);
ContinuousMap();
} }
void CameraZoom() void CameraZoom()
{ {
Vector2 vec2 = Input.mouseScrollDelta; Vector2 vec2 = Input.mouseScrollDelta;
Vector3 vec3 = new Vector3(vec2.x, 0, vec2.y); Vector3 vec3 = new Vector3(vec2.x, 0, vec2.y);
mainCamera.transform.Translate(vec3 * cameraZoomSpeed * Time.deltaTime, Space.Self); if (cameraZoomAmount < cameraZoomLimit && vec2.y > 0)
} {
mainCamera.transform.Translate(vec3 * cameraZoomSpeed * Time.deltaTime, Space.Self);
cameraZoomAmount += vec2.y * Time.deltaTime;
}
if (cameraZoomAmount > 0 && vec2.y < 0)
{
mainCamera.transform.Translate(vec3 * cameraZoomSpeed * Time.deltaTime, Space.Self);
cameraZoomAmount += vec2.y * Time.deltaTime;
}
}
// Move _selectedActor // Move _selectedActor
void Move(CivModel.Terrain.Point point) void Move(CivModel.Terrain.Point point)
...@@ -412,104 +421,11 @@ public static class ProductionFactoryTraits ...@@ -412,104 +421,11 @@ public static class ProductionFactoryTraits
case "JediKnightProductionFactory": case "JediKnightProductionFactory":
result = "제다이 기사"; result = "제다이 기사";
break; break;
case "FakeKnightProductionFactory":
result = "가짜 기사(테스팅)";
break;
case "BrainwashedEMUKnightProductionFactory":
result = "세뇌된 에뮤 기사";
break;
case "DecentralizedMilitaryProductionFactory":
result = "탈중앙화된 군인";
break;
case "JackieChanProductionFactory":
result = "재키 찬";
break;
case "LEOSpaceArmadaProductionFactory":
result = "저궤도 우주 함대";
break;
case "ProtoNinjaProductionFactory":
result = "프로토-닌자";
break;
case "UnicornOrderProductionFactory":
result = "유니콘 기사단";
break;
case "SpyProductionFactory":
result = "스파이";
break;
case "AncientSorcererProductionFactory":
result = "고대 소서러";
break;
case "AutismBeamDroneFactory":
result = "O-ti-ism 빔 드론";
break;
case "ElephantCavalryProductionFactory":
result = "코끼리 기병";
break;
case "EMUHorseArcherProductionFactory":
result = "에뮤 궁기병";
break;
case "GenghisKhanProductionFactory":
result = "징기즈 칸";
break;
case "ArmedDivisionProductionFactory":
result = "기갑사단";
break;
case "InfantryDivisionProductionFactory":
result = "보병사단";
break;
case "PadawanProductionFactory":
result = "파다완";
break;
case "ZapNinjaProductionFactory":
result = "닌자";
break;
case "CityCenterProductionFactory": case "CityCenterProductionFactory":
result = "도심부"; result = "도심부";
break; break;
case "HwanEmpireCityProductionFactory": case "FakeKnightProductionFactory":
result = "환 제국 도시"; result = "가짜 기사(테스팅)";
break;
case "HwanEmpireFIRFortressProductionFactory":
result = "환 제국 4차 산업 요새";
break;
case "HwanEmpireCityCentralLabProductionFactory":
result = "환 제국 도시 연구소";
break;
case "HwanEmpireFIRFactoryProductionFactory":
result = "환 제국 4차 산업 요새";
break;
case "HwanEmpireIbizaProductionFactory":
result = "환 제국 이비자";
break;
case "HwanEmpireKimchiFactoryProductionFactory":
result = "환 제국 김치 군수공장";
break;
case "HwanEmpireLatifundiumProductionFactory":
result = "환 제국 라티푼디움";
break;
case "AncientFinnoFineDustFactoryProductionFactory":
result = "고대 수오미 제국 미세먼지 공장";
break;
case "AncientFinnoFIRFortressProductionFactory":
result = "고대 수오미 제국 4차 산업 요새";
break;
case "AncientFinnoGermaniumMineProductionFactory":
result = "고대 수오미 제국 게르마늄 광산";
break;
case "AncientFinnoOctagonProductionFactory":
result = "고대 수오미 제국 옥타곤";
break;
case "FinnoEmpireCityProductionFactory":
result = "고대 수오미 제국 도시";
break;
case "CasinoProductionFactory":
result = "카지노";
break;
case "FIRFortressProductionFactory":
result = "4차 산업 요새";
break;
case "ZapFactoryBuildingProductionFactory":
result = "공장";
break; break;
case "FactoryBuildingProductionFactory": case "FactoryBuildingProductionFactory":
result = "공장"; result = "공장";
...@@ -548,54 +464,6 @@ public static class ProductionFactoryTraits ...@@ -548,54 +464,6 @@ public static class ProductionFactoryTraits
case "LaboratoryBuildingProductionFactory": case "LaboratoryBuildingProductionFactory":
result = "Laboratory"; result = "Laboratory";
break; break;
case "BrainwashedEMUKnightProductionFactory":
result = "BrainwashedEMUKnight";
break;
case "DecentralizedMilitaryProductionFactory":
result = "DecentralizedMilitary";
break;
case "JackieChanProductionFactory":
result = "JackieChan";
break;
case "LEOSpaceArmadaProductionFactory":
result = "LEOSpaceArmada";
break;
case "ProtoNinjaProductionFactory":
result = "ProtoNinja";
break;
case "UnicornOrderProductionFactory":
result = "UnicornOrder";
break;
case "SpyProductionFactory":
result = "Spy";
break;
case "AncientSorcererProductionFactory":
result = "AncientSorcerer";
break;
case "AutismBeamDroneFactory":
result = "AutismBeamDrone";
break;
case "ElephantCavalryProductionFactory":
result = "ElephantCavalry";
break;
case "EMUHorseArcherProductionFactory":
result = "EMUHorseArcher";
break;
case "GenghisKhanProductionFactory":
result = "GenghisKhan";
break;
case "ArmedDivisionProductionFactory":
result = "ArmedDivision";
break;
case "InfantryDivisionProductionFactory":
result = "InfantryDivision";
break;
case "PadawanProductionFactory":
result = "Padawan";
break;
case "ZapNinjaProductionFactory":
result = "ZapNinja";
break;
default: default:
result = "unknown : " + name; result = "unknown : " + name;
break; break;
...@@ -624,57 +492,9 @@ public static class ProductionFactoryTraits ...@@ -624,57 +492,9 @@ public static class ProductionFactoryTraits
case "FactoryBuilding": case "FactoryBuilding":
result = "공장"; result = "공장";
break; break;
case "LaboratoryBuilding": case "LabortoryBuilding":
result = "연구소"; result = "연구소";
break; break;
case "BrainwashedEMUKnight":
result = "세뇌된 에뮤 기사";
break;
case "DecentralizedMilitary":
result = "탈중앙화된 군인";
break;
case "JackieChan":
result = "재키 찬";
break;
case "LEOSpaceArmada":
result = "저궤도 우주 함대";
break;
case "ProtoNinja":
result = "프로토-닌자";
break;
case "UnicornOrder":
result = "유니콘 기사단";
break;
case "Spy":
result = "스파이";
break;
case "AncientSorcerer":
result = "고대 소서러";
break;
case "AutismBeamDrone":
result = "O-ti-ism 빔 드론";
break;
case "ElephantCavalry":
result = "코끼리 기병";
break;
case "EMUHorseArcher":
result = "에뮤 궁기병";
break;
case "GenghisKhan":
result = "징기즈 칸";
break;
case "ArmedDivision":
result = "기갑사단";
break;
case "InfantryDivision":
result = "보병사단";
break;
case "Padawan":
result = "파다완";
break;
case "ZapNinja":
result = "닌자";
break;
default: default:
result = "unknown : " + name; result = "unknown : " + name;
break; break;
......
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