private void Start() { ms = GameObject.Find("EventSystem").GetComponent <MazeScript>(); red = new Color(164, 20, 20, 255) / 255.0f; green = new Color(130, 255, 130, 255) / 255.0f; gold = new Color(255, 255, 0, 255) / 255.0f; grey = new Color(0.5f, 0.5f, 0.5f, 1); }
void Start() { gM = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameControllerScript>(); map = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameControllerScript>().maze; // pick random tile, spawn player. or add this to maze gen. mazeY = map.mapHeight; InvokeRepeating("Move", 0, 0.1f); }
void MovesFull() { MazeScript scr = GameObject.Find("EventSystem").GetComponent <MazeScript>(); Member member = scr.alliance.Forces[scr.curTeam].getMember(scr.curChar); for (int i = 1; i < 5; i++) { MovesFullPanel.transform.Find("" + i).GetChild(0).GetComponent <TextMeshProUGUI>().text = "" + member.getAttackMove(i).getName(); } MovesFullPanel.SetActive(true); }
void Start() { gM = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameControllerScript>(); enemyID = gM.enemyCount; draw = gameObject.GetComponent <DirectionDebugScript>(); keyInput = 5; map = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameControllerScript>().maze; mazeY = map.mapHeight; InvokeRepeating("Move", 0, 0.1f); }
void Start() { mover = gameObject.GetComponent <EnemyMoveScript>(); gM = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameControllerScript>(); mover.aS = true; maze = gM.maze; //Calc path to player. //InvokeRepeating("AStar", 0, 0.5f); mover.direction = 7; AStar(); }
private void InitialiseBoardManager() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); mazeGenerator = GetComponent <MazeGenerator>(); generatedMaze = GetComponent <MazeScript>(); }
public void BuildMaze(int index) { if (MazeWidth < 5 || MazeHeight < 5) { MazeWidth = 5; MazeHeight = 5; } if (seed == null) { seed = "Du hast vergessen einen Seed einzugeben"; } if (index == 0) { dfsScript = gameObject.AddComponent<MazeGeneratorDFS>() as MazeGeneratorDFS; dfsScript.setVariables (XTile, ITile, LTile, DeadendTile, EndTile, StartTile, TTile, wallTile, MazeWidth, MazeHeight, seed, 1, waitTime,useRandomSeed); dfsScript.BuildMaze(); /* if(Application.isPlaying) { Destroy(dfsScript); } else { DestroyImmediate(dfsScript); } */ } else if (index == 1) { primScript = gameObject.AddComponent<PrimsAlgorithm>() as PrimsAlgorithm; primScript.setVariables (XTile, ITile, LTile, DeadendTile, EndTile, StartTile, TTile, wallTile, MazeWidth, MazeHeight, seed, timeToWait, useRandomSeed); if(Application.isPlaying) { if(waitTime) { primScript.mainProgramWithWaitingTime(); }else { primScript.mainProgramWithoutWaitingTime(); } } else { primScript.mainProgramWithoutWaitingTime(); } } else if(index == 2) { kruskalScript = gameObject.AddComponent<MazeScript>() as MazeScript; kruskalScript.setVariables(XTile,ITile,LTile,DeadendTile,EndTile,StartTile,TTile,wallTile,MazeWidth,MazeHeight,seed,timeToWait,useRandomSeed); if(!Application.isPlaying) { kruskalScript.test(false); } else kruskalScript.test(waitTime); } }
public void sellAction(Button button) { if (messageRoutine != null) { StopCoroutine(messageRoutine); } if (sellButton.name == "Sell") { messageRoutine = StartCoroutine(PurchaseMessage("Select an option!")); return; } num = int.Parse(button.name); MazeScript scr = GameObject.Find("EventSystem").GetComponent <MazeScript>(); if (shopItems[num].getItem() == null) { return; } if (shopItems[num].getItem() is int) { if (amount.text == "" || amount.text == null) { messageRoutine = StartCoroutine(PurchaseMessage("Choose an amount to sell!")); return; } if (shopItems[num].getName() == "Wood" && scr.alliance.Wood >= (int)shopItems[num].getItem() * int.Parse(amount.text)) { scr.alliance.Wood -= (int)shopItems[num].getItem() * int.Parse(amount.text); GameObject.Find("Canvas").transform.Find("OutOfBattleGUI").Find("CharPics").Find("TeamStats").Find("Wood").GetChild(0).GetComponent <TextMeshProUGUI>().text = "" + scr.alliance.Wood; } else if (shopItems[num].getName() == "Iron" && scr.alliance.Iron >= (int)shopItems[num].getItem() * int.Parse(amount.text)) { scr.alliance.Iron -= (int)shopItems[num].getItem() * int.Parse(amount.text); GameObject.Find("Canvas").transform.Find("OutOfBattleGUI").Find("CharPics").Find("TeamStats").Find("Iron").GetChild(0).GetComponent <TextMeshProUGUI>().text = "" + scr.alliance.Iron; } else { messageRoutine = StartCoroutine(PurchaseMessage("You don't have enough resources")); return; } int amountGained = (int)(shopItems[num].getPrice() * int.Parse(amount.text) * 0.70f); scr.alliance.Forces[scr.curTeam].getMember(scr.curChar).addGold((int)(shopItems[num].getPrice() * int.Parse(amount.text) * 0.70f)); GameObject.Find("Canvas").transform.Find("OutOfBattleGUI").Find("CharPics").Find("TeamStats").Find("Cash").Find("Value").GetComponent <TextMeshProUGUI>().text = "" + scr.alliance.Cash; } }
public void MovesFullChoice(Button button) { MazeScript scr = GameObject.Find("EventSystem").GetComponent <MazeScript>(); Member member = scr.alliance.Forces[scr.curTeam].getMember(scr.curChar); if (shopItems[num].getClass() != member.GetClass() && shopItems[num].getClass() != Class.None) { messageRoutine = StartCoroutine(PurchaseMessage("Your current character can't learn this move")); return; } int temp = int.Parse(button.name); member.removeAttackMove(temp); member.addAttackMove(boughtMove); scr.alliance.Cash -= boughtMovePrice; GameObject.Find("Canvas").transform.Find("OutOfBattleGUI").Find("CharPics").Find("TeamStats").Find("Cash").Find("Value").GetComponent <TextMeshProUGUI>().text = "" + scr.alliance.Cash; }
// Use this for initialization void Start() { if (m_Instance == null) { m_Instance = this; DontDestroyOnLoad(m_Instance); } else if (m_Instance != this) { Destroy(gameObject); } m_MazeWallHolder = new GameObject(); m_MazeWallHolder.name = "Maze"; m_WallneighborLength = m_MazeWall.transform.localScale.x; CreateMaze(); }
void Start() { mazeScript = gameObject.GetComponent <MazeScript>(); }
private void Start() { mover = gameObject.GetComponent <EnemyMoveScript>(); behind = 4; map = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameControllerScript>().maze; }
public void buyAction(Button button) { if (messageRoutine != null) { StopCoroutine(messageRoutine); } if (buyButton.name == "Buy") { messageRoutine = StartCoroutine(PurchaseMessage("Select an option!")); return; } num = int.Parse(button.name); MazeScript scr = GameObject.Find("EventSystem").GetComponent <MazeScript>(); if (shopItems[num].getItem() == null) { return; } int totalPrice = shopItems[num].getPrice(); int itemAmount = 1; if (shopItems[num].getItem() is int && amount.gameObject.activeSelf) { if (amount.text == "") { messageRoutine = StartCoroutine(PurchaseMessage("You have to choose an amount to buy")); return; } itemAmount = int.Parse(amount.text); totalPrice += itemAmount; } if (scr.alliance.Cash >= totalPrice) { if (shopItems[num].getItem() is AttackMove) { if (shopItems[num].getClass() != scr.alliance.Forces[scr.curTeam].getMember(scr.curChar).GetClass() && shopItems[num].getClass() != Class.None) { messageRoutine = StartCoroutine(PurchaseMessage("Your current character can't learn this move")); return; } int ind; ind = GameObject.Find("EventSystem").GetComponent <MazeScript>().giveAttackMove(shopItems[num].getItem() as AttackMove); if (ind != -1) { scr.alliance.Cash -= totalPrice; } else { boughtMove = shopItems[num].getItem() as AttackMove; boughtMovePrice = totalPrice; MovesFull(); } } else if (shopItems[num].getItem() is Class) { int type = (int)shopItems[num].getItem(); if (amount.text == "") { messageRoutine = StartCoroutine(PurchaseMessage("You have to choose a team to add to")); return; } int teamAdd = int.Parse(amount.text); if (teamAdd > Stats.numberOfTeams - 1 || teamAdd < 0) { amount.text = ""; return; } if (scr.alliance.Forces[teamAdd].numberMems < 4) { scr.alliance.Forces[teamAdd].addMember((Class)type); scr.alliance.Cash -= totalPrice; if (teamAdd == scr.curTeam) { scr.updateCharPic(teamAdd); } } else { messageRoutine = StartCoroutine(PurchaseMessage("Your team is full!")); } } else if (shopItems[num].getItem() is int) { if (shopItems[num].getName() == "Wood") { scr.alliance.Wood += (int)shopItems[num].getItem() * itemAmount; GameObject.Find("Canvas").transform.Find("OutOfBattleGUI").Find("CharPics").Find("TeamStats").Find("Wood").GetChild(0).GetComponent <TextMeshProUGUI>().text = "" + scr.alliance.Wood; } else if (shopItems[num].getName() == "Iron") { scr.alliance.Iron += (int)shopItems[num].getItem() * itemAmount; GameObject.Find("Canvas").transform.Find("OutOfBattleGUI").Find("CharPics").Find("TeamStats").Find("Iron").GetChild(0).GetComponent <TextMeshProUGUI>().text = "" + scr.alliance.Iron; } else if (scr.alliance.Forces[scr.curTeam].getMember(scr.curChar).getHealth() < scr.alliance.Forces[scr.curTeam].getMember(scr.curChar).getHealthCap()) { scr.alliance.Forces[scr.curTeam].heal((int)shopItems[num].getItem(), scr.curChar); } else { messageRoutine = StartCoroutine(PurchaseMessage("Health is already full!")); return; } scr.alliance.Cash -= totalPrice; } GameObject.Find("Canvas").transform.Find("OutOfBattleGUI").Find("CharPics").Find("TeamStats").Find("Cash").Find("Value").GetComponent <TextMeshProUGUI>().text = "" + scr.alliance.Cash; } else { messageRoutine = StartCoroutine(PurchaseMessage("Not enough money in vault to purchase!")); } }
public void RecreateMaze() { Destroy(GameObject.FindGameObjectWithTag("Player")); enemyCount = 0; //clear maze GameObject[] cubes = GameObject.FindGameObjectsWithTag("Cube"); for (int c = 0; c < cubes.Length; c++) { GameObject.Destroy(cubes[c]); } // max limit if (IsUI) { InputField inpX = GameObject.FindGameObjectWithTag("X").GetComponent <InputField>(); InputField inpY = GameObject.FindGameObjectWithTag("Y").GetComponent <InputField>(); int w = 0; int h = 0; int.TryParse(inpX.text, out w); int.TryParse(inpY.text, out h); if (w > 255) { w = 255; } if (h > 255) { h = 255; } width = (byte)w; height = (byte)h; maze = new MazeScript(width, height); WallRemove(); width = maze.mapWidth; height = maze.mapHeight; inpX.text = "" + width; inpY.text = "" + height; } else { int w = width; int h = height; if (w > 255) { w = 255; } if (h > 255) { h = 255; } width = (byte)w; height = (byte)h; // actually generating maze. maze = new MazeScript(width, height); WallRemove(); width = maze.mapWidth; height = maze.mapHeight; } for (int y = 0; y < maze.mapHeight; y++) { for (int x = 0; x < maze.mapWidth; x++) { maze.mapString += maze.mapArray[x, y]; } maze.mapString += System.Environment.NewLine; //"\n" //https://stackoverflow.com/questions/12826760/printing-2d-array-in-matrix-format } Debug.Log(maze.mapString); floor.transform.localScale = new Vector3(maze.mapWidth, 1, maze.mapHeight); floor.transform.position = new Vector3(maze.mapWidth / 2, -0.5f, -maze.mapHeight / 2); cam.transform.position = new Vector3(maze.mapWidth / 2, 20, -maze.mapHeight / 2); if (maze.mapHeight > maze.mapWidth) { cam.GetComponent <Camera>().orthographicSize = (maze.mapHeight / 2) + 1; } else { cam.GetComponent <Camera>().orthographicSize = (maze.mapWidth / 2) + 1; } cubeCount = 0; for (int y = 0; y < maze.mapHeight; y++) { for (int x = 0; x < maze.mapWidth; x++) { if (maze.mapArray[x, y] != 0) { Instantiate(cube, new Vector3(x, 0.5f, -y), Quaternion.identity); cubeCount += 1; } } } if (cubeCount >= (maze.mapWidth * maze.mapHeight) - 5) { RecreateMaze(); Debug.Log("FullMaze Fixed"); } SpawnPlayer(); GameObject[] plist = GameObject.FindGameObjectsWithTag("Enemy"); for (int c = 0; c < plist.Length; c++) { GameObject.Destroy(plist[c]); } if (SpawnEnemies == true) { for (int e = 1; e < Enemy.Length; e++) { SpawnEnemy(e); } } //reset spawn markers for (int y = 0; y < maze.mapHeight; y++) { for (int x = 0; x < maze.mapWidth; x++) { if (maze.mapArray[x, y] == 3) { maze.mapArray[x, y] = 0; } } } }