コード例 #1
0
    /// <summary>
    /// 返回某类Entity的HeroType类型的List heroType为KHeroType.htInvalid是全部类型
    /// </summary>
    /// <typeparam name="EntityType">Entity类型</typeparam>
    /// <param name="heroType"></param>
    /// <returns></returns>
    public List <EntityType> GetEntities <EntityType>(KHeroType heroType = KHeroType.htInvalid) where EntityType : BaseEntity
    {
        List <EntityType> list = new List <EntityType>();

        if (m_EntityManager != null)
        {
            Dictionary <ulong, BaseEntity> entitys = m_EntityManager.GetEntities <EntityType>();
            if (entitys != null)
            {
                var values = entitys.Values;
                if (heroType == KHeroType.htInvalid)
                {
                    foreach (var entity in values)
                    {
                        list.Add(entity as EntityType);
                    }
                }
                else
                {
                    foreach (var entity in values)
                    {
                        if (entity.GetHeroType() == heroType)
                        {
                            list.Add(entity as EntityType);
                        }
                    }
                }
            }
        }
        return(list);
    }
コード例 #2
0
    /// <summary>
    /// 获取态皮肤节点通过模板ID
    /// </summary>
    /// <param name="templateID">模板ID</param>
    /// <param name="heroType">类型</param>
    /// <returns></returns>
    public Transform GetSkinTransformByTemplateID(int templateID, KHeroType heroType)
    {
        CfgEternityProxy cfgEternityProxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;

        if (cfgEternityProxy.IsSpace())
        {
            Dictionary <ulong, BaseEntity> entitys = m_EntityManager.GetEntities <SpacecraftEntity>();
            if (entitys != null)
            {
                foreach (SpacecraftEntity spacecraftEntity in entitys.Values)
                {
                    if (spacecraftEntity.GetTemplateID() == templateID && spacecraftEntity.GetHeroType() == heroType)
                    {
                        return(spacecraftEntity.GetSkinTransform());
                    }
                }
            }
        }
        else
        {
            Dictionary <ulong, BaseEntity> entitys = m_EntityManager.GetEntities <HumanEntity>();
            if (entitys != null)
            {
                foreach (HumanEntity humanEntity in entitys.Values)
                {
                    if (humanEntity.GetTemplateID() == templateID && humanEntity.GetHeroType() == heroType)
                    {
                        return(humanEntity.GetSkinTransform());
                    }
                }
            }
        }

        return(null);
    }
コード例 #3
0
 /// <summary>
 /// 根据Entity的 HeroType 和 是否是主角, 决定他的Layer
 /// </summary>
 /// <param name="heroType">Entity.GetHeroType()</param>
 /// <param name="isMain">是不是主角</param>
 /// <returns></returns>
 public static int GetLayerByHeroType(KHeroType heroType, bool isMain)
 {
     return(heroType == KHeroType.htPlayer
                             ? isMain
                                     ? GameConstant.LayerTypeID.MainPlayer
                                     : GameConstant.LayerTypeID.SpacecraftOtherPlayer
                             : heroType == KHeroType.htReliveNpc
                                     ? GameConstant.LayerTypeID.InvisibleFunctionalNPC
                                     : GameConstant.LayerTypeID.SpacecraftNPC);
 }
コード例 #4
0
    public override void OnInitialize(ISpacecraftPlayerAnimatorProperty property)
    {
        m_SpacecraftPlayerAnimatorProperty = property;

        m_IsMain    = property.IsMain();
        m_KHeroType = property.GetHeroType();
        if (m_KHeroType == KHeroType.htPlayer)
        {
            CfgEternityProxy cfgeternityproxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;
            m_musicComboID = cfgeternityproxy.GetItemByKey(property.GetItemID()).ItemUnion <Warship>().Value.MusicComboID;
        }
    }
