Exemplo n.º 1
0
    private void CreateHpBar(GameObject mtarget, Vector3 toppos)
    {
        string poolname = "HPBar";
        var    pool     = App.Inst.getObjectPoolManage().getPool(poolname);

        if (pool == null)
        {
            new ObjectPoolFactory().createHPBarPools(poolname, 20);
            pool = App.Inst.getObjectPoolManage().getPool(poolname);
        }
        GameObject returnObject = null;

        returnObject = pool.getObject();
        if (returnObject == null)
        {
            returnObject = new model.Animation("HPBar", "ui", "").create();
        }

        GameObject canvas = GameObject.Find("Canvas");

        returnObject.transform.SetParent(canvas.transform);
        returnObject.transform.localScale = Vector3.one;
        Vector3  offset = new Vector3(toppos.x, toppos.y + 18, 0);
        HubBarUI hpbar  = returnObject.GetComponent <HubBarUI>();

        hpbar.mtarget = mtarget.transform;
        hpbar.offset  = offset;
        hpbar.SetDefaultValue(this.character.hp, this.character.maxHp);

        this.bloodbarNode = hpbar;
    }
Exemplo n.º 2
0
 public SpriteUI(Entity entity)
 {
     this.entity       = entity;
     this.mapNode      = entity.map.node;
     this.curNode      = null;
     this.bloodbarNode = null;
     this.animator     = null;
     this._init();
 }
Exemplo n.º 3
0
 public void destroy()
 {
     returnObjectToPool();
     returnHPBarToPool();
     if (this.curPath != null)
     {
         this.curPath.Clear();
     }
     this.curPath      = null;
     this.entity       = null;
     this.character    = null;
     this.mapNode      = null;
     this.animator     = null;
     this.curNode      = null;
     this.bloodbarNode = null;
 }