Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (enemyHealth <= 0)
        {
            //this will create the death effect on the related object
            Instantiate(deathEffect, transform.position, transform.rotation);
            //added points to the player when enemy health reaches 0
            SocreManager.AddPoints(pointsOnDeath);
            //get the local scale of the enemy who died and compaire it with minimum size
            if (transform.localScale.y > minSize)
            {
                //create two game object clone of the boss enemy.
                try {
                    clone1 = Instantiate(bossPrefab, new Vector3(transform.position.x + 1f, transform.position.y, transform.position.z), transform.rotation) as GameObject;
                    clone2 = Instantiate(bossPrefab, new Vector3(transform.position.x - 1f, transform.position.y, transform.position.z), transform.rotation) as GameObject;
                } catch (System.Exception ex) {
                    StaticData.ErrorLogList.Add(ex.ToString());
                }

                //change its scale to half of the scale
                clone1.transform.localScale = new Vector3(transform.localScale.x * 0.5f, transform.localScale.y * 0.5f, transform.localScale.z * 0.5f);
                //give that boss enemy a helath of 10.
                clone1.GetComponent <BossHealthManager> ().enemyHealth = 10;

                //change its scale to half of the scale
                clone2.transform.localScale = new Vector3(transform.localScale.x * 0.5f, transform.localScale.y * 0.5f, transform.localScale.z * 0.5f);
                //give that boss enemy a helath of 10.
                clone2.GetComponent <BossHealthManager> ().enemyHealth = 10;
            }

            //Destroy the enemy game object
            Destroy(gameObject);
        }
    }
 // Update is called once per frame
 void Update()
 {
     if (enemyHealth <= 0)
     {
         Instantiate(deathEffect, transform.position, transform.rotation);
         SocreManager.AddPoints(pointsOnDeath);
         //TO DO: optimise
         Destroy(gameObject);
     }
 }
Exemplo n.º 3
0
    //The object must have a collider and set it's settings to Is trigger in order to run this  has this mettod.This method will get the collider that will clash with it.
    void OnTriggerEnter2D(Collider2D other)
    {
        try {
            var playercontroller = other.GetComponent <PlayerController> ();
        } catch (System.Exception ex) {
            //static list is used to create a high level error log to end user
            StaticData.ErrorLogList.Add("The script playercontroller is not found");
        }



        SocreManager.AddPoints(pointToAdd);

        //Destroy the object this script attached
        Destroy(gameObject);
    }
Exemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        if (enemyHealth <= 0)
        {
            //if enemy health equal or bellow zero points will be added to the player as well as instantiate a death partical on the destroyied object.'
            try {
                Instantiate(deathEffect, transform.position, transform.rotation);
            } catch (System.Exception ex) {
                StaticData.ErrorLogList.Add(ex.ToString());
            }

            SocreManager.AddPoints(pointsOnDeath);
            //TO DO: optimise
            Destroy(gameObject);
        }
    }
Exemplo n.º 5
0
    //respawn player
    public IEnumerator RespawnPlayerCorrutine()
    {
        //disable respawnPartical
        //enable and play death partical
        respawnPartical.SetActive(false);
        deathPartical.SetActive(true);

        //PlayerController script is disabled
        player.enabled = false;
        //player game object disabled
        PlayerGO.enabled = false;
        //Player Health manager disable
        healthManager.isDead = false;
        player.Move(0);
        SocreManager.AddPoints(-deathPanalty);

        player.GetComponent <Renderer> ().enabled = false;
        camera.isFollowing = false;
        Debug.Log("Player respawn !!!! xxxx");
        yield return(new WaitForSeconds(respawnDelay));

        //player.GetComponent<Rigidbody2D> ().gravityScale = gravityStore;
        player.transform.position = currentCheckPoint.transform.position;
        player.enabled            = true;
        PlayerGO.enabled          = true;
        try {
            player.GetComponent <Renderer> ().enabled = true;
        } catch (System.Exception ex) {
            StaticData.ErrorLogList.Add(ex.ToString());
        }
        healthManager.FullHelath();
        healthManager.isDead = false;
        //disable death partical
        //enable and play respawn partical
        respawnPartical.SetActive(true);
        camera.isFollowing = true;
        deathPartical.SetActive(false);
    }