コード例 #5
0
    /// <summary>
    /// 创建时
    /// </summary>
    private void OnTargetCreate(SpacecraftEntity target, RectTransform view)
    {
        KHeroType entityType = target.GetHeroType();

        if (entityType == KHeroType.htMine)
        {
            TMP_Text nameField = view.Find("Name/Name/Label_Name").GetComponent <TMP_Text>();
            nameField.text = entityType == KHeroType.htPlayer ? target.GetName() : TableUtil.GetNpcName(target.GetTemplateID());

            //血段
            m_LineGrid = FindComponent <Transform>(view, "Slider/Image_Bar/LineGrid");

            int bloodVolumeLength = m_CfgEternityProxy.GetDoppingBloodVolumeLengthByKey((uint)target.GetTemplateID()) - 1;
            if (m_OldPrivew != bloodVolumeLength)
            {
                m_OldPrivew = bloodVolumeLength;
                while (m_LineGrid.childCount - 2 < bloodVolumeLength)
                {
                    Transform lineItem = Object.Instantiate(m_LineGrid.GetChild(1), m_LineGrid);
                    lineItem.gameObject.SetActive(true);
                }
                for (int i = bloodVolumeLength + 2; i < m_LineGrid.childCount; i++)
                {
                    m_LineGrid.GetChild(i).gameObject.SetActive(false);
                }
            }
        }
        else
        {
            //目标名称
            TMP_Text nameField = view.Find("Name/Name").GetComponent <TMP_Text>();
            nameField.text = entityType == KHeroType.htPlayer ? target.GetName() : TableUtil.GetNpcName(target.GetTemplateID());

            //目标图标
            Image image = view.Find("Name/Icon/ImageIcon").GetComponent <Image>();
            image.gameObject.SetActive(entityType != KHeroType.htPlayer);
            if (image.gameObject.activeSelf)
            {
                Npc entityVO = m_CfgEternityProxy.GetNpcByKey(target.GetTemplateID());
                if (entityVO.NameBoardIcon == 0)
                {
                    image.color = Color.clear;
                }
                else
                {
                    image.color = Color.white;
                    UIUtil.SetIconImage(image, entityVO.NameBoardIcon);
                }
            }
        }
    }
コード例 #6
0
    public override void OnInitialize(IHumanAnimatorProperty property)
    {
        m_IsMain    = property.IsMain();
        m_KHeroType = property.GetHeroType();
        CfgEternityProxy cfgEternityProxy = (CfgEternityProxy)GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy);

        if (m_KHeroType == KHeroType.htPlayer)
        {
            Player?player = cfgEternityProxy.GetPlayerByItemTId((int)property.GetItemID());
            if (player.HasValue)
            {
                m_musicComboID = player.Value.MusicComboID;
            }
        }
    }
コード例 #7
0
    /// <summary>
    /// 更新目标点
    /// </summary>
    /// <param name="view">敌方点</param>
    /// <param name="distance">距离</param>
    /// <param name="main">主角</param>
    /// <param name="target">目标</param>
    private void UpdateTarget(RectTransform view, float distance, SpacecraftEntity main, SpacecraftEntity target)
    {
        if (!view.gameObject.activeSelf)
        {
            view.gameObject.SetActive(true);
            view.Find("Image_Enemy").gameObject.SetActive(true);
        }

        Vector3 position  = target.transform.position - main.transform.position;
        Vector3 direction = new Vector3(position.x, 0, position.z).normalized *distance;

        view.anchoredPosition = new Vector2(direction.x, direction.z);

        Image     img      = view.Find("Image_Enemy").GetComponent <Image>();
        KHeroType heroType = target.GetHeroType();

        /// 玩家不再npc表
        /// 先用指定ID
        if (heroType == KHeroType.htPlayer)
        {
            UIUtil.SetIconImage(img, TableUtil.GetIconBundle(PLAYER_MAP_ICON), TableUtil.GetIconAsset(PLAYER_MAP_ICON));
        }
        else
        {
            Npc  npc     = target.GetNPCTemplateVO();
            uint mapIcon = npc.MapIcon;
            if (mapIcon != 0)
            {
                /// TODO.
                /// 暂无考虑:同一NPC不同时刻改变阵营时,是否需要显示不同图标
                UIUtil.SetIconImage(img, TableUtil.GetIconBundle(mapIcon), TableUtil.GetIconAsset(mapIcon));
            }
            else
            {
                view.gameObject.SetActive(false);
                view.Find("Image_Enemy").gameObject.SetActive(false);
            }
        }
    }
