Commit 9f712bd9 authored by 17주승원's avatar 17주승원

Tile, Building, Unit Instantiation Available!

parent 602a0ea8
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1994173042382988}
m_IsPrefabParent: 1
--- !u!1 &1994173042382988
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4164349117385164}
- component: {fileID: 33675704233413142}
- component: {fileID: 23430415915558628}
- component: {fileID: 95116768080365986}
- component: {fileID: 114555728656525668}
m_Layer: 0
m_Name: unit
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4164349117385164
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1994173042382988}
m_LocalRotation: {x: -0.00000003774895, y: 0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: 1.4732, z: -0.1016}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &23430415915558628
MeshRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1994173042382988}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_Materials:
- {fileID: 2100000, guid: b30586820caa1de47b0e0ed1aa73c608, type: 3}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &33675704233413142
MeshFilter:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1994173042382988}
m_Mesh: {fileID: 4300000, guid: b30586820caa1de47b0e0ed1aa73c608, type: 3}
--- !u!95 &95116768080365986
Animator:
serializedVersion: 3
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1994173042382988}
m_Enabled: 1
m_Avatar: {fileID: 9000000, guid: b30586820caa1de47b0e0ed1aa73c608, type: 3}
m_Controller: {fileID: 0}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!114 &114555728656525668
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1994173042382988}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 67add831fd3c2384b9a1363aa1aa1331, type: 3}
m_Name:
m_EditorClassIdentifier:
fileFormatVersion: 2
guid: d799813cc5de24e418535494923a7dfa
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:
......@@ -252,13 +252,13 @@ Transform:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1029091335}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 110, y: 120, z: -60}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!1 &1802626827
GameObject:
m_ObjectHideFlags: 0
......@@ -290,6 +290,27 @@ MonoBehaviour:
innerRadius: 0.8660254
HextilePrefab: {fileID: 1864742050183090, guid: ef12b8f6d512e104b979d4a75f3e60c0,
type: 2}
UnitPrefab: {fileID: 1994173042382988, guid: d799813cc5de24e418535494923a7dfa, type: 2}
materials:
- {fileID: 2100000, guid: aaebbdfcddf55724e81f16f00843036c, type: 2}
- {fileID: 2100000, guid: d7c1b912f778c81408d5373612b7e506, type: 2}
- {fileID: 2100000, guid: 689b4e837e7f57a4f9661066ac8cb604, type: 2}
- {fileID: 2100000, guid: 6c4b3b32f0097254dbd6fbd4bd8c6514, type: 2}
- {fileID: 2100000, guid: d43034c6b6ecbd34490444b94465fcc8, type: 2}
- {fileID: 2100000, guid: 66b06834ae9caa44e83577e34d8cfc67, type: 2}
- {fileID: 2100000, guid: 4912b0e955bd12447a4eb88abdff0301, type: 2}
- {fileID: 2100000, guid: 1a36748b9a8dec6439997129156b4bac, type: 2}
- {fileID: 2100000, guid: e7bac625115da16408e49bbb9b01c57c, type: 2}
- {fileID: 2100000, guid: d5c18e411ea7f764592e1b2777482dcd, type: 2}
- {fileID: 2100000, guid: 9f9a3969923bd8d498f73da024895219, type: 2}
- {fileID: 2100000, guid: 6a388cc3d531c8d4085057d7f11fff91, type: 2}
- {fileID: 2100000, guid: 7a2dc2bcd2b2f93479cadccf877ebb17, type: 2}
- {fileID: 2100000, guid: 896df3751f60a50448f436393973eaf3, type: 2}
- {fileID: 2100000, guid: 64c7a7eeee22cda4c94c7afe85acf340, type: 2}
- {fileID: 2100000, guid: eb14f06a5eddeed48a11418664db9594, type: 2}
- {fileID: 2100000, guid: 31a4feda50a4d7c4f94a5f71806c7df7, type: 2}
- {fileID: 2100000, guid: 9f18b1711a90f794aad93d565cfc12e2, type: 2}
rend: {fileID: 0}
--- !u!4 &1802626829
Transform:
m_ObjectHideFlags: 0
......
......@@ -4,11 +4,14 @@ using System.Collections.Generic;
using UnityEngine;
using CivModel;
public class GameManager : MonoBehaviour
{
public class GameManager : MonoBehaviour {
private CivModel.Game _game;
public CivModel.Game Game { get { return _game; } }
private static GameManager _manager = null;
public static GameManager I { get { return _manager; } }
public float outerRadius = 1f; // Outer&inner radius of hex tile.
public float innerRadius = Mathf.Sqrt(3) / 2; // These variables can be deleted if there are no use.
......@@ -16,8 +19,22 @@ public class GameManager : MonoBehaviour
private GameObject[,] _tiles;
public GameObject[,] Tiles { get { return _tiles; } }
void Awake()
{
public GameObject UnitPrefab;
public Material[] materials;
public Renderer rend;
void Awake() {
// Singleton
if (_manager != null) {
Destroy(gameObject);
return;
}
else {
_manager = this;
}
var factories = new IGameSchemeFactory[]
{
new CivModel.Common.GameSchemeFactory(),
......@@ -32,40 +49,50 @@ public class GameManager : MonoBehaviour
}
// Use this for initialization
void Start ()
{
void Start() {
InitiateMap();
}
// Update is called once per frame
void Update () {
void Update() {
}
private void InitiateMap()
{
private void InitiateMap() {
_tiles = new GameObject[_game.Terrain.Width, _game.Terrain.Height];
for (int i = 0; i < _game.Terrain.Width; i++)
{
for (int j = 0; j < _game.Terrain.Height; j++)
{
for (int i = 0; i < _game.Terrain.Width; i++) {
for (int j = 0; j < _game.Terrain.Height; j++) {
Vector3 pos = new Vector3(2 * i * innerRadius, -0.05f, -j * outerRadius * 1.5f);
if (j % 2 != 0)
{
if (j % 2 != 0) {
pos.x -= innerRadius;
}
_tiles[i, j] = Instantiate(HextilePrefab, pos, Quaternion.identity);
_tiles[i, j].name = String.Format("({0},{1})", i, j);
_tiles[i, j].GetComponent<HexTile>().point = _game.Terrain.GetPoint(i, j);
/*
* TODO
* hextile을 생성한 후, Terrian point 클래스의 값을 이용하여
* Hextile의 terrains, tilebuilding을 수정해야 함.
*/
_tiles[i, j].name = String.Format("Tile({0},{1})", i, j);
CivModel.Terrain.Point pnt = _game.Terrain.GetPoint(i, j);
_tiles[i, j].GetComponent<HexTile>().point = pnt;
if (pnt.Unit != null)
InitiateUnit(_game.Terrain.GetPoint(i, j).Unit);
}
}
}
private void InitiateUnit(CivModel.Unit unit) {
if (unit?.PlacedPoint != null) {
var pt = unit.PlacedPoint.Value;
Vector3 pos = new Vector3(2 * pt.Position.X * innerRadius, 1.25f, -pt.Position.Y * outerRadius * 1.5f);
if ((pt.Position.Y % 2) != 0) {
pos.x -= innerRadius;
}
GameObject unt = Instantiate(UnitPrefab, pos, Quaternion.identity);
unt.name = String.Format("Unit[{0},{1}]", pt.Position.X, pt.Position.Y);
unt.GetComponent<Unit>().point = pt;
foreach (Material m in GameManager.I.materials) {
if (m == GameManager.I.materials[(int)UnitEnum.UnitToEnum(unit)]) {
unt.GetComponent<Renderer>().material = m;
}
}
}
}
}
......@@ -3,7 +3,10 @@ guid: 21eefa2ef0518bc4891057f3f8916cb5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
defaultReferences:
- HextilePrefab: {instanceID: 0}
- UnitPrefab: {instanceID: 0}
- rend: {instanceID: 0}
executionOrder: 0
icon: {instanceID: 0}
userData:
......
......@@ -9,53 +9,71 @@ public class HexTile : MonoBehaviour
public CivModel.Terrain.Point point;
// prefab의 자식 gameobject들
GameObject terrains;
GameObject tilebuildings;
Transform terrains;
Transform buildings;
/*
* TODO
* Hextile Prefab을 수정하여 terrain와 tilebuilding을 설정할 수 있게 해야함.
*/
CivModel.TileBuilding building;
/*
* 관련 legacy code
public void ChangeTile()
{
if (terrains == null)
{
// Use this for initialization
void Start() {
terrains = transform.GetChild(0).transform;
SetTerrain();
buildings = transform.GetChild(1).transform;
building = point.TileBuilding;
SetBuilding();
}
else
{
foreach (Transform child in terrains)
{
child.gameObject.SetActive(false);
// Render tile terrain
public void SetTerrain() {
if (terrains != null) {
terrains.GetChild((int)point.Type).gameObject.SetActive(true);
}
}
if (point.TileBuilding is CivModel.CityBase)
{
terrains.GetChild(0).gameObject.SetActive(true);
public void SetBuilding() {
Transform side;
if (building is CivModel.CityBase) {
buildings.GetChild(2).gameObject.SetActive(true);
side = buildings.GetChild((building.Owner.Team + 1) % 2);
side.GetChild(0).gameObject.SetActive(true);
}
else
{
terrains.GetChild((int)point.Type).gameObject.SetActive(true);
else if (building is CivModel.Hwan.HwanEmpireIbiza) {
side = buildings.GetChild(0);
side.GetChild(1).gameObject.SetActive(true);
}
else if (building is CivModel.Finno.AncientFinnoOctagon) {
side = buildings.GetChild(1);
side.GetChild(1).gameObject.SetActive(true);
}
public void BuildDistrict(CivModel.TileBuilding building)
{
buildings.GetChild(2).gameObject.SetActive(false);
for (int i = 0; i < 2; i++)
{
foreach (Transform child in buildings.GetChild(i))
{
child.gameObject.SetActive(false);
else if (building is CivModel.Hwan.HwanEmpireLatifundium) {
side = buildings.GetChild(0);
side.GetChild(2).gameObject.SetActive(true);
}
else if (building is CivModel.Finno.AncientFinnoGermaniumMine) {
side = buildings.GetChild(1);
side.GetChild(2).gameObject.SetActive(true);
}
if (building != null)
{
TileBuildingObject(building);
else if (building is CivModel.Hwan.HwanEmpireFIRFortress) {
side = buildings.GetChild(0);
side.GetChild(3).gameObject.SetActive(true);
}
}*/
else if (building is CivModel.Finno.AncientFinnoFIRFortress) {
side = buildings.GetChild(1);
side.GetChild(3).gameObject.SetActive(true);
}
else if (building is CivModel.Hwan.HwanEmpireKimchiFactory) {
side = buildings.GetChild(0);
side.GetChild(4).gameObject.SetActive(true);
}
else if (building is CivModel.Finno.AncientFinnoFineDustFactory) {
side = buildings.GetChild(1);
side.GetChild(4).gameObject.SetActive(true);
}
}
}
fileFormatVersion: 2
guid: d8d29a913d13fb5479a01f02c8d8ef1f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Unit : MonoBehaviour {
// 현재 Unit의 위치의 point class
public CivModel.Terrain.Point point;
// Use this for initialization
void Start() {
}
}
fileFormatVersion: 2
guid: 67add831fd3c2384b9a1363aa1aa1331
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
public enum Units {
HwanPioneer,
HwanBrainwashedEmuKnight,
HwanDecentralizedMilitary,
HwanSpy,
HwanUnicornOrder,
HwanLEO,
HwanJediKnight,
HwanProtoNinja,
HwanJackieChan,
FinnoPioneer,
FinnoEmuHorseArcher,
FinnoDecentralizedMilitary,
FinnoSpy,
FinnoElephantCavarly,
FinnoAncientSorcerer,
FinnoJediKnight,
FinnoAutismBeamDrone,
FinnoGenghisKhan
}
public class UnitEnum {
public static Units UnitToEnum(CivModel.Unit unit) {
if (unit is CivModel.Hwan.Pioneer) {
return Units.HwanPioneer;
}
else if (unit is CivModel.Hwan.BrainwashedEMUKnight) {
return Units.HwanBrainwashedEmuKnight;
}
else if (unit is CivModel.Hwan.DecentralizedMilitary) {
return Units.HwanDecentralizedMilitary;
}
else if (unit is CivModel.Hwan.Spy) {
return Units.HwanSpy;
}
else if (unit is CivModel.Hwan.UnicornOrder) {
return Units.HwanUnicornOrder;
}
else if (unit is CivModel.Hwan.LEOSpaceArmada) {
return Units.HwanLEO;
}
else if (unit is CivModel.Hwan.JediKnight) {
return Units.HwanJediKnight;
}
else if (unit is CivModel.Hwan.ProtoNinja) {
return Units.HwanProtoNinja;
}
else if (unit is CivModel.Hwan.JackieChan) {
return Units.HwanJackieChan;
}
else if (unit is CivModel.Finno.Pioneer) {
return Units.FinnoPioneer;
}
else if (unit is CivModel.Finno.EMUHorseArcher) {
return Units.FinnoEmuHorseArcher;
}
else if (unit is CivModel.Finno.DecentralizedMilitary) {
return Units.FinnoDecentralizedMilitary;
}
else if (unit is CivModel.Finno.Spy) {
return Units.FinnoSpy;
}
else if (unit is CivModel.Finno.ElephantCavalry) {
return Units.FinnoElephantCavarly;
}
else if (unit is CivModel.Finno.AncientSorcerer) {
return Units.FinnoAncientSorcerer;
}
else if (unit is CivModel.Finno.JediKnight) {
return Units.FinnoJediKnight;
}
else if (unit is CivModel.Finno.AutismBeamDrone) {
return Units.FinnoAutismBeamDrone;
}
else {
return Units.HwanBrainwashedEmuKnight;
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 3fb7438be05923441b2781bca534ac74
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -664,9 +664,9 @@ PlayerSettings:
UNet: 1
facebookSdkVersion: 7.9.4
apiCompatibilityLevel: 3
cloudProjectId: 351bd782-e721-4672-a71a-85649ff2d005
projectName: civilization-iii (1)
organizationId: abslon
cloudProjectId: 05bcf8b1-629c-4377-952c-497ed7680198
projectName: civilization-iii
organizationId: dshseungwon
cloudEnabled: 0
enableNativePlatformBackendsForNewInputSystem: 0
disableOldInputManagerSupport: 0
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