Example #1
0
                } // end SwitchHpBar

                public override void Dispose() {
                    if (null != hpBar) {
                        hpBar.Recycling();
                        hpBar = null;
                    } // end if
                    character.center.RemoveListener(CheckAttributeData);
                } // end Dispose
 // Start is called before the first frame update
 void Start()
 {
     if (!HolyWaterSystem.Get().CostHolyWater(HolyWaterCost))
     {
         Destroy(gameObject); return;
     }
     ResManager.Get().LoadAsync <GameObject>("Prefabs/UI/Unit/HP_Bar", (obj) => {
         obj.name = "HP_Bar";
         HP_Bar   = obj.transform.Find("Bar").gameObject;
         HP_Bar.SetActive(false);
         obj.transform.SetParent(this.transform);
         Vector3 vector3        = this.transform.position;
         vector3.y             += Height;
         obj.transform.position = vector3;
         obj.transform.rotation = Camera.main.transform.rotation;
         obj.GetComponent <HP_Bar>().SetUnit(this);
     });
     //检测初始化是否有错误
     if (CheckInitError())
     {
         Destroy(gameObject);
         return;
     }
     //OnBorn事件
     OnBorn();
     //子类初始化函数
     _Start();
     //AfterBorn事件
     AfterBorn();
 }
Example #3
0
 void Start()
 {
     motor = GetComponent <PlayerMotor>();
     //_PhotonView = GetComponent<PhotonView>();
     cam    = Camera.main;
     camPos = cam.transform;
     HP     = GetComponent <HP_Bar>();
     //Cursor.visible = false;
 }
Example #4
0
                } // end UnderAttack

                public override void SwitchHpBar(bool isShow) {
                    if (isShow) {
                        if (null == hpBar) {
                            hpBar = InstanceMgr.GetObjectManager().GetGameObject<HP_Bar>(HP_Bar.poolName);
                            hpBar.transform.SetParent(character.helpTransform, false);
                            hpBar.gameObject.SetActive(true);
                        } // end if
                    } else {
                        if (null == hpBar) return;
                        // end if
                        hpBar.Recycling();
                        hpBar = null;
                    } // end if
                } // end SwitchHpBar
Example #5
0
    public void tomarDano(int dano)
    {
        dano = dano - status.defesa;
        if (dano <= 0)
        {
            dano = 1;
        }
        HP_Bar hpBar = barraHP.GetComponent("HP_Bar") as HP_Bar;

        if (dano >= status.hpAtual)
        {
            status.hpAtual = 0;
        }
        else
        {
            status.hpAtual = status.hpAtual - dano;
        }
    }
Example #6
0
    public void tomarDano(int dano)
    {
        dano = dano - status.defesa;
        if (dano <= 0)
        {
            dano = 1;//Dano mínimo
        }
        HP_Bar barraHP = objBarraHP.GetComponent("HP_Bar") as HP_Bar;

        if (dano >= status.hpAtual)
        {
            status.hpAtual = 0;
        }
        else
        {
            status.hpAtual = status.hpAtual - dano;
        }
        barraHP.alterarHP();
    }
Example #7
0
 // Use this for initialization
 void Start()
 {
     status = objStatus.GetComponent ("Status") as Status;
     barraHP = objBarraHP.GetComponent ("HP_Bar") as HP_Bar;
     player = FindObjectOfType (typeof(PlayerBehavior)) as PlayerBehavior;
     Arma armaInimigo = objArma.GetComponent ("Arma") as Arma;
     armaInimigo.setPortador (objStatus);
     //teste.text = armaInimigo.getDanoBase () + "";
     distanciaDoPlayer = Vector3.Distance(transform.position,player.transform.position);//pega a distancia do inimigo para o jogador
     setEstado (Estado_Do_Inimigo.idle);
 }