public bool Load(string mapName) { string path = GetSelectedPath(mapName); try { BinaryReader reader = new BinaryReader(File.OpenRead(path)); int header = reader.ReadInt32(); if (header <= mapFileVersion) { hexGrid.Load(reader, header); HexMapCamera.ValidatePosition(); } else { Debug.LogWarning("Unknown map format " + header); } } catch (Exception e) { Debug.Log($"Exception - Hexmap Load file failed - {e}"); return(false); } return(true); }
void Update() { if (!instance) { instance = this; } float zoomDelta = Input.GetAxis("Mouse ScrollWheel"); if (zoomDelta != 0f) { AdjustZoom(zoomDelta); } float rotationDelta = Input.GetAxis("Rotation"); if (rotationDelta != 0f) { AdjustRotation(rotationDelta); } float xDelta = Input.GetAxis("Horizontal"); float zDelta = Input.GetAxis("Vertical"); if (xDelta != 0f || zDelta != 0f) { AdjustPosition(xDelta, zDelta); } }
private void Start() { Figures = new Figure[20, 15]; var cellPosition = hexGrid.GetCell(new Vector3(155.8846f, -0.4045f, 30.0f)).transform.position; SpawnFigure(2, 8, 2, 155.8846f, -0.4045f, 30.0f); hexGrid.GetCell(new Vector3(155.8846f, -0.4045f, 30.0f)).Walled = true; hexGrid.GetCell(new Vector3(155.8846f, -0.4045f, 30.0f)).isWallCapsule = true; SpawnFigure(3, 2, 13, 147.2243f, 0.8379046f, 195.0f); hexGrid.GetCell(new Vector3(147.2243f, 0.8379046f, 195.0f)).PlantLevel = 3; hexGrid.GetCell(new Vector3(147.2243f, 0.8379046f, 195.0f)).isWallNonCapsule = true; camera = GameObject.Find("Hex Map Camera").GetComponent <HexMapCamera>(); firstPlayerCounter = 60.0f; secondPlayerCounter = 60.0f; playerOwnershipManager = hexGrid.GetComponent <PlayerOwnershipManager>(); firstPlayerTimerbar = GameObject.Find("First Player Timer Bar").GetComponent <ProgressBarBehaviour>(); secondPlayerTimerbar = GameObject.Find("Second Player Timer Bar").GetComponent <ProgressBarBehaviour>(); firstPlayerTimerbar.Value = 100; secondPlayerTimerbar.Value = 100; players = new Player[2] { new Player("first", BuildingType.WALLS), new Player("second", BuildingType.PLANTS) }; }
void Awake() { instance = this; ValidatePostion(); swivel = transform.GetChild(0); stick = swivel.GetChild(0); }
public void SetBaseCity() { int chunk = Randomize.GetRandomInt(0, hexGridChunk.Length - 1); int cell = Randomize.GetRandomInt(0, 24); while (hexGridChunk[chunk].cells[cell].neighbors.Length != 6) { Debug.Log("Try to find new tile"); cell = Randomize.GetRandomInt(0, 24); } //放置城镇中心,2,0,0 hexGrid.SetTile(hexGridChunk[chunk].cells[cell], 2, 0, 0, 1); hexGridChunk[chunk].cells[cell].isVisible = true; hexGridChunk[chunk].cells[cell].visionField = 0; hexMapCamera.AdjustPosition(hexGridChunk[chunk].cells[cell].transform.localPosition); HexMapCamera.ValidatePostion(); for (int i = 0; i < 6; i++) { if (hexGridChunk[chunk].cells[cell].neighbors[i].tileType == (TileType)0) { hexGrid.SetTile(hexGridChunk[chunk].cells[cell].neighbors[i], 2, 0, Randomize.GetRandomInt(1, 4), 1); hexGridChunk[chunk].cells[cell].neighbors[i].isVisible = true; hexGridChunk[chunk].cells[cell].neighbors[i].visionField = 1; } } }
void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } //DontDestroyOnLoad(gameObject); enemies = new List <Enemy>(); boardScript = GetComponent <BoardManager>(); dungeonScript = GetComponent <DungeonManager>(); dungeonBSPScript = GetComponent <BSPDungeonManager>(); if (GameObject.FindGameObjectWithTag("Player")) { playerOne = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>(); } textHandle = new TextHandle(); textHandle.ReadFile("seeds"); camera3D = FindObjectOfType <HexMapCamera>(); InitGame(); }
void ShowScoutUI() { scoutUI.gameObject.SetActive(true); scoutUI.currentCell = currentCell; scoutUI.resourcePoint = gameManager.FindResourcePoint(currentCell); HexMapCamera.MoveTo(currentCell); }
void Start() { mapGenerator.GenerateMap(70, 60, seed); cellCount = 70 * 60; HexMapCamera.CenterPosition(); if (isServer) { GetAvailableCells(); do { FindTreasureCell(); } while (!FindStartCell(40, 20)); itemTypes.Add((int)HexItemType.Treasure); itemCellIndex.Add(treasureCell.Index); RemoveAvailableCell(serverStart); RemoveAvailableCell(clientStart); RemoveAvailableCell(treasureCell); SpreadKeys(10); SpreadItems(100); SendStart(); } inGame = true; }
private void OnEnable() { if (!instance) { instance = this; } }
private void OnEnable() { if (!instance) { instance = this; ValidatePosition(); } }
private void Awake() { instance = this; ValidatePosition(); HexMapCamera.Locked = true; swivel = transform.GetChild(0); stick = swivel.GetChild(0); }
// Use this for initialization void Start() { hexMapCamera = FindObjectOfType <HexMapCamera>(); attachedObject = transform.parent; spriteRenderer = GetComponentInChildren <SpriteRenderer>(); regression = 1f / (upperLimit - lowerLimit); intercept = 1 - regression * upperLimit; }
public void Load() { string path = Path.Combine(Application.persistentDataPath, "test.map"); using (BinaryReader reader = new BinaryReader(File.OpenRead(path))) { _hexGrid.Load(reader); HexMapCamera.ValidatePosition(); } }
public void RespawnPlayInRandomCell() { gamePlayEditor.GetComponent <HexMapEditor>(); while (!gamePlayEditor.CreateUnit(RandomCoordinate())) { Debug.Log("Random player set up!"); hexMapCamera = hexMapCamera.GetComponent <HexMapCamera>(); // hexMapCamera.MovingCameraToUnit(); } }
void Awake() { grid = FindObjectOfType <HexGrid>(); if (FindObjectOfType <HexGameUI>() != null) { FindObjectOfType <HexGameUI>().m_mainCamera = this; } instance = this; swivel = transform.GetChild(0); stick = swivel.GetChild(0); transform.position = m_startCameraPosition; }
void CreateMap(int x, int z) { if (generateMaps) { mapGenerator.GenerateMap(x, z); } else { hexGrid.CreateMap(x, z); } HexMapCamera.ValidatePosition(); Close(); }
/// <summary> /// 创建地图 /// </summary> /// <param name="x"></param> /// <param name="z"></param> void CreateMap(int x, int z) { if (generateMaps) { mapGenerator.GenerateMap(x, z); // 生成随机地图 } else { hexGrid.CreateMap(x, z); // 生成默认地图 } HexMapCamera.ValidatePosition(); // 验证地图边界,矫正摄像机位置 Close(); }
public void CreateMap(int x, int z) { if (m_generateMaps) { HexMapGenerator.GenerateMap(x, z, m_wrap); } else { HexGrid.CreateMap(x, z, m_wrap); } HexMapCamera.ValidatePosition(); Close(); }
void CreateMap(int x, int z) { //проверка способа создания карты if (generateMaps) { mapGenerator.GenerateMap(x, z, wrapping); } else { hexGrid.CreateMap(x, z, wrapping); } HexMapCamera.ValidatePosition(); Close(); }
void CreateMap(int x, int z) { if (generateMaps) { mapGenerator.GenerateMap(x, z); } else { hexGrid.CreateMap(x, z); } HexMapCamera.ValidatePosition(); playMode.RespawnPlayInRandomCell(); Close(); }
public void SetLabel(string text) { UnityEngine.UI.Text label = uiRect.GetComponent <Text>(); label.text = text; float angle = HexMapCamera.GetRotationAngle() + 30f; int delta = Mathf.FloorToInt(angle / 60f); if (delta == 6) { delta = 0; } uiRect.localRotation = Quaternion.Euler(0f, 0f, -60f * delta); }
public void AddUnit(HexUnit unit, HexCell location) { cellShaderData.ImmediateMode = true; units.Add(unit); unit.Grid = this; unit.transform.SetParent(transform, false); unit.Location = location; unit.Orientation = Random.Range(0f, 360f); cellShaderData.ImmediateMode = false; if (unit.Owned) { HexMapCamera.SetPosition(unit.Location); } }
void Awake() { instance = this; followingGameObject = false; swivel = transform.GetChild(0); stick = swivel.GetChild(0); if (isOrthographic) { camera.orthographic = true; } else { camera.orthographic = false; } }
private void Awake() { _swivel = transform.GetChild(0); _stick = _swivel.GetChild(0); // TODO: check if removing the null check breaks the logic, HexMapCameraInstance != null if (HexMapCameraInstance) { Destroy(gameObject); } else { HexMapCameraInstance = this; } _mainCamera = GetComponentInChildren <Camera>(); }
void Load(string pathp) { if (!File.Exists(pathp)) { path = null; return; } using (BinaryReader reader = new BinaryReader(File.OpenRead(path))) { int header = reader.ReadInt32(); if (header <= 1) { hexGrid.Load(reader, header); HexMapCamera.ValidatePosition(); } } }
public void Load() { string path = Path.Combine(Application.persistentDataPath, "test.map"); using (BinaryReader reader = new BinaryReader(File.OpenRead(path))) { int header = reader.ReadInt32(); if (header <= 1) { hexGrid.Load(reader, header); HexMapCamera.ValidatePosition(); } else { Debug.LogWarning("Unknown map format " + header); } } }
public IEnumerator CheckValidateCameraPosition() { SceneManager.LoadScene("Scene", LoadSceneMode.Single); yield return(new WaitForSeconds(1.0f)); goA = SceneManager.GetActiveScene().GetRootGameObjects(); GameObject Camera = goA[2]; HexMapCamera.ValidatePosition(); Assert.AreEqual(Camera.gameObject.transform.localPosition, new Vector3(0f, 0f, 0f)); foreach (GameObject g in goA) { GameObject.Destroy(g); } GameObject.Destroy(Camera); SceneManager.UnloadScene("Scene"); }
public void Load() { DirectoryInfo info = new DirectoryInfo(Application.dataPath); string path = Path.Combine(info.ToString() + "/Maps", "test.map"); using (BinaryReader reader = new BinaryReader(File.OpenRead(path))) { int header = reader.ReadInt32(); if (header <= HexMapEditor.mapVersion) { hexGrid.Load(reader, header); HexMapCamera.ValidatePosition(); } else { Debug.LogWarning("Unknown map format " + header); } } }
void Load(string path) { if (!File.Exists(path)) { Debug.LogError("File does not exist " + path); return; } using (BinaryReader reader = new BinaryReader(File.OpenRead(path))) { int header = reader.ReadInt32(); if (header <= mapFileVersion) { hexGrid.Load(reader, header); HexMapCamera.ValidatePosition(); } else { Debug.LogWarning("Unknown map format " + header); } } }
public void UseItem(HexItemType type) { switch (type) { case HexItemType.Poison: otherUnit.SpeedEffect(-20, 3); SendEffect(HexItemType.Poison); break; case HexItemType.FakeTreasureItem: AddItem(HexItemType.FakeTreasure, myUnit.Location); SendItem(HexItemType.FakeTreasure, myUnit); break; case HexItemType.Change: grid.changeUnits(); HexMapCamera.SetPosition(myUnit.Location); SendEffect(HexItemType.Change); break; } }