public void enemyCancelHighlight() { if (selectedEnemy != null) { selectedEnemy.selected = false; selectedEnemy = null; state_selector = 0; } }
public bool isThereAnEnemyHere() { bool result = false; GameObject[] enemies = gridMaster.enemies; foreach (GameObject enemy in enemies) { enemy_parent enemycode = (enemy_parent)enemy.GetComponent(typeof(enemy_parent)); if (enemycode.thisNode.Equals(this)) { enemyInThisNode = enemycode; result = true; } } return(result); }
public void updateEnemy(enemy_parent enemy) { unitpanel.SetActive(true); displayClass.text = "" + enemy.enemyClass; displayHealth.text = enemy.health + " / " + enemy.maxHealth; displayRange.text = "Range: " + enemy.maxWalkDistance; displayExtra.text = "Atk: " + enemy.UnitPower; switch (enemy.enemyClass) { case globals.wormname: imageUnit.sprite = allsprites[6]; break; case globals.sharkname: imageUnit.sprite = allsprites[4]; break; case globals.thiefname: imageUnit.sprite = allsprites[0]; break; case globals.thief2name: imageUnit.sprite = allsprites[2]; break; case globals.bossname: imageUnit.sprite = allsprites[11]; break; case globals.nestName: imageUnit.sprite = allsprites[1]; break; case globals.unlockerName: imageUnit.sprite = allsprites[5]; break; } }
// Update is called once per frame void Update() { controls.calculate(); if (actionLocked) { return; } //---------------------------------------------------------------------------------------------------------------------------------------- switch (state_selector) { case 0: // nada seleccionado if (Input.GetButtonDown("Fire1")) { if (!cursorNode.nodeOculto && cursorNode.isThereAUnitHere()) { selectedUnit = cursorNode.unitInThisNode; if (!selectedUnit.alreadyMoved) { selectedUnit.listMovementRange(); selectedUnit.selected = true; state_selector = 1; //Debug.Log("found unit"); } else { selectedUnit = null; //Debug.Log("unit already moved"); } } else { if (!cursorNode.nodeOculto && cursorNode.isThereAnEnemyHere()) { selectedEnemy = cursorNode.enemyInThisNode; selectedEnemy.listMovementRange(); selectedEnemy.selected = true; state_selector = 1; } else { if (!cursorNode.nodeOculto && cursorNode.tiletype.Equals("HQ")) { state_selector = 6; unitHQ_code.selected = true; showCreationMenu(); } else { //Debug.Log("no unit"); } } } } //abrir menu de stage if (Input.GetButtonDown("Fire2")) { showStageMenu(); } break; //-------------------------- case 1: //unidad seleccionada if ((selectedUnit != null) && (selectedUnit.selected)) { //if (selectedUnit.checkDistanceWalk(cursorNode, selectedUnit.thisNode, selectedUnit.thisNode, 0)) { if (selectedUnit.highLightMoveableNodes(cursorNode)) { lastPath = pathToCursor; pathToCursor = pathToAlert(cursorNode, selectedUnit.thisNode, 100); if (lastPath != null) { foreach (Node pathnode in lastPath) { pathnode.pathmember = false; } } foreach (Node pathnode in pathToCursor) { pathnode.pathmember = true; } } if (Input.GetButtonDown("Fire1")) { if (selectedUnit.highLightMoveableNodes(cursorNode)) { /*Debug.Log("move here!"); * //selectedUnit.lastNode = selectedUnit.thisNode; * //selectedUnit.thisNode = this.cursorNode; * //selectedUnit.updatePosition(); * selectedUnit.nextNode = this.cursorNode; * selectedUnit.previewPosition(); * * //disengage code * selectedUnit.selected = false; * selectedUnit.alreadyMoved = true; * selectedUnit = null; * actionLocked = false; * state_selector = 0; * if (lastPath != null) { * foreach (Node pathnode in lastPath) { * pathnode.pathmember = false; * } * } * //open action menu * //actionLocked = true; * state_selector = 2;*/ //Debug.Log("move here!"); selectedUnit.nextNode = this.cursorNode; selectedUnit.previewPosition(); state_selector = 2; showBattleMenu(); } } //cancel movement if (Input.GetButtonDown("Fire2")) { battleMenuCancelHighlightMovement(); } } if ((selectedEnemy != null) && (selectedEnemy.selected)) { //cancel movement if (Input.GetButtonDown("Fire2")) { enemyCancelHighlight(); } } break; case 2: //durante este estado el menu esta abierto //cancel /*if (Input.GetButtonDown("Fire2")) { * battleMenuCancelMovement(); * }*/ break; case 3: //drill if (Input.GetButtonDown("Fire1")) { if ((selectedUnit != null) && (selectedUnit.selected)) { if (selectedUnit.checkDrillTargets(this.cursorNode, true) && this.cursorNode.nodeOculto) { this.cursorNode.revealNode(); GameObject dust = Instantiate((GameObject)Resources.Load("dust_ps")); //, cursorNode.gridPoint, Quaternion.identity, gridMaster.groupUnit dust.transform.position = new Vector3(cursorNode.gridPoint.x, cursorNode.gridPoint.y, -1); Destroy(dust, 1.0f); //disengage code selectedUnit.lastNode = selectedUnit.thisNode; selectedUnit.thisNode = selectedUnit.nextNode; if (selectedUnit.heldRelic != null) { selectedUnit.heldRelic.thisNode = selectedUnit.thisNode; } ////gridMaster.addGas(-selectedUnit.temp_gas_usage); selectedUnit.updatePosition(); selectedUnit.selected = false; selectedUnit.alreadyMoved = true; selectedUnit = null; actionLocked = false; state_selector = 0; //gridMaster.addGas(-globals.action_cost_drill); if (lastPath != null) { foreach (Node pathnode in lastPath) { pathnode.pathmember = false; } } } } } //cancel if (Input.GetButtonDown("Fire2")) { battleMenuCancelAction(); } break; case 4: //attack if (Input.GetButtonDown("Fire1")) { if ((selectedUnit != null) && (selectedUnit.selected)) { selectedUnit.savedAttackTargets = selectedUnit.listAttackNodes(); if (selectedUnit.checkAttackTargets(this.cursorNode, true) && this.cursorNode.isThereAnEnemyHere()) { enemy_parent target = this.cursorNode.enemyInThisNode; target.health -= selectedUnit.attackPower; if (target.health <= 0) { //Destroy(target.gameObject); target.getRekt(); } //disengage code selectedUnit.lastNode = selectedUnit.thisNode; selectedUnit.thisNode = selectedUnit.nextNode; if (selectedUnit.heldRelic != null) { selectedUnit.heldRelic.thisNode = selectedUnit.thisNode; } ////gridMaster.addGas(-selectedUnit.temp_gas_usage); selectedUnit.updatePosition(); selectedUnit.selected = false; selectedUnit.alreadyMoved = true; selectedUnit = null; actionLocked = false; state_selector = 0; //gridMaster.addGas(-globals.action_cost_attack); if (lastPath != null) { foreach (Node pathnode in lastPath) { pathnode.pathmember = false; } } } } } //cancel if (Input.GetButtonDown("Fire2")) { battleMenuCancelAction(); } break; case 5: //hold if (Input.GetButtonDown("Fire1")) { if ((selectedUnit != null) && (selectedUnit.selected)) { if (selectedUnit.checkHoldTargets(this.cursorNode, true) && this.cursorNode.isThereAnItemHere()) { relic targetrelic = (relic)cursorNode.itemInThisNode; selectedUnit.heldRelic = targetrelic; targetrelic.onTake(true); targetrelic.transform.position = selectedUnit.transform.position; //disengage code selectedUnit.lastNode = selectedUnit.thisNode; selectedUnit.thisNode = selectedUnit.nextNode; if (selectedUnit.heldRelic != null) { selectedUnit.heldRelic.thisNode = selectedUnit.thisNode; } ////gridMaster.addGas(-selectedUnit.temp_gas_usage); selectedUnit.updatePosition(); selectedUnit.selected = false; selectedUnit.alreadyMoved = true; selectedUnit = null; actionLocked = false; state_selector = 0; //gridMaster.addGas(-globals.action_cost_hold); if (lastPath != null) { foreach (Node pathnode in lastPath) { pathnode.pathmember = false; } } gridMaster.wakeUpStatues(); //only for wake up boss check } } } //cancel if (Input.GetButtonDown("Fire2")) { battleMenuCancelAction(); } break; case 6: //create unit //buffer state //create unit menu active break; case 7: //set created unit in place if (Input.GetButtonDown("Fire1")) { if ((unitHQ_code != null) && unitHQ_code.selected && unitHQ_code.checkCreationSpaces(this.cursorNode, true) && (create_selector != 0)) { int createcost = globals.drill_create_cost; unit_parent selected_creation_unit = gridMaster.unit_drill_prefab; switch (create_selector) { case 1: createcost = globals.drill_create_cost; selected_creation_unit = gridMaster.unit_drill_prefab; break; case 2: createcost = globals.tank_create_cost; selected_creation_unit = gridMaster.unit_tank_prefab; break; case 3: createcost = globals.scout_create_cost; selected_creation_unit = gridMaster.unit_scout_prefab; break; case 4: createcost = globals.bomb_create_cost; selected_creation_unit = gridMaster.unit_bomb_prefab; break; case 5: createcost = globals.tank_create_cost; selected_creation_unit = gridMaster.unit_armoredS_prefab; break; } if (gridMaster.recursoDinero >= 0) { //create unit unit_parent new_creation_unit = Instantiate(selected_creation_unit, new Vector3(cursorNode.gridPoint.x, cursorNode.gridPoint.y, 0), Quaternion.identity, gridMaster.groupUnit); new_creation_unit.alreadyMoved = true; gridMaster.addDinero(-createcost); gridMaster.updateActors(); //unset state unitHQ_code.selected = false; unitHQ_code.alreadyMoved = true; actionLocked = false; state_selector = 0; } } } //cancel if (Input.GetButtonDown("Fire2")) { creationMenuCancelCreation(); } break; case 8: //drop if (Input.GetButtonDown("Fire1")) { if ((selectedUnit != null) && (selectedUnit.selected)) { if (selectedUnit.checkDropTargets(cursorNode, true)) { if (cursorNode.tiletype.Equals("HQ")) { selectedUnit.heldRelic.transform.position = new Vector3(cursorNode.gridPoint.x, cursorNode.gridPoint.y, 0); selectedUnit.heldRelic.onSave(); selectedUnit.heldRelic = null; } else { selectedUnit.heldRelic.transform.position = new Vector3(cursorNode.gridPoint.x, cursorNode.gridPoint.y, 0); selectedUnit.heldRelic.onReveal(); selectedUnit.heldRelic = null; } //disengage code selectedUnit.lastNode = selectedUnit.thisNode; selectedUnit.thisNode = selectedUnit.nextNode; if (selectedUnit.heldRelic != null) { selectedUnit.heldRelic.thisNode = selectedUnit.thisNode; } ////gridMaster.addGas(-selectedUnit.temp_gas_usage); selectedUnit.updatePosition(); selectedUnit.selected = false; selectedUnit.alreadyMoved = true; selectedUnit = null; actionLocked = false; state_selector = 0; if (lastPath != null) { foreach (Node pathnode in lastPath) { pathnode.pathmember = false; } } } } } //cancel if (Input.GetButtonDown("Fire2")) { battleMenuCancelAction(); } break; case 9: //go bomb if (Input.GetButtonDown("Fire1")) { if ((selectedUnit != null) && (selectedUnit.selected)) { //this.cursorNode.revealNode(); GameObject explotion_inst = Instantiate((GameObject)Resources.Load("bomb_explotion"), selectedUnit.transform.position, Quaternion.identity, gridMaster.groupUnit); Destroy(explotion_inst, 1.0f); //GameObject dust = Instantiate((GameObject)Resources.Load("dust_ps2")); //dust.transform.position = new Vector3(selectedUnit.nextNode.gridPoint.x, selectedUnit.nextNode.gridPoint.y, -1); //Destroy(dust, 2.0f); foreach (Node nnn in selectedUnit.listBombNodes()) { if (nnn.nodeOculto) { nnn.revealNode(); } else { if (nnn.isThereAnEnemyHere()) { nnn.enemyInThisNode.health -= globals.bombExplodeStat; if (nnn.enemyInThisNode.health <= 0) { nnn.enemyInThisNode.getRekt(); } } //friendly fire off is more fun /*if (nnn.isThereAUnitHere()) { * nnn.unitInThisNode.health -= globals.bombExplodeStat; * if (nnn.unitInThisNode.health <= 0) { * nnn.unitInThisNode.getRekt(); * } * }*/ } } //disengage code selectedUnit.lastNode = selectedUnit.thisNode; selectedUnit.thisNode = selectedUnit.nextNode; if (selectedUnit.heldRelic != null) { selectedUnit.heldRelic.thisNode = selectedUnit.thisNode; } ////gridMaster.addGas(-selectedUnit.temp_gas_usage); selectedUnit.updatePosition(); selectedUnit.selected = false; selectedUnit.alreadyMoved = true; unit_parent tempunit = selectedUnit; selectedUnit = null; actionLocked = false; state_selector = 0; //gridMaster.addGas(-globals.action_cost_base_bomb); //destroy bomb tempunit.detonate(); if (lastPath != null) { foreach (Node pathnode in lastPath) { pathnode.pathmember = false; } } } } //cancel if (Input.GetButtonDown("Fire2")) { battleMenuCancelAction(); } break; case 10: //scanplace movementLocked = true; if ((selectedUnit != null) && (selectedUnit.selected) && (controls.horizontal != 0 || controls.vertical != 0)) { if (controls.horizontal == -1 && controls.vertical == 0) { selectedUnit.scanDirection = 0; selectedUnit.savedScanTargets = selectedUnit.getScanTargets2(); } if (controls.horizontal == 0 && controls.vertical == -1) { selectedUnit.scanDirection = 1; selectedUnit.savedScanTargets = selectedUnit.getScanTargets2(); } if (controls.horizontal == 1 && controls.vertical == 0) { selectedUnit.scanDirection = 2; selectedUnit.savedScanTargets = selectedUnit.getScanTargets2(); } if (controls.horizontal == 0 && controls.vertical == 1) { selectedUnit.scanDirection = 3; selectedUnit.savedScanTargets = selectedUnit.getScanTargets2(); } } if (Input.GetButtonDown("Fire1")) { if ((selectedUnit != null) && (selectedUnit.selected)) { int enemyScan = 0; int enemyStrongScan = 0; int relicScan = 0; int nestScan = 0; //disengage part 1 selectedUnit.lastNode = selectedUnit.thisNode; selectedUnit.thisNode = selectedUnit.nextNode; if (selectedUnit.heldRelic != null) { selectedUnit.heldRelic.thisNode = selectedUnit.nextNode; } ////gridMaster.addGas(-selectedUnit.temp_gas_usage); selectedUnit.updatePosition(); selectedUnit.savedScanTargets = selectedUnit.getScanTargets2(); foreach (Node nnn in selectedUnit.savedScanTargets) { if (nnn.isThereAnEnemyHere()) { if (nnn.enemyInThisNode.GetComponent <enemy_parent>().enemyClass.Equals(globals.nestName)) { nestScan++; } else { if (nnn.enemyInThisNode.GetComponent <enemy_parent>().maxHealth > 20) { enemyStrongScan++; } else { enemyScan++; } } } if (nnn.isThereAnItemHere() && !nnn.isHQhere() && (!nnn.isThereAUnitHere() || (nnn.isThereAUnitHere() && nnn.itemInThisNode.state != 2))) { relicScan++; } } state_selector = 11; //actionLocked = true; movementLocked = false; menuScanResult.gameObject.SetActive(true); menuScanResult.setValues(selectedUnit, enemyScan, enemyStrongScan, nestScan, relicScan); //Debug.Log("Enemy: " + enemyScan + "Big-Enemy: " + enemyStrongScan + " Nest: " + nestScan + " Relic: " + relicScan); //TODO //mostrar enemigos y relics contados //disengage code part 2 /*selectedUnit.selected = false; * selectedUnit = null; * actionLocked = false; * //gridMaster.addGas(-globals.action_cost_scan); * if (lastPath != null) { * foreach (Node pathnode in lastPath) { * pathnode.pathmember = false; * } * }*/ } } //cancel if (Input.GetButtonDown("Fire2")) { movementLocked = false; battleMenuCancelAction(); } break; case 11: /*if (Input.GetButtonDown("Fire1") || Input.GetButtonDown("Fire2")) { * closeScanMenu(); * }*/ break; } //Check if we have a non-zero value for horizontal or vertical int G_horizontal = 0; int G_vertical = 0; if (!movementLocked) { if (controls.horizontal != 0 || controls.vertical != 0) { G_horizontal = controls.horizontal; G_vertical = controls.vertical; //Debug.Log("horizontal: " + horizontal + " vertical: " + vertical); } if (G_horizontal == -1 && G_vertical == 0 && nextDirection(0)) { //changeIcon(); cursorNode = cursorNode.leftNode; transform.position = new Vector3(cursorNode.gridPoint.x, cursorNode.gridPoint.y, 0); //camScript.alignCamera(cursorNode, false); } if (G_horizontal == 0 && G_vertical == -1 && nextDirection(1)) { //changeIcon(); cursorNode = cursorNode.downNode; transform.position = new Vector3(cursorNode.gridPoint.x, cursorNode.gridPoint.y, 0); //camScript.alignCamera(cursorNode, false); } if (G_horizontal == 1 && G_vertical == 0 && nextDirection(2)) { //changeIcon(); cursorNode = cursorNode.rightNode; transform.position = new Vector3(cursorNode.gridPoint.x, cursorNode.gridPoint.y, 0); //camScript.alignCamera(cursorNode, false); } if (G_horizontal == 0 && G_vertical == 1 && nextDirection(3)) { //changeIcon(); cursorNode = cursorNode.upNode; transform.position = new Vector3(cursorNode.gridPoint.x, cursorNode.gridPoint.y, 0); //camScript.alignCamera(cursorNode, false); } } /*if (controls.vertical != 0 || * controls.horizontal != 0 || * Input.GetButtonDown("Fire1") || * Input.GetButtonDown("Fire2") * ) { * gridMaster.updateAllNodes(); * }*/ //updategui(); }
//Update public void Update() { nodeSquare.GetComponent <SpriteRenderer>().sprite = defaultSprite; nodeSquare.GetComponent <SpriteRenderer>().color = Color.white; /* * if (gridMaster.cursorCode.cursorNode.Equals (gridMaster.cursorCode.playerCode.playerNode)) { * if(gridMaster.cursorCode.highLightMoveableNodes(this)){ * nodeSquare.GetComponent<SpriteRenderer> ().color = Color.blue; * } * } * foreach (GameObject enemy in gridMaster.enemies) { * EnemyParent enemyCode = (EnemyParent) enemy.GetComponent(typeof(EnemyParent)); * if(enemyCode.highLightSeenNodes(this)){ * nodeSquare.GetComponent<SpriteRenderer> ().color = Color.red; * } * } * //cursor potential sound * if(gridMaster.cursorCode.highLightSoundNodes(this)){ * nodeSquare.GetComponent<SpriteRenderer> ().color = Color.green; * } * */ foreach (GameObject unit in gridMaster.units) { unit_parent unit_code = (unit_parent)unit.GetComponent(typeof(unit_parent)); if (unit_code.selected) { switch (gridMaster.selector.state_selector) { case 11: if (unit_code.checkScanTargets(this, true)) { nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite; nodeSquare.GetComponent <SpriteRenderer>().color = Color.green; } break; case 10: if (unit_code.checkScanTargets(this, true)) { nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite; nodeSquare.GetComponent <SpriteRenderer>().color = Color.green; } break; case 9: if (unit_code.checkBombTargets(this, true)) { nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite; nodeSquare.GetComponent <SpriteRenderer>().color = Color.green; } break; case 8: if (unit_code.checkDropTargets(this, true)) { nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite; nodeSquare.GetComponent <SpriteRenderer>().color = Color.green; } break; case 5: if (unit_code.checkHoldTargets(this, true)) { nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite; nodeSquare.GetComponent <SpriteRenderer>().color = Color.green; } break; case 4: if (unit_code.checkAttackTargets(this, true)) { nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite; nodeSquare.GetComponent <SpriteRenderer>().color = Color.green; } break; case 3: if (unit_code.checkDrillTargets(this, true)) { nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite; nodeSquare.GetComponent <SpriteRenderer>().color = Color.green; } break; default: if (unit_code.highLightMoveableNodes(this)) { nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite; nodeSquare.GetComponent <SpriteRenderer>().color = Color.green; } if (pathmember) { nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite; nodeSquare.GetComponent <SpriteRenderer>().color = Color.red; } break; } } } if (unitHQ_code.selected) { if (gridMaster.selector.state_selector == 7) { if (unitHQ_code.checkCreationSpaces(this, true)) { nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite; nodeSquare.GetComponent <SpriteRenderer>().color = Color.green; } } } foreach (GameObject enemy in gridMaster.enemies) { enemy_parent enemy_code = (enemy_parent)enemy.GetComponent(typeof(enemy_parent)); if (enemy_code.selected && !nodeOculto) { if (enemy_code.highLightAttackableNodes(this)) { nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite; nodeSquare.GetComponent <SpriteRenderer>().color = Color.magenta; } if (enemy_code.highLightMoveableNodes(this)) { nodeSquare.GetComponent <SpriteRenderer>().sprite = focusedSprite; nodeSquare.GetComponent <SpriteRenderer>().color = Color.red; } } } /* * if (pathmember) { * nodeSquare.GetComponent<SpriteRenderer>().sprite = focusedSprite; * nodeSquare.GetComponent<SpriteRenderer>().color = Color.red; * }*/ }
IEnumerator endTurn() { if (gamestate == 1) { playersturn = false; guimanager.enemyTurnText.gameObject.SetActive(true); selector.actionLocked = true; foreach (GameObject unit in units) { unit_parent unitscript = unit.GetComponent <unit_parent>(); unitscript.alreadyMoved = false; if (unitscript.isActive) { //this.addGas(-unitscript.basecost); this.addDinero(-unitscript.basecost); } } if (recursoDinero <= globals.gasCoinCost) { gamestate = 2; Debug.Log("game over"); yield return(null); } foreach (GameObject enemy in enemies) { enemy_parent enemyscript = enemy.GetComponent <enemy_parent>(); enemyscript.StartCoroutine("enemysturn"); while (!enemyscript.enemyDone) { //wait for enemy to finish his turn yield return(null); } } /*//allNests * foreach (GameObject oneNest in allNests) { * enemy_thief_nest nestScript = oneNest.GetComponent<enemy_thief_nest>(); * nestScript.StartCoroutine("nestTurn"); * * while (!nestScript.enemyDone) { * //wait for enemy to finish his turn * yield return null; * } * }*/ selector.actionLocked = false; yield return(null); playersturn = true; guimanager.enemyTurnText.gameObject.SetActive(false); turnCount++; } if (gamestate == 2 || gamestate == 3) { yield return(null); selector.actionLocked = true; stageResult.gameObject.SetActive(true); stageResult.setValues(gamestate, turnCount, relicsaved, relicounter, recursoDinero, recursoDineroInicial); } }
void readFile() { //leer archivo //string[] text = System.IO.File.ReadAllLines (@"Assets\MyFolder\MAP_FILES\map_grid_1.txt"); string textFile = mapFile[mapIndex].text; string[] text = textFile.Split("\n"[0]); //leer el tamaño del mapa string[] lines = text [0].Split(";"[0]); gridSizeX = Mathf.RoundToInt(int.Parse(lines[0])); gridSizeZ = Mathf.RoundToInt(int.Parse(lines[1])); if (lines.Length >= 4) { recursoDinero = Mathf.RoundToInt(int.Parse(lines[2])); recursoDineroInicial = recursoDinero; recursoGas = Mathf.RoundToInt(int.Parse(lines[3])); } if (lines.Length >= 5) { tutorialIndexForLater = Mathf.RoundToInt(int.Parse(lines[4])); Debug.Log(lines[4]); } else { tutorialIndexForLater = 0; } grid = new Node[gridSizeX, gridSizeZ]; gridWorldSize = new Vector2(gridSizeX * nodeDiameter, gridSizeZ * nodeDiameter); //ajustar tamaño del plano/piso this.transform.position = new Vector3((float.Parse(lines[0]) - 1) / 2, (float.Parse(lines[1]) - 1) / 2, -10); plane.transform.localScale = new Vector3(gridSizeX * nodeDiameter, gridSizeZ * nodeDiameter, 1); relics = new List <relic>(); relicounter = 0; relicsaved = 0; //leer cada linea del archivo for (int i = 1; i < text.Length; i++) { //leer linea y transformarla en un nodo segun coordenadas lines = text [i].Split(";"[0]); Vector2 gridPoint = new Vector2(int.Parse(lines[0]), int.Parse(lines[1])); grid[int.Parse(lines[0]), int.Parse(lines[1])] = new Node(gridPoint, lines[2], bool.Parse(lines[3]), this); if (lines[2].Contains("relic")) { relic newrelic = Instantiate(relic_prefab, new Vector3(gridPoint.x, gridPoint.y, 0), Quaternion.identity, groupItems); relicounter++; newrelic.relicID = relicounter; relics.Add(newrelic); } if (lines[2].Contains("worm")) { enemy_parent newWorm = Instantiate(enemy_worm_prefab, new Vector3(gridPoint.x, gridPoint.y, 0), Quaternion.identity, groupEnemy);//,this.transform } if (lines[2].Contains("shark")) { enemy_shark newshark = Instantiate(enemy_shark_prefab, new Vector3(gridPoint.x, gridPoint.y, 0), Quaternion.identity, groupEnemy); } if (lines[2].Contains("thief")) { enemy_thief newthief = Instantiate(enemy_thief_prefab, new Vector3(gridPoint.x, gridPoint.y, 0), Quaternion.identity, groupEnemy); } if (lines[2].Contains("nest")) { enemy_thief_nest newNest = Instantiate(enemy_nest_prefab, new Vector3(gridPoint.x, gridPoint.y, 0), Quaternion.identity, groupEnemy); } if (lines[2].Contains("keymaster")) { enemy_unlocker newLock = Instantiate(enemy_unlocker_prefab, new Vector3(gridPoint.x, gridPoint.y, 0), Quaternion.identity, groupEnemy); } if (lines[2].Contains("sphinxawake")) { enemy_sphinx newboss = Instantiate(enemy_sphinx_prefab, new Vector3(gridPoint.x, gridPoint.y, 0), Quaternion.identity, groupEnemy); } if (lines[2].Contains("START")) { unit_HQ newHQ = Instantiate(unit_HQ_prefab, new Vector3(gridPoint.x, gridPoint.y, 0), Quaternion.identity, groupUnit); newHQ.name = "unitHQ"; unitHQ_code = newHQ; } if (lines[2].Contains("DRILL")) { unit_parent startUnit = Instantiate(unit_drill_prefab, new Vector3(gridPoint.x, gridPoint.y, 0), Quaternion.identity, groupUnit); } if (lines[2].Contains("TANK")) { unit_parent startUnit = Instantiate(unit_tank_prefab, new Vector3(gridPoint.x, gridPoint.y, 0), Quaternion.identity, groupUnit); } if (lines[2].Contains("SCOUT")) { unit_parent startUnit = Instantiate(unit_scout_prefab, new Vector3(gridPoint.x, gridPoint.y, 0), Quaternion.identity, groupUnit); } if (lines[2].Contains("BOMB")) { unit_parent startUnit = Instantiate(unit_bomb_prefab, new Vector3(gridPoint.x, gridPoint.y, 0), Quaternion.identity, groupUnit); } } //conectar nodos for (int i = 0; i < gridSizeX; i++) { for (int j = 0; j < gridSizeZ; j++) { try{ grid [i, j].leftNode = grid [i - 1, j]; } catch {} try{ grid [i, j].rightNode = grid [i + 1, j]; } catch {} try{ grid [i, j].upNode = grid [i, j + 1]; } catch {} try{ grid [i, j].downNode = grid [i, j - 1]; } catch {} grid [i, j].drawmelikeafrenchgirl(); } } checkRelics();//in case of no relics end game gamestate = 1; //world set }