/// <summary>
    /// 缓存血条
    /// </summary>
    /// <param name="b"></param>
    static void CacheBlood(GfxBlood b)
    {
        if (!OptimitzedControlPlane.Instance.EnityCreateOptimize || null == b)
        {
            return;
        }


        ENTITY_TYPE entity_Type = b.bloodType;

        if (!m_CacheBlood.ContainsKey(entity_Type))
        {
            Debug.LogError("缓存" + entity_Type + "类型血条失败,请在InitCache中添加!");
            return;
        }
        int id = b.ID;

        //不存主角
        if (id == EntityFactory.MainHeroID)
        {
            return;
        }
        if (m_BloodMap.ContainsKey(id))
        {
            b.SetEnable(false);
            b.SetBloodColor(false);
            b.ChangeParent(CacheBloodRoot.transform);
            Queue <GfxBlood> m_list = m_CacheBlood[entity_Type];
            m_list.Enqueue(b);
            m_BloodMap.Remove(id);
        }
    }
Beispiel #2
0
    /// <summary>
    /// 摧毁指定的组件
    /// </summary>
    /// <param name="instance">需要清除的Blood</param>
    public static void Destroy(GfxBlood instance)
    {
        if (Movie.GetSingleton <GfxBloodMovie>() == null)
        {
            return;
        }
        if (null == instance)
        {
            return;
        }
        int id = instance.ID;

        if (instance.movieNode.isValid)
        {
            UnUsedMovieNodeList.Enqueue(instance.movieNode);
        }

        if (GfxBloodMovie.Instance != null)
        {
            GfxBloodMovie.Instance.RemoveMovieAS3(instance.Instance);
        }
        instance.Clear();

        if (m_BloodMap.ContainsKey(id))
        {
            m_BloodMap[id] = null;
            m_BloodMap.Remove(id);
        }
        instance = null;
    }
Beispiel #3
0
 /// <summary>
 /// 设置临时血量
 /// </summary>
 /// <param name="entityID"></param>
 /// <param name="cam"></param>
 public static void SetTempValue(int entityID, int val)
 {
     if (m_BloodMap.ContainsKey(entityID))
     {
         GfxBlood gba = m_BloodMap[entityID];
         gba.SetTemp(val);
     }
 }
Beispiel #4
0
 /// <summary>
 /// 设置血条的可见性
 /// </summary>
 /// <param name="entityID">ID</param>
 /// <param name="v">值</param>
 public static void SetVisible(int entityID, bool v)
 {
     if (m_BloodMap.ContainsKey(entityID))
     {
         GfxBlood gba = m_BloodMap[entityID];
         gba.SetVisible(v);
     }
 }
Beispiel #5
0
 /// <summary>
 /// 设置血条上的等级
 /// </summary>
 /// <param name="entityID">ID</param>
 /// <param name="v">值</param>
 public static void SetLevel(int entityID, int v)
 {
     if (m_BloodMap.ContainsKey(entityID))
     {
         GfxBlood gba = m_BloodMap[entityID];
         gba.SetLevel(v);
     }
 }
Beispiel #6
0
 /// <summary>
 /// 设置血条上的数字信息
 /// </summary>
 /// <param name="entityID">ID</param>
 /// <param name="bloodInfo">值</param>
 public static void SetBloodInfo(int entityID, string bloodInfo)
 {
     if (m_BloodMap.ContainsKey(entityID))
     {
         GfxBlood gba = m_BloodMap[entityID];
         gba.SetBloodInfo(bloodInfo);
     }
 }
Beispiel #7
0
 public static void SetCamType(int entityID, int cam)
 {
     if (m_BloodMap.ContainsKey(entityID))
     {
         GfxBlood gba = m_BloodMap[entityID];
         gba.SetCamType(cam);
     }
 }
Beispiel #8
0
    //static GameObject go;

    public static void UpdateBlood(int entityID, GameObject Host, int campType)
    {
        if (m_BloodMap.ContainsKey(entityID))
        {
            GfxBlood gb = m_BloodMap[entityID];
            gb.Entry = Host;
            gb.SetCamType(campType);
        }
    }
