public static void saveBlank(LevelBlank _blank, Vector3 _cursor, int x, int y) { Vector3 startPos = _cursor; _blank.set(x, y); for (int i = 0; i < _blank.yLength; i++) { Vector3 r = startPos - Vector3.forward * 2; for (int j = 0; j < _blank.xLength; j++) { RaycastHit _hit; if (Physics.Linecast(r, r + Vector3.forward * 10, out _hit)) { if (_hit.transform.gameObject.layer == 8) { _blank.addBlock( (int)(_hit.transform.position.x - _cursor.x), (int)(_hit.transform.position.y - _cursor.y), _hit.transform.GetComponent <BlockObject> ().id); } else if (_hit.transform.gameObject.layer == 10) { _blank.addEnemy( (int)(_hit.transform.position.x - _cursor.x), (int)(_hit.transform.position.y - _cursor.y), _hit.transform.GetComponent <EnemyObject> ().id); } } r += Vector3.right; } startPos -= Vector3.up; } }
public void createBlankNoTimer() { Transform parent = Instantiate(emptyGM, cursor, Quaternion.identity).transform; Vector3 r = cursor; LevelBlank lb = blank; for (int i = 0; i < lb.fields.Count; i++) { Block b = blank.fields [i]; GameObject go = Instantiate(b.prefab, new Vector3(r.x + b.x, r.y + b.y, 0), b.prefab.transform.rotation, parent); //checkPlaceForIdol (go.transform.position); BlockObject.count++; go.GetComponent <BlockObject> ().index = BlockObject.count; Debug.Log(go.GetComponent <BlockObject> ().index); createdBlock.Add(go.GetComponent <BlockObject> ()); } for (int i = 0; i < lb.enemies.Count; i++) { Enemy e = blank.enemies [i]; GameObject go = Instantiate(e.prefab, new Vector3(r.x + e.x, r.y + e.y, 0), Quaternion.identity, parent); EnemyObject.count++; go.GetComponent <EnemyObject> ().index = EnemyObject.count; createdEnemies.Add(go.GetComponent <EnemyObject> ()); } cursor -= Vector3.up * (blank.yLength - 1); }
public static void CreateMyAsset() { LevelBlank asset = ScriptableObject.CreateInstance <LevelBlank>(); AssetDatabase.CreateAsset(asset, "Assets/NewScripableObject.asset"); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = asset; }
public static void createBlankNoTimer(LevelBlank _blank, Vector3 _cursor, GameObject _emptyGM) { Transform parent = Instantiate(_emptyGM, _cursor, Quaternion.identity).transform; Vector3 r = _cursor; LevelBlank lb = _blank; for (int i = 0; i < lb.fields.Count; i++) { Block b = _blank.fields [i]; Instantiate(b.prefab, new Vector3(r.x + b.x, r.y + b.y - 1, 0), Quaternion.identity).transform.parent = parent; } }
IEnumerator createRow(float delay) { Transform parent = Instantiate(emptyGM, cursor, Quaternion.identity).transform; Vector3 r = cursor; LevelBlank _blank = blank; for (int i = 0; i < _blank.fields.Count; i++) { Block b = _blank.fields [i]; GameObject go = Instantiate(b.prefab, new Vector3(r.x + b.x, r.y + b.y, 0), b.prefab.transform.rotation, parent); if (b.prefab.gameObject.tag != "Spike") { checkPlaceForIdol(go); } if (BlockObject.count % BlockList.instance.spawnChestRate == 0) { checkPlaceChest = true; } if (checkPlaceChest) { checkPlaceForChest(go); } BlockObject.count++; go.GetComponent <BlockObject> ().index = BlockObject.count; createdBlock.Add(go.GetComponent <BlockObject> ()); yield return(new WaitForSeconds(delay)); //yield return new WaitForEndOfFrame(); } for (int i = 0; i < _blank.enemies.Count; i++) { Enemy e = _blank.enemies [i]; GameObject go = Instantiate(e.prefab, new Vector3(r.x + e.x, r.y + e.y, 0), Quaternion.identity, parent); EnemyObject.count++; go.GetComponent <EnemyObject> ().index = EnemyObject.count; createdEnemies.Add(go.GetComponent <EnemyObject> ()); } yield break; }