public GameObject gameMaster; //GameMaster object that is currently in the scene.
	
	/// <summary>
	/// Deals damage to the body and checks if body is dead.
	/// </summary>
	/// <param name = 'damageAmount'> Damage amount to subtract from health </param>
	public void damage(int damageAmount)
	{
		gameMaster.SendMessage(ADD_ENEMY_DAMAGE_SCORE_METHOD,scorePerDestroy);
		//playAudio();
		//If body is still alive
		if(dead == false)
		{
			health -= damageAmount; //deal damage

			//If body is dead
			if(health <= deadHealth)
			{
				dead = true;
				gameMaster.SendMessage(ADD_ENEMY_DAMAGE_SCORE_METHOD,scorePerDestroy*2);
				gameMaster.SendMessage(ENTITY_DEATH_INFORM_METHOD); //send message to GameMaster informing of death

				GameObject scorePopUp = Instantiate (scorePopUpPrefab) as GameObject;

				Vector3 popUpPosition = Vector3.zero;
				for(int i = 0 ;i<6;i++)
				{
					popUpPosition.x += transform.GetChild(i).position.x;
					popUpPosition.y += transform.GetChild(i).position.y;
				}
				popUpPosition.x /= 6f;
				popUpPosition.y /= 6f;

				ScorePopUp popUp = new ScorePopUp(popUpPosition,(scorePerDestroy*2)+"");
				scorePopUp.SendMessage(ANIMATE_POP_UP_METHOD,popUp);
			}
		}
	}
Ejemplo n.º 2
0
    public GameObject gameMaster;                                               //GameMaster object that is currently in the scene.

    /// <summary>
    /// Deals damage to the body and checks if body is dead.
    /// </summary>
    /// <param name = 'damageAmount'> Damage amount to subtract from health </param>
    public void damage(int damageAmount)
    {
        gameMaster.SendMessage(ADD_ENEMY_DAMAGE_SCORE_METHOD, scorePerDestroy);
        //playAudio();
        //If body is still alive
        if (dead == false)
        {
            health -= damageAmount;             //deal damage

            //If body is dead
            if (health <= deadHealth)
            {
                dead = true;
                gameMaster.SendMessage(ADD_ENEMY_DAMAGE_SCORE_METHOD, scorePerDestroy * 2);
                gameMaster.SendMessage(ENTITY_DEATH_INFORM_METHOD);                 //send message to GameMaster informing of death

                GameObject scorePopUp = Instantiate(scorePopUpPrefab) as GameObject;

                Vector3 popUpPosition = Vector3.zero;
                for (int i = 0; i < 6; i++)
                {
                    popUpPosition.x += transform.GetChild(i).position.x;
                    popUpPosition.y += transform.GetChild(i).position.y;
                }
                popUpPosition.x /= 6f;
                popUpPosition.y /= 6f;

                ScorePopUp popUp = new ScorePopUp(popUpPosition, (scorePerDestroy * 2) + "");
                scorePopUp.SendMessage(ANIMATE_POP_UP_METHOD, popUp);
            }
        }
    }
	public void animatePopUp (ScorePopUp popUp)
	{
		GetComponent<TextMesh>().text = popUp.score;
		startScale = transform.localScale;
		endScale = startScale * 3f;
		endScale.z = 1f;
		
		startPosition = popUp.startPosition;
		endPosition = startPosition + new Vector3(0,2f,0);

		startColor = renderer.material.color;
		endColor = renderer.material.color;
		endColor.a = 0f;

		animate = true;
	}
Ejemplo n.º 4
0
    public void animatePopUp(ScorePopUp popUp)
    {
        GetComponent <TextMesh>().text = popUp.score;
        startScale = transform.localScale;
        endScale   = startScale * 3f;
        endScale.z = 1f;

        startPosition = popUp.startPosition;
        endPosition   = startPosition + new Vector3(0, 2f, 0);

        startColor = renderer.material.color;
        endColor   = renderer.material.color;
        endColor.a = 0f;

        animate = true;
    }
Ejemplo n.º 5
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (playerPassed)
        {
            return;
        }

        if (other.gameObject.CompareTag("Player"))
        {
            EventManager.OnPlatformPass?.Invoke();
            EventManager.OnPlayerScore?.Invoke(gameManager.HoleScoreIncrease);

            ScorePopUp popUp = Instantiate(addScorePopUp, transform.position, Quaternion.identity);
            popUp.InitializePopUp(gameManager.HoleScoreIncrease);
            playerPassed = true;
        }
    }
Ejemplo n.º 6
0
    private void HandleDestroy()
    {
        EventManager.OnPlayerScore?.Invoke(gameManager.EnemyScoreIncrease);
        EventManager.OnEnemyKill?.Invoke();

        CameraShake.Instance.TriggerShake();

        GameObject dead = Instantiate(deadEnemy, transform.parent.position, Quaternion.identity);

        dead.transform.parent = transform.parent.parent;

        ScorePopUp popUp = Instantiate(addScorePopUp, transform.position, Quaternion.identity);

        popUp.InitializePopUp(gameManager.EnemyScoreIncrease);

        SoundManager.Instance.PlaySound("EnemyDeath");

        Destroy(transform.parent.gameObject);
    }