//Revives the player, and moves the submarine upward private IEnumerator ReviveProcess() { //Change the texture to intact, and play the revive particle subRenderer.sprite = subTextures[currentSkinID * 2 + 1]; reviveParticle.Play(); //Reset rotation, and move the submarine up newRotation = new Vector3(0, 0, 0); this.transform.eulerAngles = newRotation; StartCoroutine(FunctionLibrary.MoveElementBy(this.transform, new Vector2(0, Mathf.Abs(this.transform.position.y - maxDepth)), 0.5f)); yield return(new WaitForSeconds(0.5f)); //Reset states playerStatus = PlayerStatus.Idle; playerState = PlayerState.Enabled; playerVulnerability = PlayerVulnerability.Enabled; bubbles.Play(); yield return(new WaitForSeconds(0.5f)); powerupUsage = PowerupUsage.Enabled; reviveParticle.Clear(); }
void SharpCamera(PowerupUsage _info) { if (_info.Value == Powerup.Sharpshooter && (GoalCamera.instance.stateMachine.current == ThrowerCameraStates.Init.instance)) { GoalCamera.instance.stateMachine.changeState = ThrowerCameraStates.Sharpshooter.instance; } }
public void OnPowerUpUsed(PowerupUsage _info) { if (PowerupUsed != null) { PowerupUsed(_info); } }
void TriggerBillboard(PowerupUsage _info) { nextBillboards.Clear(); nextBillboards.Add(powerupBillboard); nextBillboards.Add(billboards[_info.AbsId]); nextBillboards.Add(idleBillboard); countdown = 0.001f; }
//Deactivates the extra speed submarine effects public void DisableExtraSpeed() { extraSpeedFront.gameObject.SetActive(false); extraSpeedTail.gameObject.SetActive(false); CollapseShield(); powerupUsage = PowerupUsage.Enabled; }
//Called when the player enters a triggerer zone void OnTriggerEnter2D(Collider2D other) { //If the submarine is collided with a coin if (other.tag == "Coin") { //Notify the level manager, and disable the coin's renderer and collider levelManager.CoinCollected(other.transform.position); other.GetComponent <Renderer>().enabled = false; other.GetComponent <Collider2D>().enabled = false; AudioManager.Instance.PlayCoinCollected(); } //If the submarine is collided with an obstacle else if (other.tag == "Obstacle") { //Notify the level manager, and disable the obstacle's renderer and collider levelManager.Collision(other.name, other.transform.position); other.GetComponent <Renderer>().enabled = false; other.GetComponent <Collider2D>().enabled = false; AudioManager.Instance.PlayExplosion(); //If the obstacle is a torpedo, disable it's child as well if (other.name == "Torpedo") { other.transform.FindChild("TorpedoFire").gameObject.SetActive(false); } //If the player is vulnerable if (playerVulnerability == PlayerVulnerability.Enabled) { //Sink the submarine powerupUsage = PowerupUsage.Disabled; playerVulnerability = PlayerVulnerability.Disabled; playerStatus = PlayerStatus.Sinking; subRenderer.sprite = subTextures[currentSkinID * 2]; bubbles.Stop(); } //If the player is shielded, collapse it else if (playerVulnerability == PlayerVulnerability.Shielded) { CollapseShield(); guiManager.ShowAvailablePowerups(); } } //If the submarine is collided with a powerup else if (other.tag == "Powerup") { //Notify the level manager, and disable the powerup's components other.GetComponent <Renderer>().enabled = false; other.GetComponent <Collider2D>().enabled = false; other.transform.FindChild("Trail").gameObject.SetActive(false); AudioManager.Instance.PlayPowerupCollected(); levelManager.PowerupPickup(other.name); } }
//Activates the extra speed submarine effects public void ActivateExtraSpeed() { extraSpeedFront.gameObject.SetActive(true); extraSpeedTail.gameObject.SetActive(true); RaiseShield(); playerVulnerability = PlayerVulnerability.Disabled; powerupUsage = PowerupUsage.Disabled; }
private Vector2 startingPos; //Holds the starting position of the submarine #endregion Fields #region Methods //Activates the extra speed submarine effects public void ActivateExtraSpeed() { extraSpeedFront.gameObject.SetActive(true); extraSpeedTail.gameObject.SetActive(true); RaiseShield(); playerVulnerability = PlayerVulnerability.Disabled; powerupUsage = PowerupUsage.Disabled; }
void Chrono(PowerupUsage _info) { if (_info.Value != Powerup.Concentracion || GameplayService.IsGoalkeeper()) { return; } GameObject aux = Instantiate(chronoPrefab) as GameObject; aux.transform.parent = Camera.main.transform; aux.transform.localPosition = new Vector3(0, 0, 1.5f); aux.transform.localRotation = Quaternion.identity; }
//Enables the submarine public void EnableSubmarine() { playerStatus = PlayerStatus.Idle; playerState = PlayerState.Enabled; playerVulnerability = PlayerVulnerability.Enabled; powerupUsage = PowerupUsage.Enabled; subRenderer.sprite = subTextures[currentSkinID * 2 + 1]; bubbles.Play(); StartCoroutine(FunctionLibrary.MoveElementBy(this.transform, new Vector2(0.4f, 0.2f), 0.5f)); }
public void SlipperyParticles(PowerupUsage _info) { if (_info.Value != Powerup.Resbaladiza) { return; } if (greasyParticles != null) { greasyParticles.GetComponent <MudBall>().Clear(); } greasyParticles = Instantiate(particulasSlipperyPrefab, BallPhysics.instance.transform.position, Quaternion.identity) as GameObject; greasyParticles.transform.parent = BallPhysics.instance.transform; }
private Vector2 startingPos; //Holds the starting position of the submarine //Used for initialization void Start() { newRotation = new Vector3(); startingPos = this.transform.position; playerStatus = PlayerStatus.Idle; playerState = PlayerState.Disabled; playerVulnerability = PlayerVulnerability.Disabled; powerupUsage = PowerupUsage.Disabled; rotationDiv = maxVerticalSpeed / maxRotation; currentSkinID = SaveManager.currentSkinID; subRenderer.sprite = subTextures[currentSkinID * 2 + 1]; }
//Resets the submarine public void Reset() { playerStatus = PlayerStatus.Idle; playerState = PlayerState.Disabled; playerVulnerability = PlayerVulnerability.Disabled; powerupUsage = PowerupUsage.Disabled; newRotation = new Vector3(0, 0, 0); subRenderer.sprite = subTextures[currentSkinID * 2 + 1]; bubbles.Stop(); bubbles.Clear(); this.transform.position = startingPos; this.transform.eulerAngles = newRotation; }
void Manoplas(PowerupUsage _info) { if (_info.Value != Powerup.Manoplas) { return; } Material[] materials = Goalkeeper.instance.transform.Find("Body").GetComponent <Renderer>().materials; lastMaterial = Goalkeeper.instance.transform.Find("Body").GetComponent <Renderer>().sharedMaterials[4]; materials[4] = glovePowerupMaterial; Goalkeeper.instance.transform.Find("Body").GetComponent <Renderer>().materials = materials; Transform left = Goalkeeper.instance.transform.Find("Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 Spine1/Bip01 Neck/Bip01 L Clavicle/Bip01 L UpperArm/Bip01 L Forearm/Bip01 L Hand"); Transform right = Goalkeeper.instance.transform.Find("Bip01/Bip01 Pelvis/Bip01 Spine/Bip01 Spine1/Bip01 Neck/Bip01 R Clavicle/Bip01 R UpperArm/Bip01 R Forearm/Bip01 R Hand"); glove1 = Instantiate(glovePowerupPrefabL, left.position, left.rotation) as GameObject; glove1.transform.parent = left; glove2 = Instantiate(glovePowerupPrefabR, right.position, right.rotation) as GameObject; glove2.transform.parent = right; }
//Used for initialization void Start() { newRotation = new Vector3(); startingPos = this.transform.position; playerStatus = PlayerStatus.Idle; playerState = PlayerState.Disabled; playerVulnerability = PlayerVulnerability.Disabled; powerupUsage = PowerupUsage.Disabled; rotationDiv = maxVerticalSpeed / maxRotation; currentSkinID = SaveManager.currentSkinID; subRenderer.sprite = subTextures[currentSkinID * 2 + 1]; }
//Revives the player, and moves the submarine upward private IEnumerator ReviveProcess() { //Change the texture to intact, and play the revive particle subRenderer.sprite = subTextures[currentSkinID * 2 + 1]; reviveParticle.Play(); //Reset rotation, and move the submarine up newRotation = new Vector3(0, 0, 0); this.transform.eulerAngles = newRotation; StartCoroutine(FunctionLibrary.MoveElementBy(this.transform, new Vector2(0, Mathf.Abs(this.transform.position.y - maxDepth)), 0.5f)); yield return new WaitForSeconds(0.5f); //Reset states playerStatus = PlayerStatus.Idle; playerState = PlayerState.Enabled; playerVulnerability = PlayerVulnerability.Enabled; bubbles.Play(); yield return new WaitForSeconds(0.5f); powerupUsage = PowerupUsage.Enabled; reviveParticle.Clear(); }
//Called when the player enters a triggerer zone void OnTriggerEnter2D(Collider2D other) { //If the submarine is collided with a coin if (other.tag == "Coin") { //Notify the level manager, and disable the coin's renderer and collider levelManager.CoinCollected(other.transform.position); other.GetComponent<Renderer>().enabled = false; other.GetComponent<Collider2D>().enabled = false; AudioManager.Instance.PlayCoinCollected(); } //If the submarine is collided with an obstacle else if (other.tag == "Obstacle") { //Notify the level manager, and disable the obstacle's renderer and collider levelManager.Collision(other.name, other.transform.position); other.GetComponent<Renderer>().enabled = false; other.GetComponent<Collider2D>().enabled = false; AudioManager.Instance.PlayExplosion(); //If the obstacle is a torpedo, disable it's child as well if (other.name == "Torpedo") other.transform.FindChild("TorpedoFire").gameObject.SetActive(false); //If the player is vulnerable if (playerVulnerability == PlayerVulnerability.Enabled) { //Sink the submarine powerupUsage = PowerupUsage.Disabled; playerVulnerability = PlayerVulnerability.Disabled; playerStatus = PlayerStatus.Sinking; subRenderer.sprite = subTextures[currentSkinID * 2]; bubbles.Stop(); } //If the player is shielded, collapse it else if (playerVulnerability == PlayerVulnerability.Shielded) { CollapseShield(); guiManager.ShowAvailablePowerups(); } } //If the submarine is collided with a powerup else if (other.tag == "Powerup") { //Notify the level manager, and disable the powerup's components other.GetComponent<Renderer>().enabled = false; other.GetComponent<Collider2D>().enabled = false; other.transform.FindChild("Trail").gameObject.SetActive(false); AudioManager.Instance.PlayPowerupCollected(); levelManager.PowerupPickup(other.name); } }
//Resets the submarine public void Reset() { playerStatus = PlayerStatus.Idle; playerState = PlayerState.Disabled; playerVulnerability = PlayerVulnerability.Disabled; powerupUsage = PowerupUsage.Disabled; newRotation = new Vector3(0, 0, 0); subRenderer.sprite = subTextures[currentSkinID * 2 + 1]; bubbles.Stop(); bubbles.Clear(); this.transform.position = startingPos; this.transform.eulerAngles = newRotation; }
//Enables the submarine public void EnableSubmarine() { playerStatus = PlayerStatus.Idle; playerState = PlayerState.Enabled; playerVulnerability = PlayerVulnerability.Enabled; powerupUsage = PowerupUsage.Enabled; subRenderer.sprite = subTextures[currentSkinID * 2 + 1]; bubbles.Play(); StartCoroutine(FunctionLibrary.MoveElementBy(this.transform, new Vector2(0.4f, 0.2f), 0.5f)); }
//Deactivates the extra speed submarine effects public void DisableExtraSpeed() { extraSpeedFront.gameObject.SetActive(false); extraSpeedTail.gameObject.SetActive(false); CollapseShield(); powerupUsage = PowerupUsage.Enabled; }
public void UsePowerup(Powerup _powerup) { int id = (int)_powerup; bool success = false; PowerupUsage info = new PowerupUsage(); info.AbsId = id; info.Id = id; //si es de portero, se cambia mas tarde info.Own = false; info.Value = _powerup; bool isGoalkeeperPowerup = id >= MAXPOWERUPSTIRADOR; //proteccion para no usar 2 powerups al mismo tiempo if ((!isGoalkeeperPowerup && PowerupService.instance.usedShooterPowerup) || (isGoalkeeperPowerup && PowerupService.instance.usedGoalkeeperPowerup)) { return; } if (GameplayService.IsGoalkeeper()) { if (id >= MAXPOWERUPSTIRADOR) { success = m_ownInventory.UsePowerup(id - MAXPOWERUPSTIRADOR, GameMode.GoalKeeper); info.Own = true; } else { success = rivalInventory.UsePowerup(id, GameMode.Shooter); } } else { if (id >= MAXPOWERUPSTIRADOR) { success = rivalInventory.UsePowerup(id - MAXPOWERUPSTIRADOR, GameMode.GoalKeeper); } else { success = m_ownInventory.UsePowerup(id, GameMode.Shooter); info.Own = true; } } if (success) { if (id >= MAXPOWERUPSTIRADOR) { GoalkeeperPowerup = _powerup; info.Mode = GameMode.GoalKeeper; info.Id = id - MAXPOWERUPSTIRADOR; } else { ShooterPowerup = _powerup; info.Mode = GameMode.Shooter; } //lanzar evento OnPowerUpUsed(info); PersistenciaManager.instance.SavePowerUps(); } }
void PowerupCartela(PowerupUsage _info) { bool goalkeeper = _info.AbsId >= PowerupService.MAXPOWERUPSTIRADOR; float posPortero = 0.18f; float posLanzador = 0.8f; float posVPortero = 0.3f; float posVLanzador = 0.7f; // crear el texto de la cartela de powerup GameObject powerupGO = new GameObject(); powerupGO.AddComponent <GUITexture>(); powerupGO.layer = 14; powerupGO.transform.position = new Vector3(goalkeeper ? -1 : 2, !goalkeeper ? posVPortero : posVLanzador, 200); powerupGO.transform.localScale = new Vector3(0, 0, 1); powerupGO.GetComponent <GUITexture>().texture = goalkeeper ? cartelaPowerupPortero : cartelaPowerupLanzador; powerupGO.name = "cartelaPowerUp" + (goalkeeper ? "Portero" : "Lanzador") + "Texto"; float ratio = 0.25f;//(float)(goalkeeper ? cartelaPowerupPortero : cartelaPowerupLanzador).height / (float)(goalkeeper ? cartelaPowerupPortero : cartelaPowerupLanzador).width; float hSize = (940 * ifcBase.scaleFactor / 2f); float escalaTexto = 1.3f; powerupGO.GetComponent <GUITexture>().pixelInset = new Rect(hSize * escalaTexto / -2, hSize * ratio * escalaTexto / -2, hSize * escalaTexto, hSize * ratio * escalaTexto); //new Rect(hSize / -2, hSize * ratio / -2, hSize, hSize * ratio); // crear el icono de la cartela de powerup hSize *= 0.5f; // escala para el icono GameObject iconGO = GameObject.Instantiate(powerupGO, powerupGO.transform.position, Quaternion.identity) as GameObject; float iconRatio = (float)powerupCartelas[_info.AbsId].height / (float)powerupCartelas[_info.AbsId].width; iconGO.GetComponent <GUITexture>().texture = powerupCartelas[_info.AbsId]; iconGO.GetComponent <GUITexture>().pixelInset = new Rect(hSize / -2, hSize * iconRatio / -2, hSize, hSize * iconRatio); iconGO.name = "cartelaPowerUp" + (goalkeeper ? "Portero" : "Lanzador") + "Imagen"; // ajustar la posicion del texto en funcion del tipo de powerup Rect newPixelInset = powerupGO.GetComponent <GUITexture>().pixelInset; newPixelInset.x += (goalkeeper ? 1 : -1) * (iconGO.GetComponent <GUITexture>().pixelInset.width + 160 * ifcBase.scaleFactor); // <= desplazar el texto a izda o dcha el ancho del icono de powerup powerupGO.GetComponent <GUITexture>().pixelInset = newPixelInset; //SuperTweener.InWaitOut(powerupGO, 0.5f, new Vector3(0, 0.5f, 2f), 0.5f, (GameObject _target3) => { Destroy(powerupGO);}); new SuperTweener.move(powerupGO, 0.25f, new Vector3(goalkeeper ? posPortero : posLanzador, !goalkeeper ? posVPortero : posVLanzador, 300f), SuperTweener.CubicOut, (_target) => { new SuperTweener.move(powerupGO, 0.5f, new Vector3(goalkeeper ? posPortero : posLanzador, !goalkeeper ? posVPortero : posVLanzador, 300f), null, (_target2) => { new SuperTweener.move(powerupGO, 0.25f, new Vector3(!goalkeeper ? -1f : 2f, !goalkeeper ? posVPortero : posVLanzador, 300f), SuperTweener.CubicIn, (_target3) => { Destroy(powerupGO); }); }); }); new SuperTweener.move(iconGO, 0.25f, new Vector3(goalkeeper ? posPortero : posLanzador, !goalkeeper ? posVPortero : posVLanzador, 200f), SuperTweener.CubicOut, (_target) => { new SuperTweener.move(iconGO, 0.5f, new Vector3(goalkeeper ? posPortero : posLanzador, !goalkeeper ? posVPortero : posVLanzador, 200f), null, (_target2) => { new SuperTweener.move(iconGO, 0.25f, new Vector3(!goalkeeper ? -1f : 2f, !goalkeeper ? posVPortero : posVLanzador, 200f), SuperTweener.CubicIn, (_target3) => { Destroy(iconGO); }); }); }); }