コード例 #8
0
    public override void OnInitialize(ISpacecraftSoundProperty property)
    {
        m_SpacecraftSoundProperty = property;

        m_Cgeternityproxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;

        if (m_SpacecraftSoundProperty.GetHeroType() == KHeroType.htMonster)
        {
            /// TODO 怪物后续走表
            m_MusicComboID = 1001;
        }
        else if (m_SpacecraftSoundProperty.GetHeroType() == KHeroType.htPlayer)
        {
            m_MusicComboID = m_Cgeternityproxy.GetItemByKey(property.GetItemID()).ItemUnion <Warship>().Value.MusicComboID;
        }

        if (!m_SpacecraftSoundProperty.IsMain())
        {
            m_WwiseMusicPalce = WwiseMusicPalce.Palce_3st;
        }

        /// TODO.
        /// 处理探查掉落音效,先在newhero中处理跑通流程,后续根据状态协议处理
        KHeroType heroType = m_SpacecraftSoundProperty.GetHeroType();

        if (heroType == KHeroType.htNormalChest)
        {
            PlayVideoSound((int)m_Cgeternityproxy.GetGamingConfig(1).Value.Treasure.Value.Sound.Value.OrdinaryChestRefresh);
        }
        else if ((heroType == KHeroType.htRareChestGuard || heroType == KHeroType.htNormalChestGuard) && m_SpacecraftSoundProperty.IsSeal())
        {
            PlaySystemSound(WwiseMusicSpecialType.SpecialType_Voice_treasure_event2, (object obj) =>
            {
                PlayVideoSound((int)m_Cgeternityproxy.GetGamingConfig(1).Value.Treasure.Value.Sound.Value.JammerRefresh);
            });
        }
    }
