public void UseDistraction(Item item) { if (item.location == "visitor center") { //move warden to a visitor center position GameObject guard = GameObject.Find("GuardState").GetComponent <GuardStates>().GetRandomGuard(); guard.transform.position = HazardMovement.getRandomGuardPoint(HazardMovement.visitorCenter); guard.GetComponent <GuardMovement>().pos = guard.transform.position; guard.GetComponent <GuardMovement>().resetPosition = guard.transform.position; } else if (item.location == "infirmary") { //move warden to a infirmary center position GameObject guard = GameObject.Find("GuardState").GetComponent <GuardStates>().GetRandomGuard(); guard.transform.position = HazardMovement.getRandomGuardPoint(HazardMovement.infirmaryPoints2); guard.GetComponent <GuardMovement>().pos = guard.transform.position; guard.GetComponent <GuardMovement>().resetPosition = guard.transform.position; } else if (item.location == "kitchen") { //move warden to a kitchen position GameObject guard = GameObject.Find("GuardState").GetComponent <GuardStates>().GetRandomGuard(); guard.transform.position = HazardMovement.getRandomGuardPoint(HazardMovement.kitchenPoints); guard.GetComponent <GuardMovement>().pos = guard.transform.position; guard.GetComponent <GuardMovement>().resetPosition = guard.transform.position; } }
public void EscapeFailed(GameObject player) { //move to solitary and lose items & luck player.transform.position = HazardMovement.getRandomSolitaryPoint(); player.GetComponent <PlayerMovement>().pos = player.transform.position; player.GetComponent <PlayerMovement>().resetPosition = player.transform.position; GameObject.Find("Items").GetComponent <ItemDatabase>().totalLuck += player.GetComponent <Player>().luck; player.GetComponent <Player>().luck -= player.GetComponent <Player>().luck; GameObject.Find("Items").GetComponent <ItemDatabase>().PlayerLost(player); print("your items have been sent to the warden's office"); //end turn? }
public void MoveToInfirmary(GameObject player) { //TODO-check to see if the player has a usable item for this and then use it if (GameObject.Find("Items").GetComponent <UseItems>().HasHealthItem(player)) { GameObject.Find("Items").GetComponent <UseItems>().UseHealthItem(player); } else { player.transform.position = HazardMovement.getRandomInfirmaryPoint(); player.GetComponent <PlayerMovement>().pos = player.transform.position; player.GetComponent <PlayerMovement>().resetPosition = player.transform.position; } }
public void EncounterWarden(float x, float y) { //send player to solitary and take an item unless they have a donut GameObject player = GameController.ReturnPlayer(x, y); if (HasDonut(player) == false) { player.transform.position = HazardMovement.getRandomSolitaryPoint(); player.GetComponent <PlayerMovement>().pos = player.transform.position; player.GetComponent <PlayerMovement>().resetPosition = player.transform.position; //Move player to solitary Item itm = GameObject.Find("Items").GetComponent <ItemDatabase>().drawAndRemove( player.GetComponent <Player>().heldItems); //put an item in warden office GameObject.Find("Items").GetComponent <ItemDatabase>().PutItemInWardens(itm); print("Item has been sent to warden's office"); } else { Item donut = ReturnDonut(player); RemoveSingleItem(player, donut); //remove donut } }
public void MoveInfirmaryInstant(GameObject player) { player.transform.position = HazardMovement.getRandomInfirmaryPoint(); player.GetComponent <PlayerMovement>().pos = player.transform.position; player.GetComponent <PlayerMovement>().resetPosition = player.transform.position; }
// Update is called once per frame void Update() { if (inventoryCanvas.GetComponent <CanvasBahavior>().IsCanvasActive() && usingInventory == false) { inventoryCanvas.GetComponent <CanvasBahavior>().DeactivateInventory(); } if (instructionCanvas.GetComponent <InstructionCanvas>().IsCanvasActive() && usingInstructions == false) { instructionCanvas.GetComponent <InstructionCanvas>().HideInstructions(); } moveAmount = DiceRoll.movement; current = GameObject.Find("StateMachine").GetComponent <GameState>().GetObjectFromState(); if (GameState.currentPlayer == GetComponent <Player>().playerState) { isMyTurn = true; } else { isMyTurn = false; } inputAvailable--; //if(GameObject.Find("GuardState").GetComponent<GuardStates>().) if (GuardStates.IsGuardState()) { controllingGuard = true; } else { controllingGuard = false; } if (controllingGuard == false) { if (isMyTurn && usingInventory != true && usingInstructions != true) { if (inputAvailable <= 0 && moveAmount > 0 && movesMade < moveAmount) { if (Input.GetAxis("Vertical") > .5) { if (GameController.CheckForWalls(pos.x, (pos.y + moveSize)) == false && GameController.CheckForPlayer(pos.x, (pos.y + moveSize)) == false && GameController.CheckForGuard(pos.x, (pos.y + moveSize)) == false) { pos.y += moveSize; inputAvailable = 20; movesMade++; } //transform.localPosition } else if (Input.GetAxis("Vertical") < -.5) { if (GameController.CheckForWalls(pos.x, (pos.y - moveSize)) == false && GameController.CheckForPlayer(pos.x, (pos.y - moveSize)) == false && GameController.CheckForGuard(pos.x, (pos.y - moveSize)) == false) { pos.y -= moveSize; inputAvailable = 20; movesMade++; } } else if (Input.GetAxis("Horizontal") > .5) { if (GameController.CheckForWalls((pos.x + moveSize), pos.y) == false && GameController.CheckForPlayer((pos.x + moveSize), pos.y) == false && GameController.CheckForGuard((pos.x + moveSize), pos.y) == false) { pos.x += moveSize; inputAvailable = 20; movesMade++; } } else if (Input.GetAxis("Horizontal") < -.5) { if (GameController.CheckForWalls((pos.x - moveSize), pos.y) == false && GameController.CheckForPlayer((pos.x - moveSize), pos.y) == false && GameController.CheckForGuard((pos.x - moveSize), pos.y) == false) { pos.x -= moveSize; inputAvailable = 20; movesMade++; } } transform.position = pos; } if (Input.GetKeyDown(KeyCode.R)) { if (interractionCheck != 0) { print("you cannot reset your action"); //TODO } else { pos = resetPosition; transform.position = pos; movesMade = 0; } } if (Input.GetKeyDown(KeyCode.E)) { print("end turn"); //TODO //EndTurn(); pos = transform.position; resetPosition = transform.position; interractionCheck = 0; inputAvailable = 0; movesMade = 0;//moveAmount; //hasRolled = true; moveAmount = 0; //GetComponent<DiceRoll>().coroutineAllowed = true; GameObject.Find("StateMachine").GetComponent <GameState>().NextPlayer(); GameObject.Find("DiceRoller").GetComponent <DiceRoll>().coroutineAllowed = true; DiceRoll.movement = 0; //TODO-something with the dice } if (interractionCheck == 0) { if (Input.GetKeyDown(KeyCode.X)) { print("control guard"); //TODO pos = resetPosition; //resetPosition = transform.position; //interractionCheck = 0; inputAvailable = 0; movesMade = 0; //hasRolled = true; moveAmount = 0; GameObject.Find("GuardState").GetComponent <GuardStates>().NextState(); //GameObject.Find("StateMachine").GetComponent<GameState>().NextPlayer(); //GameObject.Find("DiceRoller").GetComponent<DiceRoll>().coroutineAllowed = true; //DiceRoll.movement = 0; //TODO-something with the dice } } if (GameController.CheckForInterractions(pos.x, pos.y) == true) { //Check which room if (Input.GetKeyDown(KeyCode.Return)) { if (interractionCheck != 0) { print("you can only do that once per turn"); //TODO-output sound } else { //TODO-change database List <Item> db = GameObject.Find("Items").GetComponent <ItemDatabase>().getDatabaseFromPosition(pos.x, pos.y); Item itm = GameObject.Find("Items").GetComponent <ItemDatabase>().drawAndRemove(db); if (itm != null) { if ((current.GetComponent <Player>().heldItems.Count < 5) && itm.use != "stat" && itm.type != "hazard") { print("item added to inventory"); current.GetComponent <Player>().heldItems.Add(itm); } else if (itm.use == "stat") { int amount = 0; if (itm.rare == true) { amount = 2; } else if (itm.rare == false) { amount = 1; } if (itm.location == "library") { current.GetComponent <Player>().intelligence += amount; } else if (itm.location == "yard") { current.GetComponent <Player>().strength += amount; } else if (itm.location == "shower") { current.GetComponent <Player>().looks += amount; } print("stats added to your stats"); GameObject.Find("Items").GetComponent <ItemDatabase>().ReturnItem(itm); } else if (itm.type == "hazard") { if (itm.identifier == -1) { //go to infirmary transform.position = HazardMovement.getRandomInfirmaryPoint(); pos = transform.position; resetPosition = transform.position; } else if (itm.identifier == -2) { //go to solitary transform.position = HazardMovement.getRandomSolitaryPoint(); pos = transform.position; resetPosition = transform.position; } print("hazard"); GameObject.Find("Items").GetComponent <ItemDatabase>().ReturnItem(itm); } else if ((current.GetComponent <Player>().heldItems.Count >= 5) && itm.use != "stat" && itm.type != "hazard") { print("Inventory is full"); GameObject.Find("Items").GetComponent <ItemDatabase>().ReturnItem(itm); } if (itm.rare == true) { if (GameObject.Find("Items").GetComponent <ItemDatabase>().totalLuck != 0) { current.GetComponent <Player>().luck += 1; GameObject.Find("Items").GetComponent <ItemDatabase>().totalLuck -= 1; } } interractionCheck++; movesMade = moveAmount; } else { print("There are no items left here"); //TODO-make a thud sound } } } } //TODO-win conditions based on exit if (GameController.CheckForExits(pos.x, pos.y) == true) { //TODO Check which room & check for win condition GameObject.Find("Winning").GetComponent <WinTheGame>().CheckExit(current); } /* * if(Input.GetKeyDown(KeyCode.C)){ * Camera.pixelWidth = 3840f; * Camera.pixelHeight = 2560f; * } */ }//end of isMyTurn //TODO-disable when fighting if (Input.GetKeyDown(KeyCode.I) && usingInstructions == false) { //print("Inventory"); if (usingInventory == false) { usingInventory = true; inventoryCanvas.GetComponent <CanvasBahavior>().ActivateInventory(); } else { inventoryCanvas.GetComponent <CanvasBahavior>().DeactivateInventory(); usingInventory = false; } } if (Input.GetKeyDown(KeyCode.U) && usingInventory == false) { if (usingInstructions == false) { usingInstructions = true; instructionCanvas.GetComponent <InstructionCanvas>().ShowInstructions(); } else { instructionCanvas.GetComponent <InstructionCanvas>().HideInstructions(); usingInstructions = false; } } } }