Exemple #1
0
    public void TakeAHeart()
    {
        int lifeCount = 3;

        for (int i = 2; i >= 0; i--)
        {
            if (lifes[i])
            {
                lifes[i]  = false;
                lifeCount = i;
                AudioManager.GetInstance().Play("sfx-dano");
                break;
            }
        }

        if (!lifes[0])
        {
            AudioManager.GetInstance().Play("bgm-morte");
            DeathMenu.GetInstance().Open();
            return;
        }

        LevelCompletedMenu.GetInstance().SetLifeText(lifeCount);
        FindObjectOfType <LifeManager>().SetHearts(lifes);
    }
Exemple #2
0
 public void _on_AnimationPlayer_animation_finished(string animationName)
 {
     if (animationName == "Death")
     {
         DeathMenu.ShowMenu();
     }
 }
Exemple #3
0
    //private bool isAlive = true;

    void Start()
    {
        scoreText.text = "Hello";
        player         = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMotor>();
        deathMenu      = GameObject.FindGameObjectWithTag("UserInterface").GetComponentInChildren <DeathMenu>(true);
        startTime      = Time.time;
    }
Exemple #4
0
    //knockback testing
    //public Rigidbody2D rb2D;


    // Use this for initialization
    void Start()
    {
        Death      = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <DeathMenu>();
        invertGrav = gravity * airTime;
        controller = GetComponent <BoxCollider2D>();
        //knockback testing
        //rb2D = GetComponent<Rigidbody2D>();
    }
Exemple #5
0
 // Use this for initialization
 void Start()
 {
     deathMenu               = GameObject.FindGameObjectWithTag("Death").GetComponent <DeathMenu>();
     canvas                  = GetComponent <Canvas>();
     playerHealth            = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHealth>();
     deathMenu.highscore     = PlayerPrefs.GetFloat("highscore", deathMenu.highscore);
     pauseHighScoreText.text = "High Score: " + deathMenu.highscore.ToString();
 }
    public void Die()
    {
        Instantiate(deathExplosion, this.transform.position, this.transform.rotation);
        PlayerData.Instance.isAlive = false;
        DeathMenu dm = FindObjectOfType <DeathMenu>();

        dm.playDeathScreen();
        this.gameObject.SetActive(false);
    }
Exemple #7
0
    private void Start()
    {
        menu  = GetComponent <DeathMenu>();
        stage = CreditsStage.Idle;

        style      = new GUIStyle();
        titleWidth = style.CalcSize(new GUIContent(title)).x + 4f;
        //nameWidth = style.CalcSize(new GUIContent(name)).x * 1.2f;
    }
Exemple #8
0
 void Start()
 {
     animator   = GetComponent <Animator>();
     controller = GetComponent <CharacterController>();
     startTime  = Time.time;
     deathMenu  = GameObject.FindGameObjectWithTag("UserInterface").GetComponentInChildren <DeathMenu>(true);
     //deathMenu = GameObject.FindGameObjectWithTag("DeathMenu").GetComponent<DeathMenu>();
     soundManager = GameObject.FindGameObjectWithTag("SoundManager").GetComponent <SoundManager>();
     gameManager  = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>();
 }
Exemple #9
0
 public static void ShowMenu()
 {
     if (!menuOn)
     {
         DeathMenu deathMenu = (DeathMenu)GD.Load <PackedScene>("res://Assets/Objects/UI/Menus/DeathMenu.tscn").Instance();
         deathMenu.Modulate = Color.Color8(255, 255, 255, 150);
         Game.root.GetNode("CanvasLayer").AddChild(deathMenu);
         menuOn = true;
     }
 }
Exemple #10
0
    protected override void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
            return;
        }
        instance = this;

        base.Awake();
    }
Exemple #11
0
 // Start is called before the first frame update
 public void Awake()
 {
     if (_instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         _instance = this;
         SetVisible(isShown);
     }
 }
Exemple #12
0
    public void OnDeath()
    {
        GameController GameScript = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();

        if (GameScript.DeathCount >= 0)
        {
            GameScript.DeathCount = 0;
            Hide();
            RewardedAdsMenu.Show();

            return;
        }

        GameScript.DeathCount++;

        Hide();
        DeathMenu.Show();
    }
