//set the node's information relevant to the cube type, then send the Transform information to the cube void SetCubeInfo(_CubeBase cube, CubeLayers cubeLayers, CubeTypes cubeTypes, bool _static) { cube.myIndex = currentNode.nodeIndex; cube.myCubeType = cubeTypes; cube.myCubeLayer = cubeLayers; cube.isStatic = _static; cube.facingDirection = currentNode.facingDirection; //sets rotation and position according to the values of the relevant node in kuboGrid cube.OnLoadSetTransform(); }
public void PlaceCube(CubeTypes cubeType, int x, int z, int minQty, int maxQty) { x = Mathf.Clamp(x, 0, Width - 1); z = Mathf.Clamp(z, 0, Depth - 1); Grid[x][z] = cubeType; RessourceQuantity[x][z] = UnityEngine.Random.Range(minQty, maxQty); if (GameObjectsGrid[x][z] != null) { UpdateGameObjectAt(x, z); } }
public bool IsCubeType(int x, int z, CubeTypes cubeType) { if (x < 0 || x >= Width) { return(false); } if (z < 0 || z >= Depth) { return(false); } return(Grid[x][z] == cubeType); }
private void Awake() { if (_instance != null && _instance != this) { Destroy(this); } else { _instance = this; } currentCube = CubeTypes.FullStaticCube; }
private void SelectCubeType() { cubeTypes = new string[(int)CubeTypes.ChaosBall + 1]; for (int i = 1; i <= (int)CubeTypes.ChaosBall; i++) { cubeTypesLength = (CubeTypes)i; cubeTypes[i] = cubeTypesLength.ToString(); } cubeTypeIndex = EditorGUI.Popup(new Rect(0, 40, position.width, 20), "Cube Type : ", cubeTypeIndex, cubeTypes); LevelEditor.instance.currentCube = (CubeTypes)cubeTypeIndex; }
private void GenerateSpots(CubeTypes cubeType, CubeTypes paddingType, int minRadius, int maxRadius, int spotPercent, int minQty, int maxQty) { var averageRadius = (minRadius + maxRadius) / 2; float approxNumberOfSpots = EvaluateApproxNumberOfSpots(averageRadius, spotPercent); var spotAlgorithm = new SpotAlgorithm(map, cubeType, paddingType); spotAlgorithm.SpotMinRadius = minRadius; spotAlgorithm.SpotMaxRadius = maxRadius; for (int i = 0; i < approxNumberOfSpots; i++) { spotAlgorithm.GenerateSpot(minQty, maxQty); } }
private void DrawWindow() { GUILayout.BeginHorizontal(EditorStyles.toolbar); GUILayout.FlexibleSpace(); searchIndex = EditorGUILayout.IntField(searchIndex, EditorStyles.toolbarTextField); GUILayout.EndHorizontal(); cubeType = _Grid.instance.kuboGrid[searchIndex - 1].cubeType; cubeLayers = _Grid.instance.kuboGrid[searchIndex - 1].cubeLayers; facingDirection = _Grid.instance.kuboGrid[searchIndex - 1].facingDirection; cubeOnPosition = _Grid.instance.kuboGrid[searchIndex - 1].cubeOnPosition; worldPosition = _Grid.instance.kuboGrid[searchIndex - 1].worldPosition; }
public void FillEmptySpacesWith(CubeTypes cubeType, int minQty, int maxQty) { for (int x = 0; x < Grid.Length; x++) { for (int z = 0; z < Grid[x].Length; z++) { if (Grid[x][z] == CubeTypes.Empty) { Grid[x][z] = cubeType; RessourceQuantity[x][z] = UnityEngine.Random.Range(minQty, maxQty); } } } }
GameObject ChooseTypeToSpawn(CubeTypes cubeType){ if (cubeType == CubeTypes.Explo){ return exploCube; } else if (cubeType == CubeTypes.Implo){ return imploCube; } else if (cubeType == CubeTypes.Both){ return bothCube; } else{ return neitherCube; } }
public static CubeTypes ConvertStringToCubeType(string cubetypes) { CubeTypes cubeType = CubeTypes.None; for (int i = 0; i < (int)CubeTypes.Count; i++) { cubeType = (CubeTypes)i; if (cubeType.ToString() == cubetypes) { break; } } return(cubeType); }
public Map(int width, int depth) { this.Width = width; this.Depth = depth; Grid = new CubeTypes[width][]; GameObjectsGrid = new GameObject[width][]; RessourceQuantity = new int[width][]; for (int i = 0; i < width; i++) { Grid[i] = new CubeTypes[depth]; GameObjectsGrid[i] = new GameObject[depth]; RessourceQuantity[i] = new int[depth]; } Toons = new List <ToonScript>(); }
public void SelectPosition(int x, int z) { if (MapService.HasToonAt(x, z)) { SelectedToon = MapService.GetToonAt(x, z); } else if (SelectedToon != null) { CubeTypes type = MapService.GetCubeType(x, z); var actions = ActionService.GetActionsForCube(type, x, z); if (actions.Where(a => a.ActionType != GameActionTypes.Cancel).Any()) { HudService.UpdateMenuActions(actions); HudService.OpenMenu(); } } }
void SendInfoToCube(_CubeBase cubeBase, CubeTypes cubeType, CubeLayers cubeLayer, bool _static) { //Cube info if (cubeBase.gameObject.GetComponent <_CubeScanner>() != null) { cubeBase.facingDirection = FacingDirection.forward; } cubeBase.myIndex = GetCubeIndex(); cubeBase.isStatic = _static; cubeBase.myCubeLayer = cubeLayer; cubeBase.myCubeType = cubeType; cubeBase.gameObject.transform.position = GetCubePosition(); cubeBase.gameObject.transform.parent = grid.transform; cubeBase.SetRelevantNodeInfo(); }
private void ApplyGrassAndRoadScript(CubeTypes cubeType, GameObject gameObject) { var grassAndRoadScript = gameObject.GetComponent <GrassAndRoadScript>(); if (grassAndRoadScript == null) { return; } switch (cubeType) { case CubeTypes.Grass: grassAndRoadScript.ConvertGrass(); break; case CubeTypes.Road: grassAndRoadScript.ConvertToRoad(); break; default: break; } }
public IEnumerable <GameAction> GetActionsForCube(CubeTypes type, int x, int z) { switch (type) { case CubeTypes.Empty: break; case CubeTypes.Grass: return(GrassActions(x, z)); case CubeTypes.Ground: return(GroundActions(x, z)); case CubeTypes.Rock: return(GetRockActions(x, z)); case CubeTypes.Iron: break; case CubeTypes.Wheat: break; case CubeTypes.Tree: break; case CubeTypes.Water: break; case CubeTypes.Road: return(GetRoadActions(x, z)); default: break; } return(Enumerable.Empty <GameAction>()); }
void SetNodeInfo(GameObject newCube, int nodeIndex, Vector3 worldPosition, Vector3 worldRotation, FacingDirection facingDirection, CubeLayers cubeLayers, CubeTypes cubeTypes) { grid.kuboGrid[currentNode.nodeIndex - 1].cubeOnPosition = newCube; grid.kuboGrid[currentNode.nodeIndex - 1].nodeIndex = nodeIndex; grid.kuboGrid[currentNode.nodeIndex - 1].worldPosition = worldPosition; grid.kuboGrid[currentNode.nodeIndex - 1].worldRotation = worldRotation; grid.kuboGrid[currentNode.nodeIndex - 1].facingDirection = facingDirection; grid.kuboGrid[currentNode.nodeIndex - 1].cubeLayers = cubeLayers; grid.kuboGrid[currentNode.nodeIndex - 1].cubeType = cubeTypes; }
private void CreateGameObjectFromCubeType(CubeTypes cubeType, int x, int z) { GameObject fieldPrefab = null; GameObject overFieldPrefab = null; float overFieldHeight = 1; float zTilt = 0; float xTilt = 0; float yRotation = 0; float scale = 1; switch (cubeType) { case CubeTypes.Empty: break; case CubeTypes.Grass: fieldPrefab = grassPrefab; break; case CubeTypes.Ground: fieldPrefab = groundPrefab; break; case CubeTypes.Rock: fieldPrefab = rockPrefab; break; case CubeTypes.Iron: break; case CubeTypes.Wheat: fieldPrefab = grassPrefab; overFieldPrefab = wheatPrefab; break; case CubeTypes.Tree: fieldPrefab = groundPrefab; overFieldPrefab = treePrefab; overFieldHeight = treeHeight; zTilt = UnityEngine.Random.Range(-3f, 3f); xTilt = UnityEngine.Random.Range(-3f, 3f); yRotation = UnityEngine.Random.Range(0, 360); scale = UnityEngine.Random.Range(0.9f, 1.2f); overFieldHeight = overFieldHeight * scale; break; case CubeTypes.Water: fieldPrefab = waterPrefab; break; case CubeTypes.Road: fieldPrefab = grassPrefab; break; default: break; } if (fieldPrefab != null) { var gameObject = Instantiate(fieldPrefab); gameObject.transform.position = new Vector3(x, 0, z); ApplyGrassAndRoadScript(cubeType, gameObject); map.PlaceGameObject(gameObject, x, z); } if (overFieldPrefab != null) { var gameObject = Instantiate(overFieldPrefab); gameObject.transform.position = new Vector3(x, overFieldHeight, z); gameObject.transform.rotation = Quaternion.Euler(xTilt, yRotation, zTilt); gameObject.transform.localScale = new Vector3(scale, scale, scale); } }
public SpotAlgorithm(Map map, CubeTypes cubeType, CubeTypes paddingCubeType) { Map = map; SpotType = cubeType; PaddingType = paddingCubeType; }
public static string ConvertTypeToString(CubeTypes cubetypes) { return(cubetypes.ToString()); }
private void FillMapEmptySpots(CubeTypes cubeType, int minQty, int maxQty) { map.FillEmptySpacesWith(cubeType, minQty, maxQty); }