コード例 #9
0
    /// <summary>
    /// 更新视图
    /// </summary>
    protected override void Update()
    {
        if (!IsDead() && !IsWatchOrUIInputMode() && !IsLeaping())
        {
            //GameplayProxy sceneProxy = Facade.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;
            //SpacecraftEntity main = sceneProxy.GetEntityById<SpacecraftEntity>(sceneProxy.GetMainPlayerUID());
            if (m_MainEntity == null)
            {
                m_MainEntity = m_GameplayProxy.GetEntityById <SpacecraftEntity>(m_GameplayProxy.GetMainPlayerUID());
            }
            if (!m_MainEntity)
            {
                return;
            }
            List <SpacecraftEntity> entitys = m_GameplayProxy.GetEntities <SpacecraftEntity>();

            //按距离排序
            entitys.Sort((a, b) =>
            {
                Vector3 distanceA = a.transform.position - m_MainEntity.transform.position;
                Vector3 distanceB = b.transform.position - m_MainEntity.transform.position;
                return((int)(distanceB.sqrMagnitude - distanceA.sqrMagnitude));
            });

            bool isInSpace = IsInSpace();
            for (int i = 0; i < entitys.Count; i++)
            {
                SpacecraftEntity entity             = entitys[i];
                KHeroType        heroType           = entity.GetHeroType();
                Vector3          titleOffset        = Vector3.zero;
                float            visibilityDistance = GameConstant.DEFAULT_VISIBILITY_METRE_FOR_SHIP;

                //忽略自已
                // if (entity == main)
                //    continue;

                //忽略不需要显示的NPC
                if (heroType != KHeroType.htPlayer)
                {
                    Npc entityVO = m_CfgEternityProxy.GetNpcByKey(entity.GetTemplateID());
                    if (entityVO.Display == 0)
                    {
                        continue;
                    }

                    if (entityVO.HeroHeaderLength >= 3)
                    {
                        titleOffset = new Vector3(entityVO.HeroHeader(0), entityVO.HeroHeader(1), entityVO.HeroHeader(2));
                    }

                    visibilityDistance = entityVO.MissionTargetHiddenDistance * (isInSpace ? GameConstant.METRE_PER_UNIT : 1);
                }

                //忽略死亡的( 除了矿石 )
                if (heroType != KHeroType.htMine && heroType != KHeroType.htPreicous && (entity.GetAttribute(AttributeName.kHP) <= 0 || entity.GetCurrentState().GetMainState() == EnumMainState.Dead))
                {
                    continue;
                }
                if (entity.m_EntityFatherOwnerID > 0 && heroType == KHeroType.htMine)
                {
                    continue;
                }
                //忽略不支持的
                RectTransform template = GetTemplate(m_MainEntity, entity);
                if (!template)
                {
                    continue;
                }

                //忽略过远的
                float distance = (entity.transform.position - m_MainEntity.transform.position).magnitude;
                if (entity.GetHeroType() == KHeroType.htMine && distance > entity.GetNPCTemplateVO().TriggerRange)
                {
                    continue;
                }
                distance = distance * GameConstant.METRE_PER_UNIT;
                if (distance >= visibilityDistance)
                {
                    continue;
                }

                //忽略屏幕外的
                Vector3 screenPosition = Camera.main.WorldToScreenPoint(entity.transform.TransformPoint(titleOffset));
                if (!(screenPosition.z > Camera.main.nearClipPlane && screenPosition.x >= 0 && screenPosition.x <= Camera.main.pixelWidth && screenPosition.y > 0 && screenPosition.y <= Camera.main.pixelHeight))
                {
                    continue;
                }

                Vector2 anchoredPosition;
                if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_Root, screenPosition, m_Camera, out anchoredPosition))
                {
                    Transform templatePool = m_TemplateToPool[template];

                    uint uid   = entity.GetUId();
                    bool isNew = false;

                    EntityView info;
                    if (m_UIDToRectTranform1.ContainsKey(uid))
                    {
                        info = m_UIDToRectTranform1[uid];
                        m_UIDToRectTranform1.Remove(uid);
                        m_UIDToRectTranform2[uid] = info;
                    }
                    else
                    {
                        RectTransform view = templatePool.childCount > 0 ? templatePool.GetChild(0).GetComponent <RectTransform>() : Object.Instantiate(template, m_Root);
                        view.SetParent(m_Root);
                        view.transform.SetAsLastSibling();
                        view.gameObject.SetActive(true);

                        info = new EntityView()
                        {
                            uid = uid, view = view, viewPool = templatePool
                        };
                        m_UIDToRectTranform2[uid] = info;
                        isNew = true;


                        OnTargetCreate(entity, view);
                    }

                    OnTargetUpdate(m_MainEntity, entity, info.view, anchoredPosition, distance, visibilityDistance, m_MouseMoved, isNew);
                }
            }
        }

        m_MouseMoved = false;

        //回收无效的
        foreach (EntityView info in m_UIDToRectTranform1.Values)
        {
            info.view.SetParent(info.viewPool);
        }
        m_UIDToRectTranform1.Clear();

        Dictionary <uint, EntityView> tmp = m_UIDToRectTranform1;

        m_UIDToRectTranform1 = m_UIDToRectTranform2;
        m_UIDToRectTranform2 = tmp;
    }
コード例 #10
0
 /// <summary>
 /// 设置主角
 /// </summary>
 /// <param name="value"></param>
 public void SetIsProtagonist(bool value, KHeroType KHeroType)
 {
     IsProtagonist = value;
     m_KHeroType   = KHeroType;
 }
