Death() public method

public Death ( ) : void
return void
Ejemplo n.º 1
0
    //Kill all the enemy in the scene
    public override void Activate()
    {
        playerSkill.decreaseBar(skillCost);

        bool playerFacing = player.GetComponent <PlayerMovement>().GetFacingRight();

        enemy = GameObject.FindGameObjectsWithTag("Enemy");
        for (int i = 0; i < enemy.Length; i++)
        {
            enemyHealth = enemy[i].GetComponent <EnemyHealth>();
            if (playerFacing)               //Player facingRight
            //Destroy all enemies on the right side of the player
            {
                if (enemy[i].transform.position.x > player.transform.position.x)
                {
                    enemyHealth.skillValue = 0;                     //So that when we kill it, our mana doesnt go up
                    enemyHealth.Death();
                }
            }
            else               //Player facingLeft
                               //Destroy all enemies on the left side of the player
            {
                if (enemy[i].transform.position.x < player.transform.position.x)
                {
                    enemyHealth.skillValue = 0;                     //So that when we kill it, our mana doesnt go up
                    enemyHealth.Death();
                }
            }
        }
        KillOneSideTest(playerFacing);
        Debug.Log("One side activated");
    }
Ejemplo n.º 2
0
 void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.layer == 10 && scale < maxSize)
     {
         EnemyHealth enemyHealth = col.gameObject.GetComponent <EnemyHealth> ();
         enemyHealth.Death(col.transform.position, col.transform.position - transform.position);
     }
 }
Ejemplo n.º 3
0
    public void DestroyEnemy(int entityID)
    {
        GameObject obj = this.enemyArray[entityID];

        enemyArray.Remove(entityID);

        EnemyHealth health = obj.GetComponent <EnemyHealth>();

        health.Death();
    }
Ejemplo n.º 4
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag != "Enemy")
        {
            Destroy(gameObject);
        }

        else
        {
            EnemyHealth eh = other.GetComponent <EnemyHealth>();
            eh.Death();
            Destroy(gameObject);
        }
    }
Ejemplo n.º 5
0
    //Kill all the enemy in the scene
    public override void Activate()
    {
        playerSkill.decreaseBar(skillCost);

        enemy = GameObject.FindGameObjectsWithTag("Enemy");
        for (int i = 0; i < enemy.Length; i++)
        {
            enemyHealth            = enemy[i].GetComponent <EnemyHealth>();
            enemyHealth.skillValue = 0;             //So that when we kill it, our mana doesnt go up
            enemyHealth.Death();
        }
        Debug.Log("Kill All activated");
        KillAllTest();
    }
Ejemplo n.º 6
0
    void KillMonster(int monsterID)
    {
        GameObject monster = FindMonsterWithID(monsterID);

        DeleteServerGameobjects(GameSettings.MONSTER_TYPE, monsterID);

        if (monster != null)
        {
            EnemyHealth enemyHealth = monster.GetComponent <EnemyHealth>();
            enemyHealth.currentHealth = 0;
            enemyHealth.SetHealthImage();
            enemyHealth.isDead = true;
            enemyHealth.Death();
        }
    }
Ejemplo n.º 7
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         PlayerHealth playerHealth = other.gameObject.GetComponent <PlayerHealth>();
         audioSource.PlayOneShot(clip);
         playerHealth.Death();
     }
     else if (other.gameObject.tag == "Enemy")
     {
         EnemyHealth enemyHealth = other.gameObject.GetComponent <EnemyHealth>();
         audioSource.PlayOneShot(clip);
         enemyHealth.Death();
     }
 }
Ejemplo n.º 8
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Enemy")
     {
         Debug.Log("TRIGGEEEERED");
     }
     if (timer > 0)
     {
         Debug.Log(">0");
         EnemyHealth enemy = other.GetComponent <EnemyHealth>();
         if (enemy != null)
         {
             enemy.Death();
         }
     }
 }
Ejemplo n.º 9
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         PlayerHealth playerHealth = other.gameObject.GetComponent <PlayerHealth>();
         //playerHealth.Death ();
         playerHealth.TakeDamage(playerHealth.startingHealth);
         CmdTellServerWhoGotShot(other.gameObject.name, playerHealth.startingHealth);
         audioSource.PlayOneShot(clip);
     }
     else if (other.gameObject.tag == "Enemy")
     {
         EnemyHealth enemyHealth = other.gameObject.GetComponent <EnemyHealth> ();
         enemyHealth.Death();
         audioSource.PlayOneShot(clip);
     }
 }
