void checkJump() { var rand = new System.Random(); // Jumping if (distanceBetweenX < 1.8 && p2y < p1y - 0.5 && rand.Next(100) <= 2) { MaxInput.Jump("Player2"); } }
// Update is called once per frame void Update() { //Practice Mode Handler if (GameObject.Find("PlayerData").GetComponent <SelectedCharacterManager>().gameMode == "Practice" || GameObject.Find("PlayerData").GetComponent <SelectedCharacterManager>().gameMode == "Tutorial") { //Check Settings from Practice Pause Menu //CPUState Check switch (PracticeModeSettings.GetComponent <PauseMenu>().CPUState) { case 0: dummyState = "Stand"; break; case 1: dummyState = "Crouch"; break; case 2: dummyState = "Jump"; break; case 3: dummyState = "StandGuard"; break; case 4: dummyState = "LowGuard"; break; case 5: dummyState = "GuardAll"; break; case 6: dummyState = "CPU"; break; case 7: dummyState = "Player"; break; } switch (PracticeModeSettings.GetComponent <PauseMenu>().ArmorRefill) { case 0: enableArmorRefill = true; break; case 1: enableArmorRefill = false; break; } switch (PracticeModeSettings.GetComponent <PauseMenu>().CPUAirRecover) { case 0: enableCPUAirTech = false; break; case 1: enableCPUAirTech = true; break; } switch (PracticeModeSettings.GetComponent <PauseMenu>().CPUGroundGuard) { case 0: enableGuardAfterFirstHit = false; break; case 1: enableGuardAfterFirstHit = true; break; } // If we are NOT paused if (!PracticeModeSettings.GetComponent <PauseMenu>().isPaused) { //Refill Armor Meters Option if (enableArmorRefill) { //Refill P1 Armor when P1 combo finishes if (HUD.combogauge1.enabled == false && P2inCombo && P1Prop.HitDetect.comboCount == 0) { P1Prop.armor = 4; P1Prop.durability = 100; } //Refill P2 Armor when P2 combo finishes if (HUD.combogauge1.enabled == false && P1inCombo && P2Prop.HitDetect.comboCount == 0) { P2Prop.armor = 4; P2Prop.durability = 100; } //Refill P1 armor after move whiffed if (P1Prop.HitDetect.Actions.acceptSuper && !P2inCombo && (P1Prop.HitDetect.anim.GetCurrentAnimatorStateInfo(0).IsName("IdleStand") || P1Prop.HitDetect.anim.GetCurrentAnimatorStateInfo(0).IsName("Jump") || P1Prop.HitDetect.anim.GetCurrentAnimatorStateInfo(0).IsName("IdleCrouch"))) { P1Prop.armor = 4; P1Prop.durability = 100; } //Refill P2 armor after move whiffed if (P2Prop.HitDetect.Actions.acceptSuper && !P1inCombo && (P2Prop.HitDetect.anim.GetCurrentAnimatorStateInfo(0).IsName("IdleStand") || P2Prop.HitDetect.anim.GetCurrentAnimatorStateInfo(0).IsName("Jump") || P2Prop.HitDetect.anim.GetCurrentAnimatorStateInfo(0).IsName("IdleCrouch"))) { P2Prop.armor = 4; P2Prop.durability = 100; } } //Update Health settings from menu P1ValorSetting = PracticeModeSettings.GetComponent <PauseMenu>().P1Valor; P2ValorSetting = PracticeModeSettings.GetComponent <PauseMenu>().P2Valor; //Refill Health Meters/Manage whiff detection for Armor refill //Refill P1 HP after P2 combo finishes if (P1Prop.HitDetect.hitStun > 0) { P1inCombo = true; } if (P2Prop.HitDetect.comboCount == 0) { P1Prop.currentHealth = P1Prop.maxHealth * (P1ValorSetting / 100f); P1inCombo = false; P2CurrentHitDamage = 0; P1PrevHealth = P1Prop.currentHealth; P2CurrentComboTotalDamage = 0; } //Refill P2 HP after P1 combo finishes if (P2Prop.HitDetect.hitStun > 0 && refillCPUHealth) { P2inCombo = true; InputTimer = 0.0f; } if (P1Prop.HitDetect.comboCount == 0 && refillCPUHealth) { P2Prop.currentHealth = P2Prop.maxHealth * (P2ValorSetting / 100f); P2inCombo = false; P1CurrentHitDamage = 0; P2PrevHealth = P2Prop.currentHealth; P1CurrentComboTotalDamage = 0; } //Manage Hit/Combo Damage/Hit Type Display //Display Current hit damage/Current Combo damage/Current Hit Type if (P2Prop.currentHealth < P2PrevHealth) { P1CurrentHitDamage = P2PrevHealth - P2Prop.currentHealth; P1CurrentComboTotalDamage += P1CurrentHitDamage; P1HitDamage.text = "Damage: "; P1HitDamage.text += P1CurrentHitDamage; P1ComboDamage.text = "Total Damage: "; P1ComboDamage.text += P1CurrentComboTotalDamage; P1HitType.text = "Guard Level: "; if (P1Prop.HitDetect.guard == "Unblockable") { P1HitType.text += "Grab"; } else { P1HitType.text += P1Prop.HitDetect.guard; } P2PrevHealth = P2Prop.currentHealth; P2CurrentHitDamage = P2PrevHealth - P2Prop.currentHealth; P2CurrentComboTotalDamage += P1CurrentHitDamage; P2HitDamage.text = "Damage: "; P2HitDamage.text += P1CurrentHitDamage; P2ComboDamage.text = "Total Damage: "; P2HitType.text = "Guard Level: "; if (P1Prop.HitDetect.guard == "Unblockable") { P2HitType.text += "Grab"; } else { P2HitType.text += P1Prop.HitDetect.guard; } P2ComboDamage.text += P1CurrentComboTotalDamage; } if (HUD.Player1Hits.text == "" && P1Prop.HitDetect.comboCount != 1) { P1HitDamage.text = ""; P1HitType.text = ""; } if (HUD.Player2Hits.text == "" && P1Prop.HitDetect.comboCount != 1) { P2HitDamage.text = ""; P2HitType.text = ""; } //Update Highest Combo Damage if (P1CurrentComboTotalDamage > P1HighestComboDamage) { P1HighestComboDamage = P1CurrentComboTotalDamage; P1HighComboDamage.text = "Highest Combo Damage: "; P1HighComboDamage.text += P1HighestComboDamage; P2HighestComboDamage = P1CurrentComboTotalDamage; P2HighComboDamage.text = "Highest Combo Damage: "; P2HighComboDamage.text += P1HighestComboDamage; } //Handle Dummy State p1x = GameObject.Find("Player1").transform.GetChild(0).transform.position.x; p2x = GameObject.Find("Player2").transform.GetChild(0).transform.position.x; if (InputTimer > 0) { InputTimer -= Time.deltaTime; } else { InputTimer = 0; } //Determine P1 Current attack type to determine proper Guard guardLevel = Player1.GetComponentInChildren <AcceptInputs>().hitType; switch (dummyState) { case "CPU": MaxInput.enableAI(); MaxInputObject.GetComponent <AI>().enabled = true; break; case "Stand": MaxInput.ClearInput("Player2"); MaxInput.enableAI(); MaxInputObject.GetComponent <AI>().enabled = false; break; case "Crouch": MaxInput.ClearInput("Player2"); MaxInput.enableAI(); MaxInputObject.GetComponent <AI>().enabled = false; MaxInput.Crouch("Player2"); break; case "Jump": MaxInput.ClearInput("Player2"); MaxInput.enableAI(); MaxInputObject.GetComponent <AI>().enabled = false; if (InputTimer == 0 && !P2inCombo) { MaxInput.Jump("Player2"); InputTimer = 1.0f; } break; case "StandGuard": MaxInput.ClearInput("Player2"); MaxInput.enableAI(); MaxInputObject.GetComponent <AI>().enabled = false; if (p1x - p2x < 0) { MaxInput.MoveRight("Player2"); } else { MaxInput.MoveLeft("Player2"); } break; case "LowGuard": MaxInput.ClearInput("Player2"); MaxInput.enableAI(); MaxInputObject.GetComponent <AI>().enabled = false; if (p1x - p2x < 0) { MaxInput.DownRight("Player2"); } else { MaxInput.DownLeft("Player2"); } break; case "GuardAll": MaxInput.ClearInput("Player2"); MaxInput.enableAI(); MaxInputObject.GetComponent <AI>().enabled = false; if (p1x - p2x < 0) { if (guardLevel == "Low" && (p1x - p2x > -2)) { MaxInput.DownRight("Player2"); } else { MaxInput.MoveRight("Player2"); } } else { if (guardLevel == "Low" && (p1x - p2x < 2)) { MaxInput.DownLeft("Player2"); } else { MaxInput.MoveLeft("Player2"); } } break; case "Player": MaxInput.ClearInput("Player2"); MaxInput.disableAI(); break; } //CPU Air Tech Option if (enableCPUAirTech && dummyState != "Player" && dummyState != "CPU") { //Air tech if in combo and hitstun = 0 if (P2Prop.HitDetect.hitStun > 0 && Player2.transform.GetComponentInChildren <AcceptInputs>().airborne) { P2inAirTrueCombo = true; } else if (P2Prop.HitDetect.hitStun <= 0 && Player2.GetComponentInChildren <AcceptInputs>().airborne&& P2inAirTrueCombo) { MaxInput.Cross("Player2"); P2inAirTrueCombo = false; } } //CPU ground guard after first hit if (enableGuardAfterFirstHit && dummyState != "Player" && dummyState != "CPU") { //(On Ground) Guard if in combo, hitstun = 0, and Player is still in the middle of an attack if (P2Prop.HitDetect.hitStun > 0) { P2inGroundTrueCombo = true; } if (P2Prop.HitDetect.hitStun <= 0 && P2inGroundTrueCombo) { guardAfterTrueCombo = true; P2inGroundTrueCombo = false; } if (guardAfterTrueCombo) { if (p1x - p2x < 0) { if (guardLevel == "Low" && (p1x - p2x > -2)) { MaxInput.DownRight("Player2"); } else { MaxInput.MoveRight("Player2"); } } else { if (guardLevel == "Low" && (p1x - p2x < 2)) { MaxInput.DownLeft("Player2"); } else { MaxInput.MoveLeft("Player2"); } } if (!P1Prop.HitDetect.Actions.attacking) { guardAfterTrueCombo = false; } } } //Fix Animation bug with resetting positions if (fixAnimBug) { switch (GameObject.Find("PlayerData").GetComponent <SelectedCharacterManager>().P1Character) { case "Dhalia": resetDhalia(Player1); break; case "Achealis": resetAchealis(Player1); break; } switch (GameObject.Find("PlayerData").GetComponent <SelectedCharacterManager>().P2Character) { case "Dhalia": resetDhalia(Player2); break; case "Achealis": resetAchealis(Player2); break; } fixAnimBug = false; InputTimer = 0.0f; } //Reset Positions back to start if (Input.GetButtonDown(inputSelect)) // Temporarily changed to P2 { resetPositions(); //Reset Character Specific things switch (GameObject.Find("PlayerData").GetComponent <SelectedCharacterManager>().P1Character) { case "Dhalia": resetDhalia(Player1); break; case "Achealis": resetAchealis(Player1); break; } switch (GameObject.Find("PlayerData").GetComponent <SelectedCharacterManager>().P2Character) { case "Dhalia": resetDhalia(Player2); break; case "Achealis": resetAchealis(Player2); break; } fixAnimBug = true; } if (GameObject.Find("PlayerData").GetComponent <SelectedCharacterManager>().gameMode == "Practice") { // Recording if (Input.GetButtonDown(inputL3) && !isReplaying) { recording++; //L3 } switch (recording) { case 1: // Switch player controls RecordingDisplay.SetActive(true); RecordingState.text = "Recording Armed"; isRecording = true; switchControls(true); break; case 2: // Get inputs from MaxInput. returnMovement() returnInputs() RecordingState.text = "Now Recording " + recordingFrame; recordingFrame++; List <float> getMoves = MaxInput.returnMovement("Player1"); List <bool> getInputs = MaxInput.returnInputs("Player1"); movement.Add(getMoves); inputs.Add(getInputs); break; case 3: // Create a txt file that has all the inputs for each frame RecordingState.text = "Recording Saved"; switchControls(false); saveRecording(); isRecording = false; recording = 0; recordingFrame = 0; break; } // Replaying the Recording if (Input.GetButtonDown(inputR3) && !isReplaying && !isRecording) //R3 { isReplaying = true; reader = new StreamReader(path); string temp = reader.ReadLine(); if (temp == "True") { faceLeft = true; } else { faceLeft = false; } } if (isReplaying) { // Read file, execute MaxInput actions every frame string line; if ((line = reader.ReadLine()) != null) { RecordingState.text = "Replaying " + recordingFrame; MaxInput.ClearInput("Player2"); replay(line); } else { isReplaying = false; recordingFrame = 0; reader.Close(); } } } } } }
public void combo2H_1() { // Step 1: Crouching if (AI.doing2H_1 == 1) { MaxInput.Crouch("Player2"); AI.doing2H_1 = 2; AI.delayTimer = .1f; AI.keepInput = true; } // Step 2: 2H else if (AI.doing2H_1 == 2) { MaxInput.Circle("Player2"); AI.doing2H_1 = 3; AI.delayTimer = .5f; } // Step 3: Jump Left/Right else if (AI.doing2H_1 == 3 && AI.pIsHitstun) { if (AI.faceLeft == true) { MaxInput.MoveLeft("Player2"); } else { MaxInput.MoveRight("Player2"); } MaxInput.Jump("Player2"); AI.doing2H_1 = 4; AI.delayTimer = .1f; AI.keepInput = false; } // Step 4 - 7: J.H else if (AI.doing2H_1 >= 4 && AI.doing2H_1 <= 7 && AI.pIsHitstun) { MaxInput.Circle("Player2"); AI.doing2H_1++; AI.delayTimer = .25f; //if (AI.doing2H_1 == 8) AI.delayTimer = .3f; } // Step 8: Jump Left/Right else if (AI.doing2H_1 == 8 && AI.pIsHitstun) { if (AI.faceLeft == true) { MaxInput.MoveLeft("Player2"); } else { MaxInput.MoveRight("Player2"); } MaxInput.Jump("Player2"); AI.doing2H_1 = 9; AI.delayTimer = .1f; } // Step 9: J.H else if (AI.doing2H_1 == 9 && AI.pIsHitstun) { MaxInput.Circle("Player2"); AI.doing2H_1++; AI.delayTimer = .25f; } // Step 10: J.B else if (AI.doing2H_1 == 10 && AI.pIsHitstun) { MaxInput.Cross("Player2"); AI.doing2H_1 = 11; AI.delayTimer = .2f; } // Step 11: Spinny Kick else if (AI.doing2H_1 == 11 && AI.pIsHitstun) { AI.doing2H_1 = 12; AI.keepAction = "Circle"; AI.doingQCB = 1; QCB(); } else if (AI.doing2H_1 == 12 && AI.pIsHitstun) { AI.doing2H_1 = 13; AI.delayTimer = 1f; } else if (AI.doing2H_1 == 13 && AI.pIsHitstun && AI.armor >= 2) { AI.doing2H_1 = 0; AI.keepAction = "RTrigger"; AI.doingQCF = 1; AI.AIInput.QCF(); } else { AI.doing2H_1 = 0; //AI.delayTimer = 5f; AI.keepInput = false; } }