public void changetheme() { LoadOnClick loc = new LoadOnClick(); int actual = loc.theme; int expected = loc.theme + 1; Assert.Greater(expected, actual); }
public static void SetFailState() { LoadOnClick loader = new LoadOnClick(); ScoreManager.won = false; ScoreManager.gameOver = true; loader.LoadScene(4); }
void Start() { Scene scene = SceneManager.GetActiveScene(); if (scene.name == "StartMenu") { difficultyPicker = GameObject.Find("DifficultyPicker").GetComponent(typeof(LoadOnClick)) as LoadOnClick; } }
void CheckIfWon() { if (ScoreManager.playerScore >= scoreToWin) { ScoreManager.won = true; LoadOnClick load = new LoadOnClick(); load.LoadScene(4); } }
void OnCollisionEnter(Collision col) { if (col.gameObject.name == "Player") { float y = hitRacketFactor(transform.position, col.transform.position, col.collider.bounds.size.y); Vector3 dir = new Vector3(1, y).normalized; curSpeed += sFactor; rb.velocity = dir * curSpeed; } else if (col.gameObject.name == "PlayerTwo") { float y = hitRacketFactor(transform.position, col.transform.position, col.collider.bounds.size.y); Vector3 dir = new Vector3(-1, y).normalized; curSpeed += sFactor; rb.velocity = dir * curSpeed; } else if (col.gameObject.name == "Right Wall") { playerOne.addScore(); p1Text.text = "Score: " + playerOne.score; respawn(); } else if (col.gameObject.name == "Left Wall") { if (playerTwo != null) { playerTwo.addScore(); p2Text.text = "Score: " + playerTwo.score; } else if (playerComp != null) { playerComp.addScore(); p2Text.text = "Score: " + playerComp.score; } respawn(); } if (checkScores()) { LoadOnClick.LoadSceneNoImage(3); } }
// Update is called once per frame void Update() { if (Input.GetButtonDown("Heal")) { Heal(); } //text.text = "Attack1 Charges: " + (int) attack1Charges + " " + "Attack2 Charges: " + (int) attack2Charges + " " + "Dash Charges: " + (int) dashCharges; // Debug.Log (text.text); //register all the inputs that need to be dynamically tracked //movement key inputs movementInput = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")); //mouse position Ray camRay = playerCamera.ScreenPointToRay(Input.mousePosition); RaycastHit floorHit; if (Physics.Raycast(camRay, out floorHit, playerCamera.farClipPlane, LayerMask.GetMask("MouseRaycast"))) { Vector3 p2m = floorHit.point - transform.position; p2m.y = 0f; playerToMouse = p2m.normalized; } //Animate currentState.Animate(); //carry out state-specific orders currentState.Update(); if (stateEnded) { if (nextState == null) { this.nextState = currentState.HandleInput(); } stateEnded = false; } if (this.GetComponent <Health>().currentHealth <= 0) { this.currentState.Exit(); LoadOnClick.StaticLoadSceneByName("MainMenu"); } }
public override void FixedUpdate() { Quaternion change = Quaternion.Euler(0, 179 + bc.gameObject.transform.rotation.eulerAngles.y, 0); bc.gameObject.transform.rotation = Quaternion.Slerp(bc.gameObject.transform.rotation, change, Time.deltaTime); bc.gameObject.GetComponentInChildren <SpriteRenderer>().color = new Color(1f, 1f, 1f, bc.gameObject.GetComponentInChildren <SpriteRenderer>().color.a * .9f); // Color col = sr.color; // col.a *= .7f; // sr.color = col; // Debug.Log (ec.gameObject.GetComponentInChildren<SpriteRenderer> ().color); if (bc.gameObject.transform.rotation.eulerAngles.y > 200) { LoadOnClick.StaticLoadSceneByName("Credits"); } //dieTimer += Time.deltaTime; //if (dieTimer >= dieDuration) //{ //} }
void FixedUpdate() { if (panelIndex == canvasGroups.Length) { LoadOnClick.StaticLoadSceneByName("MainMenu"); } switch (panelState) { case 0: canvasGroups[panelIndex].alpha += Time.deltaTime / panelRiseTime; if (canvasGroups[panelIndex].alpha >= 1) { panelState++; } break; case 1: panelStayTimer += Time.deltaTime; if (panelStayTimer >= panelStayTime) { panelState++; panelStayTimer = 0; } break; case 2: canvasGroups[panelIndex].alpha -= Time.deltaTime / panelFallTime; if (canvasGroups[panelIndex].alpha <= 0) { panelIndex++; panelState = 0; } break; default: break; } }
void OnTriggerEnter2D(Collider2D other) { if (other.CompareTag("Coin")) { score += 10; Destroy(other.gameObject); } else if (other.CompareTag("Chest")) { hasTakenChest = true; score += 25; other.gameObject.SetActive(false); chestimage.gameObject.SetActive(true); } if (other.CompareTag("Door") && hasTakenChest) { coinsList.Clear(); foreach (Transform coin in coinsParent.transform) { coinsList.Add(coin.gameObject); } finalCoinCount = coinsList.Count; if (SceneManager.GetActiveScene().name == "Level3") { Time.timeScale = 0; panel.SetActive(true); } else { LoadOnClick loadOnClick = GameObject.FindObjectOfType <LoadOnClick> (); loadOnClick.ButtonNextLevel(); } } }
public void CheckCommand() { #region Variables for checking a command bool endOfCommand = false; string fullOptionText = textLines[currentLine]; string commandText = ""; string secondaryCommandText = ""; string tertiaryCommandText = ""; int secondaryNum = -1; // can represent an item number to take from the NPC or give the NPC or a line number to jump to int tertiaryNum = -1; // can represent a line number to jump to GameObject otherObject; #endregion int i = 1; #region Primary Command // Loops through // Saves the text between the square brackets do { if (fullOptionText[i] == ']') { endOfCommand = true; } else if (endOfCommand != true) { commandText += fullOptionText[i]; } i++; } while (endOfCommand == false); #endregion #region Secondary Command // getting the text for item management with an NPC or number for going to a different text line switch (commandText) { case "GiveItem": // Second number is index of the item in items list case "RemoveItem": // Second number is index of the item in items list case "SpawnEnemy": // Second number is the index of the enemy in the enemies list case "StartQuestOtherObject": // Second number is the index of the additionalObjectsNeeded list case "SetObjectActive": // Second number is the index of the additionalObjectsNeeded list case "GoToLine": // Second number is line number the text will go to case "CheckRequirements": // Second number is the line to go to if the player fulfills the requirements case "Reward": // Second number is the number of screws rewarded to the player // Increment by one for the beginning parenthesis i++; // Reset endofCommand to flase for the do/while loop endOfCommand = false; // loop through to get the full number do { if (fullOptionText[i] == ')') { endOfCommand = true; } else if (endOfCommand != true) { secondaryCommandText += fullOptionText[i]; } i++; } while (endOfCommand == false); // Loops through // Saves the text between the square brackets int.TryParse(secondaryCommandText, out secondaryNum); Console.WriteLine(secondaryNum); break; } #endregion #region Tertiary Command switch (commandText) { // Tertiary command set to object // used for conditional statements case "CheckRequirements": // Third number is the line the text document goes to if requirements are not met case "SpawnEnemy": // Third number represents the line to go to if there are no enemies left to spawn // Increment by one for the beginning parenthesis i++; // Reset endofCommand to flase for the do/while loop endOfCommand = false; // loop through to get the full number do { if (fullOptionText[i] == ')') { endOfCommand = true; } else if (endOfCommand != true) { tertiaryCommandText += fullOptionText[i]; } i++; } while (endOfCommand == false); // Loops through // Saves the text between the square brackets int.TryParse(tertiaryCommandText, out tertiaryNum); Console.WriteLine(tertiaryNum); break; } #endregion //Debug.Log("Command: " + commandText + " Secondary Command Number: " + secondaryNum + " Tertiary Command Number: " + tertiaryCommandText); #region Commands switch (commandText) { #region Item based commands (give/remove) case "GiveItem": // give player that item //Debug.Log("Gave player: " + items[secondaryNum]); // Add item to inventory player.GetComponent <PlayerManager>().AddItem(items[secondaryNum]); // Advance to the next text line currentLine++; break; case "RemoveItem": // give player that item //Debug.Log("Took from player: " + items[secondaryNum]); // Add item to inventory player.GetComponent <PlayerManager>().RemoveItem(items[secondaryNum]); // Advance to the next text line currentLine++; break; case "Reward": GameManager.instance.screws += secondaryNum; currentLine++; break; #endregion #region Dynamic Commands // This command checks all requirements including Items, Enemies, and NPCs // Items are checked in the inventory and only removed once all requirements are met // Enemies are checked if they are null (they are removed from the list and are deleted from the scene if dead) // NPCs are checked if they have a Complete Quest Status case "CheckRequirements": // give player that item //Debug.Log("Check Requirements"); int completedRequirements = 0; for (int j = 0; j < requirements.Count; j++) { // For enemies (they would be deleted if they are defeated) // This must be checked first so that a nullreferenece exception doesn't occur if (requirements[j] != null) { // For NPCS (if their quest has been completed) if (requirements[j].GetComponent <NPC>()) { if (requirements[j].GetComponent <NPC>().currentQuestStatus == QuestStatus.Completed) { completedRequirements++; } } // For Allies (if their quest has been completed) if (requirements[j].GetComponent <AllyManager>()) { if (requirements[j].GetComponent <AllyManager>().currentQuestStatus == QuestStatus.Completed) { completedRequirements++; } } } else { requirements.Remove(requirements[j]); j--; } } // Check For Items bool requirementfulfilled = true; requirementfulfilled = CheckInventory(player.GetComponent <PlayerManager>().playerItems); if (completedRequirements == requirements.Count && requirementfulfilled) { //Debug.Log("Requirements fulfilled, moved to line " + secondaryNum); // Only remove Item requirements if the full check has been completed RemoveItemRequirements(player.GetComponent <PlayerManager>().playerItems); currentLine = secondaryNum; } else { //Debug.Log("Requirements not fulfilled, moved to line " + tertiaryNum); currentLine = tertiaryNum; } //Debug.Log("Current Line: " + currentLine); break; #endregion #region Quest Commands case "ResetQuest": //Debug.Log("Command: " + commandText + secondayCommand); currentQuestStatus = QuestStatus.NotStarted; if (questIcon != null) { questIcon.GetComponent <SpriteRenderer>().sprite = QuestSprites[1]; } TextFileSetUp(startedQuestTextFile); currentLine = 0; endDialogue(); break; case "StartQuest": //Debug.Log("Command: " + commandText + secondayCommand); currentQuestStatus = QuestStatus.Started; if (questIcon != null) { questIcon.GetComponent <SpriteRenderer>().sprite = QuestSprites[1]; } TextFileSetUp(startedQuestTextFile); currentLine = 0; endDialogue(); break; case "StartQuestOtherObject": //Debug.Log("Command: " + commandText + secondayCommand); otherObject = additionalObjectsNeeded[secondaryNum]; NPC otherNPCScript = otherObject.GetComponent <NPC>(); otherNPCScript.currentQuestStatus = QuestStatus.Started; if (otherNPCScript.questIcon != null) { otherNPCScript.questIcon.GetComponent <SpriteRenderer>().sprite = QuestSprites[1]; } otherNPCScript.TextFileSetUp(otherNPCScript.startedQuestTextFile); otherNPCScript.currentLine = 0; currentLine++; break; case "CompleteQuest": currentQuestStatus = QuestStatus.Completed; //questIcon.GetComponent<SpriteRenderer>().sprite = QuestSprites[2]; if (questIcon != null) { questIcon.GetComponent <SpriteRenderer>().sprite = null; } TextFileSetUp(completedQuestTextFile); currentLine = 0; endDialogue(); break; #endregion #region Spawning Commands case "SetObjectActive": if (additionalObjectsNeeded[secondaryNum] != null) { additionalObjectsNeeded[secondaryNum].SetActive(true); currentLine++; } else { currentLine = tertiaryNum; } break; case "SpawnEnemy": if (enemies[secondaryNum] != null) { enemies[secondaryNum].SetActive(true); currentLine++; } else { currentLine = tertiaryNum; } break; case "StartBossFight": // Start the boss fight enemies[0].SetActive(true); GameObject.Find("HUDCanvas").GetComponent <GUIManager>().BossHealthSetUp(enemies[0]); GUIManager.bossFight = true; currentLine++; break; #endregion #region Dialogue Specific Commands case "GoToLine": // Go to a specific text line currentLine = secondaryNum; break; case "Exit": endDialogue(); break; #endregion #region Ally Commands case "StartFollowing": GetComponent <AllyMovement>().FollowingPlayer = true; currentLine++; break; case "StopFollowing": GetComponent <AllyMovement>().FollowingPlayer = false; currentLine++; break; #endregion case "DeleteSelf": // Go to a specific spot in the scene transform.position = new Vector3(10000, 10000, 0); currentLine++; break; #region Exiting Level case "ExitLevel": LoadOnClick.ReturnToLevelSelectScreen(); currentLine++; break; #endregion } #endregion // Start the scrolling text (if the command isn't an Exit related command) if (!(commandText == "Exit" || commandText == "CompleteQuest" || commandText == "StartQuest" || commandText == "ExitLevel")) { StartCoroutine(GUIManager.TextScroll(textLines[currentLine])); } }
void Start() { loadOnClick = GameObject.FindGameObjectWithTag (Tags.canvas).GetComponent<LoadOnClick> (); }
//starts a new game by loading GameScreen scene public static void startGame() { LoadOnClick loc = new LoadOnClick(); loc.LoadScene("GameScreen"); }
public void escapeButton() { LoadOnClick loc = new LoadOnClick(); Assert.That(loc.getEscapeButton()); }
public void exitButton() { LoadOnClick loc = new LoadOnClick(); Assert.That(loc.getExitButton()); }
public void startButton() { LoadOnClick loc = new LoadOnClick(); Assert.That(loc.getStartButton()); }
public void SelectWeapon(string i_Key) { PlayerController.SelectedWeapon = i_Key; Debug.Log("selcted weapon = " + i_Key); LoadOnClick.LoadSavedScene(); }
public void LoadTheScene(int levelIndex) { loader = new LoadOnClick(); loader.LoadScene(levelIndex); }