Ejemplo n.º 10
0
    void Update()
    {
        /*<-----------Attack---------->*/
        // Add the time since Update was last called to the timer.
        timer += Time.deltaTime;

        // If the timer exceeds the time between attacks, the player/tower is in range and this enemy is alive...
        if (timer >= timeBetweenAttacks && InRange && enemyHealth.currentHealth > 0)
        {
            // ... attack.
            Attack();
        }

        if (!playerLockOn)
        {
            if (turretHealth.currenthealth < 0)
            {
                enemyHealth.Death();
            }
        }
        else if (playerHealth.currentHealth <= 0)
        {
            // ... tell the animator the player is dead.
            anim.SetTrigger("PlayerDead");
        }

        /*<----------Movement------------>*/

        if (!playerLockOn && enemyHealth.currentHealth > 0 && turretHealth.currenthealth > 0)
        {
            // If the enemy and the player have health left...
            // ... set the destination of the nav mesh agent to the base.
            nav.SetDestination(turret.transform.position);
        }
        else if (playerLockOn && enemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0)
        {
            nav.SetDestination(player.transform.position);
        }
        // Otherwise...
        else
        {
            // ... disable the nav mesh agent.
            nav.enabled = false;
        }
    }
Ejemplo n.º 11
0
    void OnTriggerEnter(Collider other)
    {
        int nbExplosion = 0;

        if (other.gameObject.tag == "Monster" && nbExplosion == 0)
        {
            EnemyHealth enemyHeatlh = other.GetComponent <EnemyHealth> ();
            enemyHeatlh.Death();

            PyroExplode Pyro = this.gameObject.AddComponent("PyroExplode") as PyroExplode;

            Pyro.setTransform(transform);
            Pyro.Generate();
            Pyro.gameObject.tag = "PyroClone";

            Destroy(this.gameObject);
        }
    }
Ejemplo n.º 12
0
 /// <summary>
 /// Unity Function. Checks if another game object' collider went in the collider of this game object.
 ///
 /// Depending on the flags set to true, certain types of objects will be destroyed/killed.
 /// </summary>
 /// <param name="other">Other Game Object's Collider.</param>
 void OnTriggerEnter2D(Collider2D other)
 {
     if (killsPlayer && other.gameObject.GetComponent <PlayerYuni> () != null)
     {
         Debug.Log("Entered Player Death");
         PlayerHealth player = other.gameObject.GetComponent <PlayerHealth> ();
         player.isAlive = false;
     }
     else if (killsEnemy && other.gameObject.CompareTag(Tags.ENEMY))
     {
         EnemyHealth enemy = other.gameObject.GetComponent <EnemyHealth> ();
         enemy.Death();
     }
     else if (killsSkyPiece && other.gameObject.CompareTag(Tags.SKY_FRAGMENT_PIECE))
     {
         SkyFragmentPiece piece = other.gameObject.GetComponent <SkyFragmentPiece> ();
         piece.transform.position = piece.GetDetachedManagerParent().transform.position;
     }
 }
Ejemplo n.º 13
0
    // Update is called once per frame
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject == player)
        {
            winGame.text     = "GAME WON";
            winGame.fontSize = 65;
            winGame.color    = new Color(0.44f, 1f, 0.86f);
            restart.SetActive(true);

            GameObject[] allEnemies = GameObject.FindGameObjectsWithTag("Enemy");
            foreach (GameObject enemy in allEnemies)
            {
                EnemyHealth health = enemy.GetComponent <EnemyHealth>();
                health.Death();
                player.GetComponent <PlayerMovement> ().enabled = false;
                player.GetComponent <PlayerShooting> ().enabled = false;
            }
            ;
        }
    }
Ejemplo n.º 14
0
    /// <summary>
    /// Deprecated, trigger should be used.
    /// </summary>
    /// <param name="other">Other Game Object's Collider.</param>
    void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.CompareTag(Tags.PLAYER))
        {
            PlayerHealth player = other.gameObject.GetComponent <PlayerHealth> ();
            player.isAlive = false;
        }
        else if (other.gameObject.CompareTag(Tags.ENEMY))
        {
            EnemyHealth enemy = other.gameObject.GetComponent <EnemyHealth> ();
            enemy.Death();
        }
        else if (other.gameObject.CompareTag(Tags.SKY_FRAGMENT_PIECE))
        {
            SkyFragmentPiece piece = other.gameObject.GetComponent <SkyFragmentPiece> ();
            piece.transform.position = piece.GetDetachedManagerParent().transform.position;
        }
//		else
//			Destroy (other.gameObject);
    }
