bool CheckWinningCondition() { //Get current abilities int currentAbilityNum = myAStack.GetAvailableAbilityNum(); List <Player_Ability> currentAbilityList = myAStack.GetAbilityList(); //Get target abilities Color[] targetAbilities = stage.GetComponent <Stage_WinningCondition> ().GetTargetList(); //See if current abilities match target abilities int collectedTargetNum = 0; for (int i = 0; i < currentAbilityNum; i++) { for (int j = 0; j < targetAbilities.Length; j++) { if (Stage_Utilities.compareColorsLoose(currentAbilityList[i].abilityColor, targetAbilities [j])) { collectedTargetNum += 1; break; } } } if (collectedTargetNum == targetAbilities.Length) { return(true); } else { return(false); } }
//Swtich abilities void SwitchForm() { //Get current ability list and ability number int abilityNum = myAStack.GetAvailableAbilityNum(); List <Player_Ability> abilityList = myAStack.GetAbilityList(); if (Input.GetKeyDown(KeyCode.Z)) { if (abilityNum >= 1) //Only able to use the first ability when ability number is greater than 1 //Switch to the ability if not currently using it { if (!Stage_Utilities.compareColorsLoose(mySpriteRenderer.color, abilityList [0].abilityColor)) { mySpriteRenderer.color = abilityList [0].abilityColor; attackSpriteRenderer.color = abilityList [0].abilityColor; bulletPrefab.GetComponent <SpriteRenderer> ().color = abilityList [0].abilityColor; dustPuff.GetComponent <ParticleSystem> ().startColor = abilityList [0].abilityColor; } else //Switch back to original if currently using it { mySpriteRenderer.color = new Color(1, 1, 1); attackSpriteRenderer.color = new Color(1, 1, 1); bulletPrefab.GetComponent <SpriteRenderer> ().color = new Color(1, 1, 1); dustPuff.GetComponent <ParticleSystem> ().startColor = new Color(1, 1, 1); } } } if (Input.GetKeyDown(KeyCode.X)) { if (abilityNum >= 2) //Only able to use the second ability when ability number is greater than 2 { if (!Stage_Utilities.compareColorsLoose(mySpriteRenderer.color, abilityList [1].abilityColor)) { mySpriteRenderer.color = abilityList [1].abilityColor; attackSpriteRenderer.color = abilityList [1].abilityColor; bulletPrefab.GetComponent <SpriteRenderer> ().color = abilityList [1].abilityColor; dustPuff.GetComponent <ParticleSystem> ().startColor = abilityList [1].abilityColor; } else { mySpriteRenderer.color = new Color(1, 1, 1); attackSpriteRenderer.color = new Color(1, 1, 1); bulletPrefab.GetComponent <SpriteRenderer> ().color = new Color(1, 1, 1); dustPuff.GetComponent <ParticleSystem> ().startColor = new Color(1, 1, 1); } } } if (Input.GetKeyDown(KeyCode.C)) { if (abilityNum >= 3) //Only able to use the third ability when ability number is greater than 3 { if (!Stage_Utilities.compareColorsLoose(mySpriteRenderer.color, abilityList [2].abilityColor)) { mySpriteRenderer.color = abilityList [2].abilityColor; attackSpriteRenderer.color = abilityList [2].abilityColor; bulletPrefab.GetComponent <SpriteRenderer> ().color = abilityList [2].abilityColor; dustPuff.GetComponent <ParticleSystem> ().startColor = abilityList [2].abilityColor; } else { mySpriteRenderer.color = new Color(1, 1, 1); attackSpriteRenderer.color = new Color(1, 1, 1); bulletPrefab.GetComponent <SpriteRenderer> ().color = new Color(1, 1, 1); dustPuff.GetComponent <ParticleSystem> ().startColor = new Color(1, 1, 1); } } } }