Exemple #13
0
    void Start()
    {
        if (GameObject.Find("SaveManager"))
        {
            curHealth = GameObject.Find("SaveManager").GetComponent <DataController>().gameData.health;

            if (SceneManager.GetActiveScene().buildIndex == GameObject.Find("SaveManager").GetComponent <DataController>().gameData.Scene)
            {
                //print("Scenes Matched - Loaded previous player location and rotation.");
                gameObject.GetComponent <Transform>().position = GameObject.Find("SaveManager").GetComponent <DataController>().gameData.location;
                gameObject.GetComponent <Transform>().rotation = GameObject.Find("SaveManager").GetComponent <DataController>().gameData.rotation;
            }
        }

        //else print("Scenes Did Not Match - Did not load previous player location and rotation.");
        if (autoHeal)
        {
            InvokeRepeating("healthRegen", 0, 1);          //Calls HealthRegen every second
        }
        healthBarScript = gameObject.GetComponent <HealthBarScript>() as HealthBarScript;
        deathMenu       = gameObject.GetComponent <DeathMenu>() as DeathMenu;
    }
Exemple #14
0
    void Awake()
    {
        currentLevel = this;

        track           = GameObject.Find("Track").transform;
        rowIndex        = 0;
        timer           = 0;
        tileScale       = 1;
        disappearPulses = 0;
        clickPulses     = 0;

        levelDifficulty = (Difficulty)debugDifficulty;
        defaultColor    = Color.white;
        quarterPulse    = debugPulse;
        tileScale       = levelTileScaling;

        source           = GetComponent <AudioSource> ();
        startTime        = Time.time;
        pulseActivations = new List <float> {
            debugPulse / 2, debugPulse
        };

        LevelController.pulsed   += DisappearRow;
        LevelController.pulsed   += PlayBeat;
        FinishTile.finishedLevel += LoadNextLevel;

        BarrierTile.barrierDeath += KillPlayer;
        barrier = GameObject.Find("BarrierCollider");

        GameObject menu = Resources.Load("UI/EscapeMenu") as GameObject;

        escapeMenu = GameObject.Instantiate(menu).GetComponent <EscapeMenu> ();
        escapeMenu.gameObject.SetActive(false);
        menu      = Resources.Load("UI/DeathMenu") as GameObject;
        deathMenu = GameObject.Instantiate(menu).GetComponent <DeathMenu> ();
        deathMenu.gameObject.SetActive(false);
        gameOver = false;
    }
Exemple #15
0
    public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
    {
        // Define conditional logic for each ad completion status:
        if (showResult == ShowResult.Finished)
        {
            GameController GameScript = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();
            GameScript.points *= 2;

            Hide();
            DeathMenu.Show();

            // Reward the user for watching the ad to completion.
        }
        else if (showResult == ShowResult.Skipped)
        {
            Hide();
            DeathMenu.Show();
            // Do not reward the user for skipping the ad.
        }
        else if (showResult == ShowResult.Failed)
        {
            Debug.LogWarning("The ad did not finish due to an error.");
        }
    }
 void Awake()
 {
     myRigidbody2D = GetComponent<Rigidbody2D>();
     deathMenu = FindObjectOfType<DeathMenu>();
     touch_enabled = true;
 }
Exemple #17
0
 public override void OnBackPressed()
 {
     Hide();
     DeathMenu.Show();
 }
Exemple #18
0
 void Start()
 {
     instance = this;
     anim     = GetComponent <Animator>();
 }
 void Awake()
 {
     inst = this;
 }
