Beispiel #1
0
    /// <summary>
    /// 创建BOSS血条
    /// </summary>
    private static void CreateBossBlood()
    {
        if (null == BossBlood)
        {
            Value BossIns = new Value();
            if (!GfxDynamicMovie.Instance.AttachMovie(ref BossIns, BossBloodAS3RefrenceName, BossBloodAS3RefrenceName + "asd", -1))
            {
                Trace.LogError("Flash -- BossBlood创建失败!");
                BossIns = null;
            }

            BossBlood = new GfxBlood(BossIns);
            BossBlood.Init(-1, null, -1, ENTITY_TYPE.TYPE_MONSTER);
            BossBlood.SetMaxValue(100);
            BossBlood.SetCurValue(100);
            BossBlood.SetVisible(false);
            BossBlood.SetPositionDirectly_StagePoint(OrginalBossBloodPos);
        }
    }
Beispiel #2
0
    /// <summary>
    /// 创建一个Blood,返回一个GfxBlood实例,失败返回null
    /// </summary>
    /// <param name="entityID">实体ID</param>
    /// <param name="Host">实体</param>
    /// <param name="campType">阵营类型</param>
    /// <param name="CurValue">当前值</param>
    /// <param name="MaxValue">最大值</param>
    public static GfxBlood CreateBlood(U3D_Render.EntityView objev, int entityID, GameObject Host, int campType, int CurValue = 100, int MaxValue = 100)
    {
        if (SFGFxMovieManager.Instance == null)
        {
            Trace.LogError("SFGFxMovieManager没有初始化,请不要在Awake中创建!");
            return(null);
        }
        if (!bInit)
        {
            Trace.LogError("GfxBloodManager必须初始化!");
            return(null);
        }
        //有可能GfxBloodMovie还没有创建完成.
        if (GfxBloodMovie.Instance == null)
        {
            //Trace.LogError("GfxBloodMovie尚未创建完成,请等待创建完成后再调用。");
            return(null);
        }

        CreateBossBlood();

        if (!objev.IsValid)
        {
            Trace.LogWarning("实体视图无效!id=" + entityID);
            return(null);
        }

        if (m_BloodMap.ContainsKey(entityID))
        {
            Trace.LogWarning(entityID + "已经有血条,返回已有的实例");
            GfxBlood gba = m_BloodMap[entityID];
            return(gba);
        }

        CurValue = Mathf.Clamp(CurValue, 0, MaxValue);


        ENTITY_TYPE entityType = objev.Type;

        if (!m_entiyTypeMap.ContainsKey(entityType))
        {
            Trace.LogWarning(entityID + "找不到实体类型:" + entityType + "使用怪物类型代替,请在GfxBloodManager::Init()中添加");
            entityType = ENTITY_TYPE.TYPE_MONSTER;
        }

        //按照策划要求,目前不创建己方小兵血条,其他己方物体不变
        if (objev.Flag == (int)EWarMonsterExec.EWME_Soldier && campType == (int)GFxCampManager.GFxCampTpye.CT_Friend)
        {
            return(null);
        }

        MovieNode trs = new MovieNode();
        GfxBlood  gb  = GetBlood(entityType, entityID == EntityFactory.MainHeroID, ref trs);

        if (null == gb)
        {
            return(null);
        }
        gb.Init(entityID, Host, campType, entityType);
        gb.CreateBillBorad();
        //获取最大值和当前值
        MaxValue = objev.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_MAX_HP);
        CurValue = objev.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_HP);

        gb.SetMaxValue(MaxValue);
        gb.SetCurValue(CurValue);

        //设置一下血量数字信息
        string bloodInfo = CurValue + "/" + MaxValue;

        gb.SetBloodInfo(bloodInfo);

        //设置血量数字信息是否显示,通过读取本地配置文件
        gb.SetBloodInfoVisible(bBloodInfoVisible);

        //判断一下如果是主角,则通过读取本地配置文件,设置主角血量是否显示
        if (entityID == EntityFactory.MainHeroID)
        {
            //读取本地配置文件,获取玩家血条是否需要显示
            bPlayerBloodVisible = ASpeedGame.Data.GameSettingsXml.GameSettingsXmlManager.Instance.GameSettingsModel.showPlayerBlood.AValue;
            gb.SetPlayerVisible(bPlayerBloodVisible);
        }

        gb.ChangeMovieNode(trs);
        m_BloodMap.Add(entityID, gb);
        ChangeMask(objev, true);
        //if (!go)
        //{
        //    go = GameObject.CreatePrimitive(PrimitiveType.Plane);

        //    go.GetComponent<Renderer>().sharedMaterial.SetTexture("_MainTex", GfxBloodMovie.BloodRenderTexture);
        //}
        if (entityType == ENTITY_TYPE.TYPE_PLAYER_ROLE && entityID != EntityFactory.MainHeroID)
        {
            setHeroProperty(objev);
        }
        return(gb);
    }
    public static void PreWarmBlood()
    {
        if (bPreWarmBlood)
        {
            return;
        }
        bPreWarmBlood = true;
        Queue <GfxBlood> MonsterList = m_CacheBlood[ENTITY_TYPE.TYPE_MONSTER];

        for (int i = 0; i < MonsterCacheCout; i++)
        {
            MovieNode moveNode = new MovieNode();
            if (!AllocBloodPos(ENTITY_TYPE.TYPE_MONSTER, ref moveNode))
            {
                //Debug.LogWarning("Movie空间不足,最多只能容纳:" + MaxColCount * MaxRowCount + "个血条!!");
                continue;
            }
            GfxBlood gb = CreateBloodInstance(MonsterBloodAS3RefrenceName);
            gb.Init(-1, CacheBloodRoot, -1, ENTITY_TYPE.TYPE_MONSTER);
            gb.CreateBillBorad();
            gb.ChangeParent(CacheBloodRoot.transform);
            gb.SetEnable(false);
            gb.ChangeMovieNode(moveNode);

            MonsterList.Enqueue(gb);
        }

        Queue <GfxBlood> PlayerList = m_CacheBlood[ENTITY_TYPE.TYPE_PLAYER_ROLE];

        for (int i = 0; i < PlayerCacheCout; i++)
        {
            MovieNode moveNode = new MovieNode();
            if (!AllocBloodPos(ENTITY_TYPE.TYPE_PLAYER_ROLE, ref moveNode))
            {
                //Debug.LogWarning("Movie空间不足,最多只能容纳:" + MaxColCount * MaxRowCount + "个血条!!");
                continue;
            }

            GfxBlood gb = CreateBloodInstance(PlayerBloodAS3RefrenceName);
            gb.Init(-1, CacheBloodRoot, -1, ENTITY_TYPE.TYPE_PLAYER_ROLE);

            gb.SetMaxValue(100);
            gb.SetCurValue(100);
            gb.CreateBillBorad();
            gb.ChangeParent(CacheBloodRoot.transform);
            gb.SetEnable(false);
            gb.ChangeMovieNode(moveNode);
            PlayerList.Enqueue(gb);
        }

        Queue <GfxBlood> TankList = m_CacheBlood[ENTITY_TYPE.TYPE_TANK];

        for (int i = 0; i < TankCacheCout; i++)
        {
            MovieNode moveNode = new MovieNode();
            if (!AllocBloodPos(ENTITY_TYPE.TYPE_TANK, ref moveNode))
            {
                //Debug.LogWarning("Movie空间不足,最多只能容纳:" + MaxColCount * MaxRowCount + "个血条!!");
                continue;
            }
            GfxBlood gb = CreateBloodInstance(BuildingsBloodAS3RefrenceName);
            gb.Init(-1, CacheBloodRoot, -1, ENTITY_TYPE.TYPE_TANK);
            gb.SetMaxValue(100);
            gb.SetCurValue(100);
            gb.CreateBillBorad();
            gb.ChangeParent(CacheBloodRoot.transform);
            gb.SetEnable(false);
            gb.ChangeMovieNode(moveNode);
            TankList.Enqueue(gb);
        }
    }