Beispiel #9
0
 public static GfxBlood FindBlood(int entityID)
 {
     if (m_BloodMap.ContainsKey(entityID))
     {
         GfxBlood gba = m_BloodMap[entityID];
         return(gba);
     }
     return(null);
 }
    /// <summary>
    /// 获取血条
    /// </summary>
    /// <param name="entity_Type"></param>
    /// <param name="isHero"></param>
    /// <param name="moveNode"></param>
    /// <returns></returns>
    static GfxBlood GetBlood(ENTITY_TYPE entity_Type, bool isHero, ref MovieNode moveNode)
    {
        GfxBlood gb   = null;
        string   name = m_entiyTypeMap[entity_Type];

        if (isHero) //主角直接创建
        {
            if (!AllocBloodPos(entity_Type, ref moveNode))
            {
                //Debug.LogWarning("Movie空间不足,最多只能容纳:" + MaxColCount * MaxRowCount + "个血条!!");
                return(null);
            }

            name = PlayerSelfBloodAS3RefrenceName;
            gb   = CreateBloodInstance(name);

            return(gb);
        }

        if (!OptimitzedControlPlane.Instance.EnityCreateOptimize)
        {
            if (!AllocBloodPos(entity_Type, ref moveNode))
            {
                //Debug.LogWarning("Movie空间不足,最多只能容纳:" + MaxColCount * MaxRowCount + "个血条!!");
                return(null);
            }
            gb = CreateBloodInstance(name);
            return(gb);
        }

        if (!m_CacheBlood.ContainsKey(entity_Type))
        {
            moveNode = new MovieNode();
            return(gb);
        }
        else
        {
            Queue <GfxBlood> m_CacheList = m_CacheBlood[entity_Type];
            if (m_CacheList.Count > 0)
            {
                gb = m_CacheList.Dequeue();
                gb.SetEnable(true);
                moveNode = gb.movieNode;
            }
            else
            {
                if (!AllocBloodPos(entity_Type, ref moveNode))
                {
                    //Debug.LogWarning("Movie空间不足,最多只能容纳:" + MaxColCount * MaxRowCount + "个血条!!");
                    return(null);
                }
                gb = CreateBloodInstance(name);
            }
        }
        return(gb);
    }
Beispiel #11
0
    /// <summary>
    /// 一般更新
    /// </summary>
    private static void NormalUpdate()
    {
        InvalidList.Clear();
        if (null != m_BloodMap)
        {
            foreach (GfxBlood var in m_BloodMap.Values)
            {
                GfxBlood gba = var;
                U3D_Render.EntityView view = EntityFactory.getEntityViewByID(gba.ID);
                if (view == null)
                {
                    InvalidList.Enqueue(gba);
                    continue;
                }
                if (!gba.Entry)
                {
                    InvalidList.Enqueue(gba);
                    continue;
                }

                if (!gba.Entry.activeSelf || !view.StateMachine.GetVisible())//实体没有被激活或者不可见
                {
                    if (gba.GetEnable())
                    {
                        gba.SetEnable(false);
                    }
                }
                else//正常的实体
                {
                    if (!gba.GetEnable())
                    {
                        gba.SetEnable(true);
                    }
                    gba.OnUpdate();
                }
            }
        }


        while (InvalidList.Count > 0)
        {
            //移除无效的Blood节点
            GfxBlood b = InvalidList.Dequeue();
            if (OptimitzedControlPlane.Instance.EnityCreateOptimize)
            {
                CacheBlood(b);
            }
            else
            {
                GfxBloodManager.Destroy(b);
            }
        }
        InvalidList.Clear();
    }
Beispiel #12
0
 /// <summary>
 /// 设置血条的当前值
 /// </summary>
 /// <param name="entityID">ID</param>
 /// <param name="v">值</param>
 public static void SetCurValue(int entityID, int v)
 {
     if (v < 0)
     {
         Trace.LogWarning("ID:" + entityID + ",的当前血量小于0!请注意!!,值为:" + v);
         return;
     }
     if (m_BloodMap.ContainsKey(entityID))
     {
         GfxBlood gba = m_BloodMap[entityID];
         gba.SetCurValue(v);
     }
 }
    /// <summary>
    /// 创建血条实例
    /// </summary>
    /// <param name="AS3ReferenceName"></param>
    /// <returns></returns>
    static GfxBlood CreateBloodInstance(string AS3ReferenceName)
    {
        Value ins = new Value();

        if (!GfxBloodMovie.Instance.AttachMovie(ref ins, AS3ReferenceName, "Blood-" + System.DateTime.Today.Millisecond, -1))
        {
            Trace.LogError("Flash -- Blood创建失败!");
            ins = null;
            return(null);
        }
        GfxBlood gb = new GfxBlood(ins);

        return(gb);
    }
Beispiel #14
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 #15
0
 /// <summary>
 /// 清除所有的组件
 /// </summary>
 public static void DestroyALL()
 {
     if (Movie.GetSingleton <GfxBloodMovie>() == null)
     {
         return;
     }
     ClearCache();
     if (null != m_BloodMap)
     {
         foreach (KeyValuePair <int, GfxBlood> var in m_BloodMap)
         {
             GfxBlood gba = var.Value;
             if (GfxBloodMovie.Instance != null)
             {
                 GfxBloodMovie.Instance.RemoveMovieAS3(gba.Instance);
             }
             gba.Clear();
         }
         CurrentColIndex = 0;
         CurrentRowIndex = 0;
         UnUsedMovieNodeList.Clear();
         m_BloodMap.Clear();
     }
     if (null != BossBlood)
     {
         if (GfxDynamicMovie.Instance != null)
         {
             GfxDynamicMovie.Instance.RemoveMovieAS3(BossBlood.Instance);
         }
         BossBlood.Clear();
         BossBlood             = null;
         CurrentBossBlodHostID = -1;
     }
     BossBloodEntityTable.Clear();
     BossBloodProityList.Clear();
     //GFxWarPauseMenu.BoolEvent -= ChangeBloodSetting;
 }
    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);
        }
    }
Beispiel #17
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);
    }