Exemple #20
0
    void OnTriggerEnter2D(Collider2D target)
    {
        if (this.tag == "Player")
        {
            if ((target.gameObject.tag == "Enemy") && (currentMeleeInvuln >= maxMeleeInvuln))
            {
                float myPosX        = this.transform.position.x;
                float myPosY        = this.transform.position.y;
                float enemyPosX     = target.gameObject.transform.position.x;
                float enemyPosY     = target.gameObject.transform.position.y;
                float knockbackVelX = knockbackForce;
                float knockbackVelY = knockbackForce;

                if (myPosX < enemyPosX)                   //enemy to the right
                {
                    knockbackVelX *= -1;
                }
                if (myPosY < enemyPosY)                 //enemy is above
                {
                    knockbackVelY *= -1;
                }

                body2d.velocity = new Vector2(knockbackVelX, knockbackVelY);

                collisionState.stunned     = true;             //stuns player temporarily
                collisionState.timeStunned = 0f;

                currentHP -= 1;                 //player always takes 1 damage.
                PlayerPrefs.SetInt("HP" + PlayerPrefs.GetInt("SelectedPlayer", 0), currentHP);
                currentMeleeInvuln = 0f;        //make player unable to take damage for a time;
            }
            if (currentHP < 1)
            {
                gameObject.SetActive(false);
                DeathMenu menu = (DeathMenu)deathCanvas.GetComponent("DeathMenu");
                menu.playerDeath();
                PlayerPrefs.SetInt("HP" + PlayerPrefs.GetInt("SelectedPlayer", 0), 2);
            }
        }
        else if (this.tag == "Enemy")
        {
            if ((target.gameObject.tag == "PlayerSword") && (currentMeleeInvuln >= maxMeleeInvuln))
            {
                Sword sword = target.gameObject.transform.parent.gameObject.GetComponent <Sword>();
                damage             = sword.damage;     //get damage amount from sword
                currentHP         -= damage;
                currentMeleeInvuln = 0f;
            }

            //GAA 5 MAR 2016 Note 1: added an if statement for nested enemy structures (e.g. Flying Enemy sprite with multiple colliders)
            if (currentHP < 1)
            {
                if (gameObject.transform.parent != null && gameObject.transform.parent.CompareTag("Enemy"))
                {
                    gameObject.transform.parent.gameObject.SetActive(false);
                }
                else
                {
                    gameObject.SetActive(false);
                }
            }

//			//GAA 5 MAR 2016 Note 2: Previous implementation of deactivating enemy gameobjects
//			if(currentHP < 1){
//				gameObject.SetActive (false);
//			}
        }
        else if (this.tag == "CL2Boss")         //added by ivan on 03/31/2016 for boss Testing
        {
            if ((target.gameObject.tag == "PlayerSword") && (currentMeleeInvuln >= maxMeleeInvuln) && this.gameObject.GetComponent <FrogTongue>().autostart == true)
            {
                Sword sword = target.gameObject.transform.parent.gameObject.GetComponent <Sword>();
                //damage = sword.damage; //get damage amount from sword
                damage = 1;
                this.gameObject.GetComponent <FrogTongue> ().hit = true;
                currentHP -= damage;
                //StartCoroutine ("damageAnimation");
                //StartCoroutine("damageAnim", this.gameObject.transform.parent);
                //damageAnimHandler(this.gameObject.transform.parent.FindChild("sample_boss_head"), "clBoss");
                object[] parameters = new object[3] {
                    this.gameObject.transform.parent.FindChild("sample_boss_head"), Color.red, Color.magenta
                };
                StartCoroutine("damageAnim", parameters);

                currentMeleeInvuln = 0f;
            }
            if (currentHP < 1)
            {
                Debug.Log("Here");
                object[] parameters = new object[4] {
                    this.gameObject.transform.parent.FindChild("sample_boss_head"), Color.white, Color.clear, "death"
                };
                StartCoroutine("damageAnim", parameters);

                /*
                 * if (gameObject.transform.parent != null && gameObject.transform.parent.CompareTag ("CL2Boss")) {
                 *      gameObject.transform.parent.gameObject.SetActive (false);
                 * } else {
                 *      //gameObject.SetActive (false);//disables just tongue
                 *      gameObject.transform.parent.gameObject.SetActive (false);//disables head and tongue
                 * }
                 */
            }
        }
    }
Exemple #21
0
 public void Start()
 {
     instance = this;
     PlayerController.instance.playerCharacter.health.died += ShowDeathMenu;
 }