示例#1
0
    // Use this for initialization
    void Start()
    {
        GameObject thePlayer = GameObject.FindGameObjectWithTag("Player");

        thePlayerController = thePlayer.GetComponent <PlayerController>();
        theAbilities        = thePlayer.GetComponentInChildren <PlayerAbilities>();

        healthBar   = GameObject.FindGameObjectWithTag("healthBar").GetComponent <Slider>();
        healthValue = healthBar.GetComponentInChildren <Text>();

        theKing = GameObject.FindGameObjectWithTag("theKing").GetComponent <KingControl>();

        bossHealthBar   = GameObject.FindGameObjectWithTag("bossHealthBar").GetComponent <Slider>();
        bossHealthValue = bossHealthBar.GetComponentInChildren <Text>();

        ability1  = GameObject.FindGameObjectWithTag("ability1").GetComponent <Image>();
        cdSlider1 = ability1.GetComponentInChildren <Slider>();
        cdText1   = cdSlider1.GetComponentInChildren <Text>();

        ability2  = GameObject.FindGameObjectWithTag("ability2").GetComponent <Image>();
        cdSlider2 = ability2.GetComponentInChildren <Slider>();
        cdText2   = cdSlider2.GetComponentInChildren <Text>();

        ability3  = GameObject.FindGameObjectWithTag("ability3").GetComponent <Image>();
        cdSlider3 = ability3.GetComponentInChildren <Slider>();
        cdText3   = cdSlider3.GetComponentInChildren <Text>();

        powerUpPanel = GameObject.FindGameObjectWithTag("powerUpPanel").GetComponent <RectTransform>();
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        GameObject thePlayer = GameObject.FindGameObjectWithTag("Player");
        thePlayerController = thePlayer.GetComponent<PlayerController>();
        theAbilities = thePlayer.GetComponentInChildren<PlayerAbilities>();

        healthBar = GameObject.FindGameObjectWithTag("healthBar").GetComponent<Slider>();
        healthValue = healthBar.GetComponentInChildren<Text>();

        theKing = GameObject.FindGameObjectWithTag("theKing").GetComponent<KingControl>();

        bossHealthBar = GameObject.FindGameObjectWithTag("bossHealthBar").GetComponent<Slider>();
        bossHealthValue = bossHealthBar.GetComponentInChildren<Text>();

        ability1 = GameObject.FindGameObjectWithTag("ability1").GetComponent<Image>();
        cdSlider1 = ability1.GetComponentInChildren<Slider>();
        cdText1 = cdSlider1.GetComponentInChildren<Text>();

        ability2 = GameObject.FindGameObjectWithTag("ability2").GetComponent<Image>();
        cdSlider2 = ability2.GetComponentInChildren<Slider>();
        cdText2 = cdSlider2.GetComponentInChildren<Text>();

        ability3 = GameObject.FindGameObjectWithTag("ability3").GetComponent<Image>();
        cdSlider3 = ability3.GetComponentInChildren<Slider>();
        cdText3 = cdSlider3.GetComponentInChildren<Text>();

        powerUpPanel = GameObject.FindGameObjectWithTag("powerUpPanel").GetComponent<RectTransform>();
    }
示例#3
0
 void OnTriggerEnter2D(Collider2D collis)
 {
     if (collis.gameObject.tag == "wall")
     {
     }
     if (collis.gameObject.tag == "enemy")
     {
         EnemyController enemyHealth = collis.GetComponent <EnemyController>();
         enemyHealth.wasHit = true;
         Vector3 targetPosition = collis.transform.position - this.transform.position;
         targetPosition.z = 0;
         if (enemyHealth.currentHealth > 0)
         {
             collis.transform.GetChild(0).gameObject.SetActive(true);
             collis.transform.Translate(targetPosition.normalized * 2);
             enemyHealth.TakeDamage(10);
         }
     }
     if (collis.gameObject.tag == "theKing")
     {
         KingControl enemyHealth    = collis.GetComponent <KingControl>();
         Vector3     targetPosition = collis.transform.position - this.transform.position;
         targetPosition.z = 0;
         if (enemyHealth.currentHealth > 0)
         {
             enemyHealth.TakeDamage(10);
         }
     }
 }
示例#4
0
    void OnTriggerStay2D(Collider2D collis)
    {
        if (collis.gameObject.tag == "wall")
        {
        }
        else if (collis.gameObject.tag == "theKing")
        {
            KingControl enemyHealth = collis.GetComponent <KingControl>();

            if (enemyHealth.currentHealth > 0 && hitTime <= 0)
            {
                enemyHealth.TakeDamage(10);
                hitTime = 0.5f;
            }
        }
    }
 void OnCollisionEnter2D(Collision2D collis)
 {
     if (collis.gameObject.tag == "wall")
     {
         this.GetComponent <CircleCollider2D>().isTrigger = true;
         anim.SetTrigger("Hit");
         this.GetComponent <Rigidbody2D>().velocity = thePlayer.transform.up * 0;
         Destroy(this.gameObject, destroyTimeHit);
     }
     else if (collis.gameObject.tag == "enemy")
     {
         EnemyController enemyHealth = collis.gameObject.GetComponent <EnemyController>();
         if (enemyHealth.currentHealth > 0)
         {
             this.GetComponent <CircleCollider2D>().isTrigger = true;
             collis.transform.GetChild(0).gameObject.SetActive(true);
             anim.SetTrigger("Hit");
             this.GetComponent <Rigidbody2D>().velocity = thePlayer.transform.up * 0;
             Destroy(this.gameObject, destroyTimeHit);
             enemyHealth.TakeDamage(10);                  //Changed to 100 for testing purposes.
         }
     }
     else if (collis.gameObject.tag == "theKing")
     {
         KingControl enemyHealth = collis.gameObject.GetComponent <KingControl>();
         print("kings health" + enemyHealth.currentHealth);
         if (enemyHealth.currentHealth > 0)
         {
             this.GetComponent <CircleCollider2D>().isTrigger = true;
             //collis.transform.GetChild(0).gameObject.SetActive (true);
             anim.SetTrigger("Hit");
             this.GetComponent <Rigidbody2D>().velocity = thePlayer.transform.up * 0;
             Destroy(this.gameObject, destroyTimeHit);
             enemyHealth.TakeDamage(10);                  //Changed to 100 for testing purposes.
         }
     }
 }