Пример #1
0
 // Use this for initialization
 void Start()
 {
     if (identity == null)
     {
         identity = GetComponent <UnitIdentity>();
     }
     if (engine == null)
     {
         engine = GetComponent <ShipEngine>();
     }
     if (weaponHolder == null)
     {
         weaponHolder = GetComponent <ShipboardWeaponHolder>();
     }
     if (health == null)
     {
         health = GetComponent <Health>();
     }
     if (sheild == null)
     {
         sheild = GetComponent <Sheild>();
     }
     if (master != null)
     {
         master.Register(this);
     }
 }
Пример #2
0
    // Update is called once per frame
    protected override void Update()
    {
        base.Update();
        if (target == null)
        {
            hidden = true;
        }
        if (!hidden)
        {
            //Refresh health bar and sheild bar
            Health health = targetUnit.health;
            Sheild sheild = targetUnit.sheild;

            float health01 = health.healthRate;
            float sheild01 = sheild.sheildRate;
            healthBar.value = health01;
            sheildBar.value = sheild01;
            float healthMax   = health.maxHealth;
            float healthValue = health.health;
            float sheildMax   = sheild.maxSheild;
            float sheildValue = sheild.sheild;

            healthBarText.text = "" + (int)healthValue + "/" + (int)healthMax;
            sheildBarText.text = "" + (int)sheildValue + "/" + (int)sheildMax;
        }
    }
Пример #3
0
    void Start()
    {
        this.rb    = this.GetComponent <Rigidbody2D>();
        this.anim  = this.GetComponent <Animator>();
        this.a1    = this.GetComponentInChildren <Attack1>();
        this.block = this.GetComponentInChildren <Sheild>();

        SetHealth(4);
    }