Ejemplo n.º 15
0
    private IEnumerator MovePointer(float numeratorDestination, float denominatorDestination)
    {
        bool isCorrect = false;

//		pauseController.PauseGame ();
        GameController_v7.Instance.GetPauseController().Pause();
//		cameraZoom.ZoomTowards (gameObject.transform.position);
        this.AdjustCamera();
        highlightRenderer.enabled          = true;
        highlightRenderer.sortingLayerName = "Needle";
        highlightRenderer.sortingOrder     = (-1);
        highlightRenderer.SetPosition(0, pointer.transform.position);

        this.pointer.SetActive(true);
        this.pointer.GetComponent <PointerLabel> ().SetValue(0, (int)denominatorDestination);
        float pointerOriginalPosX = this.pointer.transform.localPosition.x;

        bool isPositiveMovement = (this.targetValNumerator > this.initialCurrentPointerNumerator);
        int  multiplier         = 1;

        if (isPositiveMovement)
        {
            multiplier = 1;
        }
        else
        {
            multiplier = -1;
        }

        this.currentPointerNumberLine.IsPositiveMovement(isPositiveMovement);
        this.currentPointerNumberLine.SetLineLength(this.lineLength);

        this.currentPointerNumberLine.ShowSmallerFraction();

        this.currentPointerNumberLine.Partition((int)denominatorDestination + 1);
        float xCoords = this.currentPointerNumberLine.GetSegments()[0].transform.localPosition.x + multiplier * (numeratorDestination * Vector2.Distance(this.currentPointerNumberLine.GetSegments()[0].transform.position, this.currentPointerNumberLine.GetSegments()[1].transform.position));
        float answer  = (this.initialCurrentPointerNumerator / this.initialCurrentPointerDenominator) + ((numeratorDestination * multiplier) / denominatorDestination);

        if (Mathf.Approximately(answer, (this.targetValNumerator / this.targetValDenominator)))
        {
            isCorrect = true;
        }

        float        startTime           = Time.time;
        Vector2      pos                 = new Vector2(xCoords, this.pointer.transform.localPosition.y);
        float        journeyLength       = Vector2.Distance(this.pointer.transform.localPosition, pos);
        PointerLabel currentPointerLabel = pointer.GetComponent <PointerLabel> ();
        int          currentMaxNumerator = Mathf.Abs(currentPointerLabel.GetDenominator());

        highlightRenderer.positionCount = 2;
        Vector3[] listPositions = new Vector3[2];

        Physics2D.autoSimulation = false;
        while (pos.x != this.pointer.transform.localPosition.x)
        {
            Physics2D.Simulate(POINTER_MOVEMENT_SPEED * Time.unscaledDeltaTime);
            this.pointer.transform.localPosition = Vector2.MoveTowards(this.pointer.transform.localPosition, pos, POINTER_MOVEMENT_SPEED * Time.unscaledDeltaTime);

            listPositions [0] = new Vector3(currentPointerNumberLine.GetComponent <LineRenderer>().GetPosition(0).x, highlightTransform.localPosition.y, -1.0f);

            listPositions [1] = new Vector3(pointer.transform.localPosition.x, highlightTransform.localPosition.y, -1.0f);             //pointer.transform.position.y, (float)-0.1);
            highlightRenderer.SetPositions(listPositions);



            Debug.Log("Numerator: " + Mathf.Abs(currentPointerLabel.GetNumerator()));
            Debug.Log("Max Numerator: " + currentMaxNumerator);

            if (Mathf.Abs(currentPointerLabel.GetNumerator()) >= currentMaxNumerator)
            {
                currentPointerNumberLine.ExtendLine();
                currentMaxNumerator++;
            }

            yield return(new WaitForSeconds(0.0f));
        }
        this.pointer.transform.localPosition = pos;
        this.pointer.GetComponent <PointerLabel> ().SetValue((int)numeratorDestination, (int)denominatorDestination);

        Physics2D.autoSimulation = true;
//		GameController_v7.Instance.GetPauseController ().Continue ();
//		cameraZoom.shouldZoomIn = false;
//		cameraZoom.shouldZoomOut = true;

//		if (Mathf.Approximately (this.pointer.transform.position.x, this.targetPointer.transform.position.x)) {
        if (isCorrect)
        {
//			StartCoroutine (this.UpdateHighlight ());
//			yield return new WaitForSeconds (CORRECT_DELAY); // If CORRECT
            yield return(new WaitForSecondsRealtime(CORRECT_DELAY));

            this.resultsUI.PlaySuccess();
//			GameController_v7.Instance.GetPauseController ().Continue ();
//			StopCoroutine (this.UpdateHighlight ());

            // TODO: uncomment on tally fix :(
//            if (entry.isSimilar == null)
//                entry.isSimilar = ((int)targetValDenominator == (int)denominatorDestination) ? true : false;
//            if (entry.isProper == null)
//                entry.isProper = ((int)numeratorDestination < (int)denominatorDestination) ? true : false;
//            if (entry.initialValue == null)
//                entry.initialValue = new Tuple<int, int>((int)initialCurrentPointerNumerator, (int)initialCurrentPointerDenominator);
//            if (entry.targetValue == null)
//                entry.targetValue = new Tuple<int, int>((int)targetValNumerator, (int)targetValDenominator);
//            if (entry.actualAnswer == null)
//                entry.actualAnswer = new Tuple<int, int>(Math.Abs((int)targetValNumerator - (int)initialCurrentPointerNumerator), (int)targetValDenominator);
//            if (entry.attemptedAnswers == null)
//                entry.attemptedAnswers = new List<Tuple<int, int>>();
//
//            entry.isDeadThroughLCD = isNumberLineUpdated;
//            entry.attemptedAnswers.Add(new Tuple<int, int>((int)numeratorDestination, (int)denominatorDestination));
//            entry.numberOfAttempts++;
//            entry.timeSolved = System.DateTime.Now;
//			if (initialCurrentPointerDenominator == targetValDenominator)
//				entry.topic = EnemyEntry.Topic.Similar;
//			else
//				entry.topic = EnemyEntry.Topic.Dissimilar;

            enemyHealth.Death();
            yield return(new WaitForSecondsRealtime(1.0f));

            this.ReturnCamera();
            GameController_v7.Instance.GetPauseController().Continue();
        }
        else
        {
            // TODO: temporarily commented out, conflict when hitting 2 enemies :'(
            isNumberLineUpdated = false;
//            if (entry.isSimilar == null)
//                entry.isSimilar = ((int)targetValDenominator == (int)denominatorDestination) ? true : false;
//            if (entry.isProper == null)
//                entry.isProper = ((int)numeratorDestination < (int)denominatorDestination) ? true : false;
//            if (entry.initialValue == null)
//                entry.initialValue = new Tuple<int, int>((int)initialCurrentPointerNumerator, (int)initialCurrentPointerDenominator);
//            if (entry.targetValue == null)
//                entry.targetValue = new Tuple<int, int>((int)targetValNumerator, (int)targetValDenominator);
//            if (entry.actualAnswer == null)
//                entry.actualAnswer = new Tuple<int, int>(Mathf.Abs((int)targetValNumerator - (int)initialCurrentPointerNumerator), (int)targetValDenominator);
//            if (entry.attemptedAnswers == null)
//                entry.attemptedAnswers = new List<Tuple<int, int>>();
//            entry.isDeadThroughLCD = isNumberLineUpdated;
//            entry.attemptedAnswers.Add(new Tuple<int, int>((int)numeratorDestination, (int)denominatorDestination));
//            entry.numberOfAttempts++;


//            StartCoroutine (this.UpdateHighlight ());
            SoundManager.Instance.Play(AudibleNames.Results.MISTAKE, false);
            yield return(new WaitForSecondsRealtime(WRONG_DELAY));             // If WRONG

            this.ReturnCamera();
            GameController_v7.Instance.GetPauseController().Continue();
//			cameraZoom.shouldZoomIn = false;
//			cameraZoom.shouldZoomOut = true;
//			StopCoroutine (this.UpdateHighlight ());

            startTime     = Time.time;
            pos           = new Vector2(pointerOriginalPosX, this.pointer.transform.localPosition.y);
            journeyLength = Vector2.Distance(this.transform.localPosition, pos);
            listPositions = new Vector3[2];
            while (pos.x != this.pointer.transform.localPosition.x)
            {
                this.pointer.transform.localPosition = Vector2.MoveTowards(this.pointer.transform.localPosition, pos, 2 * POINTER_MOVEMENT_SPEED * Time.deltaTime);
                // Pointer movement speed of returning

                listPositions [0] = new Vector3(currentPointerNumberLine.GetComponent <LineRenderer>().GetPosition(0).x, highlightTransform.localPosition.y, -1.0f);
                listPositions [1] = new Vector3(pointer.transform.localPosition.x, highlightTransform.localPosition.y, highlightRenderer.transform.position.z);                 //pointer.transform.position.y, (float)-0.1);
                highlightRenderer.SetPositions(listPositions);

                yield return(new WaitForSeconds(0.0f));
            }
        }

        this.currentPointerNumberLine.PurgeSegments();
//		this.currentPointerNumberLine.gameObject.SetActive (false);
        this.currentPointerNumberLine.HideSmallerFraction();
//		this.pointer.SetActive (false);
        highlightRenderer.enabled = false;
        this.isPlaying            = false;
//        if (entry.timeWeaponRemoved == null)
//            entry.timeWeaponRemoved = new List<DateTime>();
//        entry.timeWeaponRemoved.Add(System.DateTime.Now);

//		DataManager.UpdateEnemyEntry(DataManager.GetEnemyLastKey(), entry);
//		Debug.Log ("<b>NUMBER OF ATTEMPTS: " + String.Join(",",DataManager.GetIntColumn (StringConstants.TableNames.ENEMY, StringConstants.ColumnNames.NUMBER_OF_ATTEMPTS)) + "</b>");
    }