コード例 #11
0
    /// <summary>
    /// 更新所有任务标记
    /// </summary>
    protected override void Update()
    {
        if (!IsDead() && !IsWatchOrUIInputMode() && !IsLeaping())
        {
            float w = m_Flags.rect.width;
            float h = m_Flags.rect.height;

            m_ScaleBox.localScale = w > h ? new Vector3(1, h / w, 1) : new Vector3(w / h, 1, 1);

            GameplayProxy    sceneProxy = Facade.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;
            SpacecraftEntity main       = sceneProxy.GetEntityById <SpacecraftEntity>(sceneProxy.GetMainPlayerUID());

            if (!main)
            {
                return;
            }

            List <SpacecraftEntity> entitys = sceneProxy.GetEntities <SpacecraftEntity>();
            for (int i = 0; i < entitys.Count; i++)
            {
                SpacecraftEntity entity      = entitys[i];
                KHeroType        heroType    = entity.GetHeroType();
                Vector3          titleOffset = Vector3.zero;

                //忽略自已
                if (entity == main)
                {
                    continue;
                }

                //忽略不需要显示的NPC
                if (heroType != KHeroType.htPlayer)
                {
                    Npc entityVO = m_CfgEternityProxy.GetNpcByKey(entity.GetTemplateID());
                    //if (entityVO.Display == 0)
                    //continue;

                    if (entityVO.HeroHeaderLength >= 3)
                    {
                        titleOffset = new Vector3(entityVO.HeroHeader(0), entityVO.HeroHeader(1), entityVO.HeroHeader(2));
                    }
                }

                //忽略死亡的( 除了矿石 )
                if (heroType != KHeroType.htMine && heroType != KHeroType.htPreicous && (entity.GetAttribute(AttributeName.kHP) <= 0 || entity.GetCurrentState().GetMainState() == EnumMainState.Dead))
                {
                    continue;
                }

                //忽略不支持的
                RectTransform template = GetTemplate(main, entity);
                if (!template)
                {
                    continue;
                }

                //忽略过远的
                float distance = (entity.transform.position - main.transform.position).magnitude;
                if (entity.GetHeroType() == KHeroType.htMine && distance > entity.GetNPCTemplateVO().TriggerRange)
                {
                    continue;
                }
                distance = distance * GameConstant.METRE_PER_UNIT;
                if (distance >= GameConstant.DEFAULT_VISIBILITY_METRE_FOR_SHIP)
                {
                    continue;
                }

                //忽略屏幕内的
                Vector3 screenPosition = Camera.main.WorldToScreenPoint(entity.transform.TransformPoint(titleOffset));
                if (screenPosition.z > Camera.main.nearClipPlane && screenPosition.x >= 0 && screenPosition.x <= Camera.main.pixelWidth && screenPosition.y > 0 && screenPosition.y <= Camera.main.pixelHeight)
                {
                    // is in screen
                }
                else
                {
                    //忽略屏幕外的
                    Transform templatePool = m_TemplateToPool[template];

                    uint uid = entity.GetUId();

                    EntityView info;
                    if (m_UIDToRectTranform1.ContainsKey(uid))
                    {
                        info = m_UIDToRectTranform1[uid];
                        m_UIDToRectTranform1.Remove(uid);
                        m_UIDToRectTranform2[uid] = info;
                    }
                    else
                    {
                        RectTransform view = templatePool.childCount > 0 ? templatePool.GetChild(0).GetComponent <RectTransform>() : Object.Instantiate(template, m_Flags);
                        view.SetParent(m_Flags);
                        view.transform.SetAsLastSibling();
                        view.gameObject.SetActive(true);

                        info = new EntityView()
                        {
                            uid = uid, view = view, viewPool = templatePool
                        };
                        m_UIDToRectTranform2[uid] = info;

                        OnTargetCreate(view, entity);
                    }

                    OnTargetUpdate(info.view, entity.transform.position, distance);
                }
            }
        }


        //回收无效的
        foreach (EntityView info in m_UIDToRectTranform1.Values)
        {
            info.view.SetParent(info.viewPool);
        }
        m_UIDToRectTranform1.Clear();

        Dictionary <uint, EntityView> tmp = m_UIDToRectTranform1;

        m_UIDToRectTranform1 = m_UIDToRectTranform2;
        m_UIDToRectTranform2 = tmp;
    }