private void HitOpponent(Collider2D otherPlayer, string rival) { if (otherPlayer.tag == rival) { rivalCharacter = otherPlayer.gameObject.GetComponent <CharacterFeatures>(); float attackValue = currentCharacter.DoDamage() * CurrentFightStats.GetDamage(); ///Moves hit character rivalCharacter.HitDone(); switch (currentCharacter.GetIsFlipped()) { case true: otherPlayer.gameObject.GetComponent <Rigidbody2D>().velocity = Vector2.left * 40f; break; case false: otherPlayer.gameObject.GetComponent <Rigidbody2D>().velocity = Vector2.right * 40f; break; } if (rivalCharacter.GetIsBlocking()) { rivalSoundEffect.PlayCharacterSoundEffect("Block"); rivalCharacter.TakeDamage(attackValue / 4); PlayBlockAnimation(); blockSprite.GetComponent <BlockBehaviour>().ActivateBlockSprite(otherPlayer.gameObject.GetComponent <BoxCollider2D>(), rivalCharacter.GetIsFlipped()); } else { rivalSoundEffect.PlayCharacterSoundEffect("Hit"); rivalCharacter.TakeDamage(attackValue); PlayHitAnimation(); hitSparks.GetComponent <SparksBehaviour>().ActivateHitSparks(gameObject.GetComponent <BoxCollider2D>().bounds.center); } } }
private bool ChooseCharacter(string charName) { if (!CharacterAlreadyChosen(charName)) { soundEffect.PlaySoundEffect("ConfirmCharSel"); chosenChars++; switch (chosenChars) { case 1: firstChosenCharacter.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Textures_and_Sprites/Menus/Interface/CharacterSelectionMenu/CharacterProfile/" + characterSeries + "/" + charName + "/" + "Chosen" + charName + "Background"); CurrentFightStats.SetSelectedCharacterPlayer1(charName, 0); break; case 2: secondChosenCharacter.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Textures_and_Sprites/Menus/Interface/CharacterSelectionMenu/CharacterProfile/" + characterSeries + "/" + charName + "/" + "Chosen" + charName + "Background"); CurrentFightStats.SetSelectedCharacterPlayer1(charName, 1); break; case 3: thirdChosenCharacter.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Textures_and_Sprites/Menus/Interface/CharacterSelectionMenu/CharacterProfile/" + characterSeries + "/" + charName + "/" + "Chosen" + charName + "Background"); CurrentFightStats.SetSelectedCharacterPlayer1(charName, 2); loadScene.LoadByIndex(8); break; } return(true); } soundEffect.PlaySoundEffect("Wrong"); return(false); }
private bool CharacterAlreadyChosen(string charName) { for (int i = 0; i < chosenChars; i++) { if (charName == CurrentFightStats.GetSelectedCharacter(i, "Player1")) { return(true); } } return(false); }
// Use this for initialization void Start() { characterName = CurrentFightStats.GetSelectedCharacter(transform.GetSiblingIndex(), gameObject.tag); //characterName = "Ken"; //For testing characterSeries = CharacterSelectionMapping.GetCharacterSeries(characterName); var type = Type.GetType(characterName); character = (Character)Activator.CreateInstance(type); healthBar = new HealthBar(health.transform.GetChild(transform.GetSiblingIndex()).gameObject, character.GetHealth(), characterName); animator.runtimeAnimatorController = Resources.Load("Animation/Characters/" + characterSeries + "/" + characterName + "/" + characterName) as RuntimeAnimatorController; SetIsAI(CurrentFightStats.GetAI(transform.tag)); characterVoice = CharacterVoicePlayer.GetComponent <CharacterVoice>(); }
private void SetVsPortraits(GameObject portraits) { int portraitNumber = 0; foreach (Transform portrait in portraits.transform) { string charName = CurrentFightStats.GetSelectedCharacter(portraitNumber, portrait.tag); string characterSeries = CharacterSelectionMapping.GetCharacterSeries(charName); portrait.GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("Textures_and_Sprites/Menus/Interface/CharacterSelectionMenu/CharacterProfile/" + characterSeries + "/" + charName + "/" + "Chosen" + charName + "Background"); portraitNumber++; } }
void Start() { if (CurrentFightStats.GetTimer() > 0) { //timer = 100; timer = CurrentFightStats.GetTimer(); counter.text = timer.ToString(); } else { timer = -1; counter.fontSize = 100; counter.text = "\u221E"; //Infinity symbol } }
IEnumerator FightStart() { yield return(new WaitUntil(() => announcer.GetComponent <AnnouncerVoice>().AnnouncerIsPlaying() == false)); yield return(new WaitForSeconds(0.5f)); announcerText.sprite = Resources.Load <Sprite>("Textures_and_Sprites/Menus/Interface/Fight/Texts/Fight"); announcer.GetComponent <AnnouncerVoice>().PlayAnnouncer("Fight"); yield return(new WaitForSeconds(0.2f)); fightStarted = true; player1.transform.GetChild(0).GetComponent <CharacterFeatures>().SetIsBlocked(false); player2.transform.GetChild(0).GetComponent <CharacterFeatures>().SetIsBlocked(false); announcerText.GetComponent <Image>().color = new Color(announcerText.color.r, announcerText.color.g, announcerText.color.b, 0f); music.GetComponent <MusicPlayer>().PlayMusic(CurrentFightStats.GetSelectedCharacter(0, "Player1")); music.GetComponent <AudioSource>().loop = true; }
void Update() { if (!fightStarted) { AnnounceFight(); } if (fightStarted) { StartCoroutine(SwapCharacterWhenDead(player1)); StartCoroutine(SwapCharacterWhenDead(player2)); //Declares a winner if all healthBars has been depleted if (CheckLifeBars(player1) && !fightEnded) { SetWinner(player2); } if (CheckLifeBars(player2) && !fightEnded) { SetWinner(player1); } //Prompts the restart fight screen and stops the timer if (fightEnded && !restartPrompt) { if (CurrentFightStats.GetTimer() > 0) { timerCounter.GetComponent <Timer>().StopTimer(); } StartCoroutine(PopUpRestartFight()); } //Counts down the time if (timerCounter.GetComponent <Timer>().GetTimer() > 0 && !fightEnded) { timerCounter.GetComponent <Timer>().DecreaseTimer(); } if (timerCounter.GetComponent <Timer>().GetTimer() == 0 && !fightEnded) { fightEnded = true; TimeUpVictory(); } } }
public void SetDamageParameter(int childNumber) { ChooseSetting damageSetting = this.transform.GetChild(childNumber).GetComponent <ChooseSetting>(); CurrentFightStats.SetDamage(damageSetting.GetValueOption()); }