public CaseData(GV.BATTLEFIELDTYPE bType, GV.CASETYPES cType, Vector3 position, float height) { this.bType = (int)bType; this.cType = (int)cType; this.position = position; this.height = height; }
public Case(GV.BATTLEFIELDTYPE bType, GV.CASETYPES cType, Vector3 position, float height, GameObject parent) { #region DummyManager if (cType == GV.CASETYPES.DUMMY) { Debug.Log("Auto generated case"); restart: switch (bType) { case GV.BATTLEFIELDTYPE.DUMMY: Debug.LogError("Shouldn't be dummy here"); bType = Utils.Instance.GetRandomEnum <GV.BATTLEFIELDTYPE>(1); goto restart; case GV.BATTLEFIELDTYPE.Desert: cType = GenerateDesertCase(); break; case GV.BATTLEFIELDTYPE.Temper: cType = GenerateMediumCase(); break; case GV.BATTLEFIELDTYPE.Ice: cType = GenerateIcedCase(); break; } } #endregion Height = height * GV._PerCaseHeight; CaseType = cType; GameObject = GameObject.Instantiate(Resources.Load <GameObject>(GV._PathToPrefabs + "BasicTile")); position.y = Height / 2; GameObject.transform.localPosition = position; GameObject.transform.localScale = new Vector3(1, Height, 1); if (cType == GV.CASETYPES.Cactus || cType == GV.CASETYPES.Fir || cType == GV.CASETYPES.Oak) { GenerateTree(cType.ToString()); GameObject.GetComponent <Renderer>().material = Resources.Load <Material>(GV._PathToMaterials + "Cases/" + DefineSrtCaseType(cType)); } else { GameObject.GetComponent <Renderer>().material = Resources.Load <Material>(GV._PathToMaterials + "Cases/" + cType.ToString()); } GameObject.transform.SetParent(parent.transform); GameObject.name = "tile_" + cType.ToString(); }
/// <summary> /// Generate a new map /// The stored way to manage maps /// </summary> /// <param name="name">Must be unique, it is the ID</param> public void CreateNewMap(string name, Vector2Int size, GV.BATTLEFIELDTYPE bType) { Map map = new Map(name, size, bType); string jmap = JsonUtility.ToJson(map); string path = "Assets/Resources/BattlefieldMaps/" + map.GetName() + ".jmap"; try { if (File.Exists(path)) { File.Delete(path); } File.WriteAllText(path, jmap); } catch (Exception e) { Debug.LogError(e.ToString()); } }
public Map(string name, Vector2Int size, GV.BATTLEFIELDTYPE type) { this.name = name; this.size = size; if (type == GV.BATTLEFIELDTYPE.DUMMY) { this.type = Utils.Instance.GetRandomEnum <GV.BATTLEFIELDTYPE>(1); } else { this.type = type; } this.battleField = new List <CaseData>(); for (int i = 0; i < size.y; i++) { for (int j = 0; j < size.x; j++) { CaseData cs = new CaseData(type, GV.CASETYPES.DUMMY, new Vector3(j, 0, -i), 1); battleField.Add(cs); } } }