public void init() { initialised = false; map = FindObjectOfType <CreateMap>(); if (x > 0 && y > 0 && x < map.sizeX - 1 && y < map.sizeY - 1) { //1e rij neighbors[0, 0] = map.level[x - 1, y - 1]; neighbors[1, 0] = map.level[x - 0, y - 1]; neighbors[2, 0] = map.level[x + 1, y - 1]; //2e rij neighbors[0, 1] = map.level[x - 1, y]; //zelf moet null zijn neighbors[2, 1] = map.level[x + 1, y]; //3e rij neighbors[0, 2] = map.level[x - 1, y + 1]; neighbors[1, 2] = map.level[x - 0, y + 1]; neighbors[2, 2] = map.level[x + 1, y + 1]; } initialised = true; }
public void GenerateChunk() { int[,] temp = new int[XSize, YSize]; for (int x = 0; x < XSize; x++) { for (int y = 0; y < YSize; y++) { int num = Random.Range(0, 100); if (num >= 35) { num = 3; } else if (num > 25) { num = 0; } else { num = 1; } temp[x, y] = num; } } temp = CreateMap.CellularAutomata(temp, XSize, YSize, 0, 2, 1, true); int cnt = 0; foreach (Chunk chunk in Chunks) { chunk.GenerateTile((eGeoType)temp[cnt % XSize, cnt / XSize]); cnt++; } }
void Start() { ownerId = 1; sr = GetComponent<SpriteRenderer> (); _createmap = GetComponentInParent<CreateMap> (); offsetPosition = new Vector3 (0, 0, 9f); }
// Start is called before the first frame update void Start() { grassCanGo = new List <Tile>(); createMap = GameObject.FindGameObjectWithTag("GameController").GetComponent <CreateMap>(); spawnHumanCD = new Cooldown(timeToSpawnHuman); spawnHumanCD.Start(); transformToCityCD = new Cooldown(timeToTransformToCity); transformToCityCD.Stop(); spriteRender = GetComponent <SpriteRenderer>(); transform.rotation = Quaternion.Euler(new Vector3(transform.rotation.x, transform.rotation.y + 180, transform.rotation.z)); if (desert.Length > 0) { rnd = (int)Random.Range(0, desert.Length); spriteRender.material = desert[rnd]; } else { spriteRender.color = Color.yellow; } }
static void Main() { CreateMap.Start(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainFrm()); }
public AutomapperConfig() { CreateMap <Fornecedor, FornecedorViewModel> .ReverseMap(); CreateMap <Endereco, EnderecoViewModel> .ReverseMap(); CreateMap <Produto, ProdutoViewModel> .ReverseMap(); }
public void TestMethod3() { DijkstraSource d = new DijkstraSource(); CreateMap cm = new CreateMap(); int squareSize = 10; var map = cm.CreateMapTiles(squareSize); d.FindPathThroughMap(map); }
public static void CreateMapWindow() { CreateMap Window = EditorWindow.GetWindow <CreateMap>("Create map information"); if (Window != null) { Window.Show(true); } }
// Start is called before the first frame update void Start() { canLose = new Cooldown(5f); canLose.Start(); createMap = GetComponent <CreateMap>(); pause = GetComponent <PauseController>(); score = GetComponent <Score>(); playerMovement = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovement>(); }
void OnEnable() { Camera.main.GetComponent <CameraFollow>().SetTarget(this.transform); _mapReference = GameObject.Find("MAP").GetComponent <CreateMap>(); _mapMatrixVec = _mapReference.MapMatrixVec; _newMapReference = GameObject.Find("MAP"); _playerTarget = transform.position; }
public void Create_Map() { StringBuilder sb = new StringBuilder(); int squareSize = 20; CreateMap cm = new CreateMap(); var map = cm.CreateMapTiles(squareSize); for (int i = 0; i < squareSize; i++) { for (int j = 0; j < squareSize; j++) { if (map.GetLocationType(j, i) == RTSGameMap.RTSGameMapOccupied.True) { sb.Append("#"); } else { sb.Append("."); } } Debug.WriteLine(sb.ToString()); sb.Clear(); } FindPath fp = new FindPath(); List <History> mapHistory = fp.FindPathThroughMap(map); for (int i = 0; i < squareSize; i++) { for (int j = 0; j < squareSize; j++) { if (map.GetLocationType(j, i) == RTSGameMap.RTSGameMapOccupied.True) { sb.Append("#"); } else { if (mapHistory.Where(x => x.Location.x == j && x.Location.y == i).Any()) { sb.Append("X"); } else { sb.Append("."); } } } Debug.WriteLine(sb.ToString()); sb.Clear(); } }
private void mapsConstructorToolStripMenuItem_Click(object sender, EventArgs e) //включение режима конструктора { //заполнение панели спрайтов Graphics gr = CreateMap.CreateGraphics(); gr.DrawImage(Maps.MakeSpritePanel(), 0, 0); //вывод пустой карты Maps.EmptyMap(mapArr); //загрузить в массив пустую карту Graphics gr2 = Battleground.CreateGraphics(); gr2.DrawImage(Maps.MakeMap(mapArr), 0, 0); //рисуем пустую карту }
public override void OnInspectorGUI() { base.DrawDefaultInspector(); CreateMap CM = target as CreateMap; if (GUILayout.Button("CreateMap")) { CM.GenerateMap(); } if (GUILayout.Button("DestroyMap")) { CM.DestroyMap(); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); CreateMap createMap = (CreateMap)target; if (GUILayout.Button("Restart")) { createMap.RecreateMap(); } if (GUILayout.Button("Save")) { createMap.SaveMap(); } }
public void Smoothing() { int[,] nGeo = new int[nXSize * 8, nYSize * 8]; foreach (TileData tile in TileList) { nGeo[tile.X, tile.Y] = tile.Height; } nGeo = CreateMap.CellularAutomata(nGeo, nXSize * 8, nYSize * 8, 2, 2, 4, true); foreach (TileData tile in TileList) { tile.Height = nGeo[tile.X, tile.Y]; tile.CoverDirt(); } }
public void GenerateSeed() { if (useStringSeed) { seed = stringSeed.GetHashCode(); } if (randomizeSeed) { seed = Random.Range(0, 99999); } Random.InitState(seed); mapCreator = GetComponent <CreateMap>(); }
private void Awake() { if (SharedInstance != null && SharedInstance != this) { Destroy(this.gameObject); return; } else { SharedInstance = this; } GenerateSeed(); mapCreator = GetComponent <CreateMap>(); }
// Use this for initialization void Start() { instance = this; scalefactor = 1; for (int i = 0; i <= size.x; i++) { for (int j = 0; j <= size.y; j++) { for (int k = 0; k <= size.z; k++) { //Debug.Log(k.ToString() + i.ToString() + j.ToString()); Instantiate(sphere, startSphere.transform.position + new Vector3(i * scalefactor, j * scalefactor, k * scalefactor), startSphere.rotation); } } } }
public override void OnInspectorGUI() { CreateMap voronoiDiagram = (CreateMap)target; if (DrawDefaultInspector()) { if (voronoiDiagram.autoUpdate) //if the auto button is activated { voronoiDiagram.Create(); //then Create } } if (GUILayout.Button("Create")) //if Create button in the edditor is pressed { voronoiDiagram.Create(); //then Create } }
//, AddElemento ae) public MakeMap(FileHandler fh, List<Elemento> herr, CreateMap cm) { InitializeComponent(); // Matriz = new List<Elemento>(); temMap = new Map("", 0, 0, (int)width.Value, (int)height.Value, trackBar1.Maximum); S_M = new SceneManager(); R_M = new RenderManager(); R_M.AddHandlers(new SceneHandler(S_M.PlayScene), fh); F_H = fh; temMap.SetFileManager(fh); CrearMatriz((int)height.Value,(int)width.Value,trackBar1.Value,1); temMap.Draw(new RenderHandler(R_M.AddData)); R_M.Fondo = Color.White; temp = new List<Elemento>(); Herramienta = herr; pm = new PhisicManager(); C_M = cm; }
private void Awake() { m_FoundPath = new List <Vector2Int>(); List <MapKeyData> data = new List <MapKeyData>(); foreach (MapKeyDataMono readerMono in m_MapReaderMono) { MapKeyData d = new MapKeyData(readerMono.TileType, readerMono.Prefab); data.Add(d); } m_MapReader = new MapReader(); m_CreateMap = new CreateMap(data, m_TxtFile); m_CreateMap.MapCreator(); foreach (var item in m_CreateMap.WalkablePath) { m_FoundPath.Add(new Vector2Int(item.x / 2, item.y / 2)); } m_StartPos = new Vector2Int(m_CreateMap.StartTilePos.x / 2, m_CreateMap.StartTilePos.y / 2); m_EndPos = new Vector2Int(m_CreateMap.EndTilePos.x / 2, m_CreateMap.EndTilePos.y / 2); }
static void Main(string[] args) { StringBuilder sb = new StringBuilder(); int squareSize = 64; CreateMap cm = new CreateMap(); var map = cm.CreateMapTiles(squareSize); for (int i = 0; i < squareSize; i++) { for (int j = 0; j < squareSize; j++) { if (map.GetLocationType(j, i) == RTSGameMap.RTSGameMapOccupied.True) { sb.Append("#"); } else { sb.Append("."); } } Console.WriteLine(sb.ToString()); sb.Clear(); } DijkstraSource fp = new DijkstraSource(); Stack <Coords> mapHistory = fp.FindPathThroughMap(map); while (mapHistory.Count != 0) { var t = mapHistory.Pop(); Console.SetCursorPosition(t.x, t.y); Thread.Sleep(50); Console.Write("X"); } var ff = Console.ReadLine(); }
private void PlacePlayerOnMapAndGetInfo() { if (!flag_got_map_info) { planeInfo = FindObjectOfType<Playground>().gameObject; myMapInfo = planeInfo.GetComponent<CreateMap>(); m_enemy_i = myMapInfo.getEnemies(); myGridSize = myMapInfo.getGridSize(); myLocationOfFirstCube = myMapInfo.getFirstLocationOfCube(); myMap = myMapInfo.GetMyMap(); //Reduce player size if player size is bigger than grid size Vector3 player_size = this.transform.localScale; if (player_size[0] > myGridSize[0]) player_size[0] = myGridSize[0] - myGridSize[0] / 10; if (player_size[2] > myGridSize[2]) player_size[2] = myGridSize[2] - myGridSize[2] / 10; this.transform.localScale = player_size; this.transform.position = LocateFirstAvailableSpace(myMap, myLocationOfFirstCube, myGridSize) + new Vector3(0f, transform.position[1], 0f); //+new Vector3(this.transform.localScale[0] / 2, 0f, this.transform.localScale[2] / 2); flag_got_map_info = true; } }
// Use this for initialization void Start() { _grid = GetComponent<CreateMap> (); _drawPath = GetComponent<DrawPath> (); }
// Use this for initialization void Start() { m_aCreateMap = GetComponent <CreateMap>(); }
IEnumerator setUpMap() { if (DataSaver.instance.mapExists(mapName) && !makeNewMap) { CreateMap create = new CreateMap(false, length, xSize, zSize, mapName); while (create.totalNodes == 0) { yield return(null); } //Debug.Log("Total nodes: " + create.totalNodes); //Debug.Log("Created nodes: " + create.createdNodes); while (!create.mapIsReady) { CameraUI.instance.progressText.text = create.createdNodes + "/" + create.totalNodes; CameraUI.instance.progressBar.value = create.createdNodes / create.totalNodes; yield return(null); } CameraUI.instance.progressText.text = create.createdNodes + "/" + create.totalNodes; CameraUI.instance.progressBar.value = create.createdNodes / create.totalNodes; nodes = create.nodes; xSize = create.xSize; zSize = create.zSize; //print("Node count: " + nodes.Length); GameObject g = Instantiate((GameObject)Resources.Load(mapName)); g.transform.position = new Vector3(xSize / 2, 0, zSize / 2); g = Instantiate(nodeMarker); g.transform.position = nodes[0, 0].position; g.transform.localScale = vLength; g = Instantiate(nodeMarker2); g.transform.position = nodes[0, nodes.GetLength(0) - 1].position; g.transform.localScale = vLength; g = Instantiate(nodeMarker3); g.transform.position = nodes[nodes.GetLength(0) - 1, 0].position; g.transform.localScale = vLength; g = Instantiate(nodeMarker2); g.transform.position = nodes[nodes.GetLength(0) - 1, nodes.GetLength(nodes.Rank - 1) - 1].position; g.transform.localScale = vLength; print("Finished loading map"); mapIsReady = true; } else { print("Making new map"); //print("Length: " + length + ", x size: " + xSize + ", Z size: " + zSize); if (xSize == 0 || zSize == 0) { xSize = 2000; zSize = 2000; } CreateMap m = new CreateMap(makeNewMap, length, xSize, zSize, mapName); while (m.totalNodes == 0) { yield return(null); } while (!m.mapIsReady) { CameraUI.instance.progressText.text = m.touchedNodes + "/" + m.totalNodes; CameraUI.instance.progressBar.value = m.touchedNodes / m.totalNodes; yield return(null); } CameraUI.instance.progressText.text = m.touchedNodes + "/" + m.totalNodes; CameraUI.instance.progressBar.value = m.touchedNodes / m.totalNodes; nodes = m.nodes; //print("Node count: " + nodes.Length); GameObject g = Instantiate(nodeMarker); g.transform.position = nodes[0, 0].position; g.transform.localScale = vLength; g = Instantiate(nodeMarker2); g.transform.position = nodes[0, nodes.GetLength(0) - 1].position; g.transform.localScale = vLength; g = Instantiate(nodeMarker3); g.transform.position = nodes[nodes.GetLength(0) - 1, 0].position; g.transform.localScale = vLength; g = Instantiate(nodeMarker2); g.transform.position = nodes[nodes.GetLength(0) - 1, nodes.GetLength(nodes.Rank - 1) - 1].position; g.transform.localScale = vLength; //Save map mapData mData = new mapData(); nodeData[,] data = new nodeData[(int)(xSize * (1 / length)), (int)(zSize * (1 / length))]; for (int i = 0; i < (xSize * (1 / length)); i++) { for (int j = 0; j < (zSize * (1 / length)); j++) { nodeData n = new nodeData(); n.populate(nodes[i, j]); data[i, j] = n; } yield return(null); } mData.mName = mapName; mData.mapNodes = data; mData.xSize = xSize; mData.zSize = zSize; mData.nodeLength = length; //DataSaver.instance.saveMap(mData); mapIsReady = true; print("Finished making and saving map"); } }
// Update is called once per frame void Update() { // m_Agent.destination = TragetPos; if (!updated_env) { myMapInfo = FindObjectOfType<CreateMap>(); mPlayerInfo = FindObjectOfType<PlayerController>(); myGridSize = myMapInfo.getGridSize(); myLocationOfFirstCube = myMapInfo.getFirstLocationOfCube(); myMap = myMakeCopyOf(myMapInfo.GetMyMap()); int rand_col = UnityEngine.Random.Range((int)0, (int)2); transform.position = myFindFirstRandomPlace(myMap, myLocationOfFirstCube, myGridSize, mPlayerInfo.transform.position, rand_col) + new Vector3(0f, transform.position[1], 0f); setTargetPos(transform.position - new Vector3(0f, this.transform.position[1], 0f), false); updated_env = true; } flag_hit_player = false; if (EnemyType == myEnemyType.NotFollowingPlayer) { float threshold = Mathf.Abs(EnemySpeed); bool flag_find_new_target = false; if ((this.transform.position - new Vector3(0.0f, transform.position[1], 0.0f) - TragetPos).magnitude < threshold) { flag_find_new_target = true; } else if (myUpdatedPath != null) { if (myUpdatedPath.Count == 0) { flag_find_new_target = true; } } if (flag_find_new_target) { int rand_pos = UnityEngine.Random.Range((int)0, (int)2); if (rand_pos == 0) TragetPos = myFindRandomPlace(myMap, myLocationOfFirstCube, myGridSize, true) + new Vector3(0f, transform.position[1], 0f); else TragetPos = myFindRandomPlace(myMap, myLocationOfFirstCube, myGridSize, false) + new Vector3(0f, transform.position[1], 0f); flag_update_path = true; } } if (flag_update_path) { if (EnemyType == myEnemyType.FollowingPlayer) { setTargetPos(FindObjectOfType<PlayerController>().transform.position, true);//get position of the agent } else { setTargetPos(TragetPos, false); } Vector3 pos1 = mPosToMapIndex(transform.position, myLocationOfFirstCube, myGridSize); pos1[0] = Mathf.Round(pos1[0]); pos1[2] = Mathf.Round(pos1[2]); Vector3 pos2 = TragetPos; myUpdatedPath = mFindPath(pos1, pos2, myUpdatedPath); flag_update_path = false; } if (EscapeTileBombPos[1] >= 0) { Vector3 dis_player_bomb = transform.position - EscapeTileBombPos; if (!(Mathf.Abs(dis_player_bomb[0]) < myGridSize[0] && Mathf.Abs(dis_player_bomb[2]) < myGridSize[2])) { EscapeTileBombPos[1] = -1; } } mMoveOnThePath(myUpdatedPath, myLocationOfFirstCube, myGridSize); checkBombHitEnemy(); }
void OnEnable() { MapProperty = (CreateMap)target; mGrid = serializedObject.FindProperty("Grid"); mRow = serializedObject.FindProperty("i_Row"); mColumn = serializedObject.FindProperty("i_Column"); mRect = serializedObject.FindProperty("Rect"); MapProperty.gameObject.tag = "EditorTool"; }
// Update is called once per frame void Update() { if (!updated_env) { myMapInfo = FindObjectOfType<CreateMap>(); myGridSize = myMapInfo.getGridSize(); myLocationOfFirstCube = myMapInfo.getFirstLocationOfCube(); myMap = myMakeCopyOf(myMapInfo.GetMyMap()); int rand_col = UnityEngine.Random.Range((int)0, (int)2); this.transform.localScale = new Vector3(myGridSize[0]/2, this.transform.localScale[1], myGridSize[2]/2); transform.position = myFindFirstRandomPlace(myMap, myLocationOfFirstCube, myGridSize, rand_col) + new Vector3(0f, transform.position[1], 0f); setTargetPos(transform.position - new Vector3(0f, this.transform.position[1], 0f), false); updated_env = true; } if (EnemyType == myEnemyType.NotFollowingPlayer) { float threshold = Mathf.Abs(EnemySpeed); bool flag_find_new_target = false; if ((this.transform.position - new Vector3(0.0f, transform.position[1], 0.0f) - TragetPos).magnitude < threshold) { flag_find_new_target = true; } else if (myUpdatedPath != null) { if (myUpdatedPath.Count == 0) { flag_find_new_target = true; } } if (flag_find_new_target) { int rand_pos = UnityEngine.Random.Range((int)0, (int)2); if (rand_pos == 0) TragetPos = myFindRandomPlace(myMap, myLocationOfFirstCube, myGridSize, true) + new Vector3(0f, transform.position[1], 0f); else TragetPos = myFindRandomPlace(myMap, myLocationOfFirstCube, myGridSize, false) + new Vector3(0f, transform.position[1], 0f); flag_update_path = true; } } if (flag_update_path) { if (EnemyType == myEnemyType.FollowingPlayer) { } else { setTargetPos(TragetPos, false); } Vector3 pos1 = mPosToMapIndex(transform.position, myLocationOfFirstCube, myGridSize); pos1[0] = Mathf.Round(pos1[0]); pos1[2] = Mathf.Round(pos1[2]); Vector3 pos2 = TragetPos; myUpdatedPath = mFindPath(pos1, pos2, myUpdatedPath); flag_update_path = false; } mMoveOnThePath(myUpdatedPath, myLocationOfFirstCube, myGridSize); }
protected override void LoadContent() { font = Content.Load<SpriteFont>("Content/MS20"); sprite = new SpriteBatch(GraphicsDevice); cpu = new CPU(Gm.GraphicsDevice, sprite, mapa, eneLv); blast = new Unit(Gm.GraphicsDevice, sprite, unimap ); cmap = new CreateMap(Gm.GraphicsDevice, sprite); Tgazo = Content.Load<Texture2D>("Content/sampgame"); gazo2 = Content.Load<Texture2D>("Content/sampgame2"); for (int i = 0; i < 10; i++) { using (Stream stream = File.OpenRead("img/no" + i + ".png")) { noimg[i] = Texture2D.FromStream(GraphicsDevice , stream); } } Stream s1= File.OpenRead("img/luM.png"); uni1 = Texture2D.FromStream(GraphicsDevice, s1); Stream s11 = File.OpenRead("img/luM.png"); uni3 = Texture2D.FromStream(GraphicsDevice, s11); Stream s12 = File.OpenRead("img/luM.png"); uni4 = Texture2D.FromStream(GraphicsDevice, s12); Stream s13 = File.OpenRead("img/luM.png"); uni5 = Texture2D.FromStream(GraphicsDevice, s13); Stream s14 = File.OpenRead("img/luM.png"); uni6 = Texture2D.FromStream(GraphicsDevice, s14); Stream s15 = File.OpenRead("img/luM.png"); uni7 = Texture2D.FromStream(GraphicsDevice, s15); Stream s2 = File.OpenRead("img/boM.png"); uni2 = Texture2D.FromStream(GraphicsDevice, s2); Stream s4 = File.OpenRead("img/lvup.png"); me3 = Texture2D.FromStream(GraphicsDevice, s4); Stream s42 = File.OpenRead("img/sale.png"); me32 = Texture2D.FromStream(GraphicsDevice, s42); Stream s5 = File.OpenRead("img/lvup2.png"); me4 = Texture2D.FromStream(GraphicsDevice, s5); Stream s6 = File.OpenRead("img/unitmen.png"); me5 = Texture2D.FromStream(GraphicsDevice, s6); base.LoadContent(); }
// Update is called once per frame void Update() { if (!updated_env) { myMapInfo = FindObjectOfType <CreateMap>(); myGridSize = myMapInfo.getGridSize(); myLocationOfFirstCube = myMapInfo.getFirstLocationOfCube(); myMap = myMakeCopyOf(myMapInfo.GetMyMap()); int rand_col = UnityEngine.Random.Range((int)0, (int)2); this.transform.localScale = new Vector3(myGridSize[0] / 2, this.transform.localScale[1], myGridSize[2] / 2); transform.position = myFindFirstRandomPlace(myMap, myLocationOfFirstCube, myGridSize, rand_col) + new Vector3(0f, transform.position[1], 0f); setTargetPos(transform.position - new Vector3(0f, this.transform.position[1], 0f), false); updated_env = true; } if (EnemyType == myEnemyType.NotFollowingPlayer) { float threshold = Mathf.Abs(EnemySpeed); bool flag_find_new_target = false; if ((this.transform.position - new Vector3(0.0f, transform.position[1], 0.0f) - TragetPos).magnitude < threshold) { flag_find_new_target = true; } else if (myUpdatedPath != null) { if (myUpdatedPath.Count == 0) { flag_find_new_target = true; } } if (flag_find_new_target) { int rand_pos = UnityEngine.Random.Range((int)0, (int)2); if (rand_pos == 0) { TragetPos = myFindRandomPlace(myMap, myLocationOfFirstCube, myGridSize, true) + new Vector3(0f, transform.position[1], 0f); } else { TragetPos = myFindRandomPlace(myMap, myLocationOfFirstCube, myGridSize, false) + new Vector3(0f, transform.position[1], 0f); } flag_update_path = true; } } if (flag_update_path) { if (EnemyType == myEnemyType.FollowingPlayer) { } else { setTargetPos(TragetPos, false); } Vector3 pos1 = mPosToMapIndex(transform.position, myLocationOfFirstCube, myGridSize); pos1[0] = Mathf.Round(pos1[0]); pos1[2] = Mathf.Round(pos1[2]); Vector3 pos2 = TragetPos; myUpdatedPath = mFindPath(pos1, pos2, myUpdatedPath); flag_update_path = false; } mMoveOnThePath(myUpdatedPath, myLocationOfFirstCube, myGridSize); }
private void Awake() { Instance = this; }
void Awake() { G_State = GameObject.Find("Game_Manager").GetComponent <Game_State>(); Map = GameObject.Find("MapCreator").GetComponent <CreateMap>(); }
// public InputField indexText; //used for test void Start() { m = new Material (shader); g = new GameObject("g"); lineNow = 0; isNewLine = true; GameObject go = GameObject.Find("MapController"); _createMap = go.GetComponent<CreateMap> (); Debug.Log ("未考虑怪物不能走斜线的问题"); }