コード例 #1
0
    /// <summary>
    /// 射线检测
    /// </summary>
    /// <param name="main">主角</param>
    /// <param name="distance">射线长度</param>
    /// <param name="target">碰到的目标</param>
    /// <param name="collider">碰到的碰撞体</param>
    private void RaycastTarget(SpacecraftEntity main, float distance, out SpacecraftEntity target, out Collider collider)
    {
        if (GetCamera() != null)
        {
            Ray centerRay = GetCamera().ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
            // 与武器的目标选择逻辑统一
            centerRay.origin    = GetCamera().transform.position;
            centerRay.direction = centerRay.direction.normalized;
            int layerToSelect = (1 << GameConstant.LayerTypeID.HumanNPC) | (1 << GameConstant.LayerTypeID.SpacecraftNPC)
                                | (1 << GameConstant.LayerTypeID.SpacecraftOtherPlayer) | (1 << GameConstant.LayerTypeID.HumanOtherPlayer);
            var allHitInfo = Physics.RaycastAll(centerRay, distance, layerToSelect);
            foreach (var hitInfo in allHitInfo)
            {
                if (hitInfo.collider.attachedRigidbody == null)
                {
                    continue;
                }

                SpacecraftEntity entity = hitInfo.collider.attachedRigidbody.GetComponent <SpacecraftEntity>();
                if (entity == null)
                {
                    continue;
                }
                if (entity == main)
                {
                    continue;
                }
                if (entity.GetHeroType() == KHeroType.htMonsterChest)
                {
                    continue;
                }
                if (entity.GetHeroType() == KHeroType.htNpc)
                {
                    continue;
                }
                if (entity.GetHeroType() == KHeroType.htPlayer)
                {
                    continue;
                }

                target   = entity;
                collider = hitInfo.collider;

                return;
            }
        }

        target   = null;
        collider = null;
    }
コード例 #2
0
    private bool RaycastTarget(float distance, out SpacecraftEntity target, out Vector3 targetPoint, out Collider collider)
    {
        if (Camera.main != null)
        {
            RaycastHit[] allHitInfo = Physics.RaycastAll(Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0)), distance);
            foreach (var hitInfo in allHitInfo)
            {
                if (hitInfo.collider.attachedRigidbody == null)
                {
                    continue;
                }

                SpacecraftEntity entity = hitInfo.collider.attachedRigidbody.GetComponent <SpacecraftEntity>();

                if (entity == null)
                {
                    continue;
                }
                if (entity == m_PickTargetProperty.GetOwner())
                {
                    continue;
                }
                if (entity.GetHeroType() == KHeroType.htMonsterChest)
                {
                    continue;
                }
                if (entity.GetHeroType() == KHeroType.htNpc)
                {
                    continue;
                }

                target      = entity;
                targetPoint = hitInfo.point;
                collider    = hitInfo.collider;
                return(true);
            }
        }

        target      = null;
        targetPoint = Vector3.zero;
        collider    = null;
        return(false);
    }
コード例 #3
0
 /// <summary>
 /// 获取模板
 /// </summary>
 /// <param name="main">主角</param>
 /// <param name="target">目标</param>
 /// <returns>模板</returns>
 private RectTransform GetTemplate(SpacecraftEntity main, SpacecraftEntity target)
 {
     switch (target.GetHeroType())
     {
     case KHeroType.htPreicous:
     case KHeroType.htDetector:
         return(m_DetectorTemplate);
     }
     return(null);
 }
コード例 #4
0
    /// <summary>
    /// 获取模板
    /// </summary>
    /// <param name="main">主角</param>
    /// <param name="target">目标</param>
    /// <returns>模板</returns>
    private RectTransform GetTemplate(SpacecraftEntity main, SpacecraftEntity target)
    {
        switch (target.GetHeroType())
        {
        case KHeroType.htMonster:
            return(m_CfgEternityProxy.GetRelation(main.GetCampID(), target.GetCampID()) == CampRelation.Enemy ? m_EnemyTemplate : m_UAVTemplate);

        case KHeroType.htEliteMonster2:
            return(m_BossTemplate);

        case KHeroType.htPlayer:
            return(m_FriendTemplate);

        case KHeroType.htNpc:
            return(m_NpcTemplate);

        case KHeroType.htMine:
            return(m_MineralTemplate);

        case KHeroType.htPreicous:
        case KHeroType.htDetector:
            return(m_DetectorTemplate);

        case KHeroType.htRareChestGuard:
            return(m_BossTemplate);

        case KHeroType.htNormalChestGuard:
            return(m_EnemyTemplate);

        case KHeroType.htDisturbor:
            return(m_EnemyTemplate);

        case KHeroType.htBeEscortedNpc:
            return(m_EscortTemplate);

        default:
            Debug.Log(target + "===类型不对==" + target.GetHeroType());
            return(m_EnemyTemplate);
        }
        return(null);
    }
コード例 #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
    /// <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);
            }
        }
    }
コード例 #7
0
    private void UpdateCurrentTarget()
    {
        m_CurrentTarget = null;
        if (IsBattling())
        {
            if (m_MainSpacecraftEntity)
            {
                m_CurrentTarget = m_MainSpacecraftEntity.GetTarget();
            }
        }
        else
        {
            m_CurrentTarget = m_RaycastProxy.Raycast();
        }

        if (m_CurrentTarget != null)
        {
            if ((m_CurrentTarget.GetHeroType() != KHeroType.htMine || m_CurrentTarget.GetAttribute(AttributeName.kHP) <= 0))
            {
                m_CurrentTarget = null;
            }
        }
    }
コード例 #8
0
    /// <summary>
    /// 保存AI召唤的所有怪物信息
    /// </summary>
    public void SaveAICallMonsterInfo(S2C_PLOT_MONSTER_LIST msg)
    {
        if (m_AICallMonsterDic.ContainsKey(msg.npc_id))
        {
            m_AICallMonsterDic[msg.npc_id].m_MonsterList = msg.monster_uids;
        }
        else
        {
            MonsterList ml = new MonsterList();
            ml.m_MonsterList = msg.monster_uids;
            m_AICallMonsterDic.Add(msg.npc_id, ml);
        }
        int count = msg.monster_uids.Count;

        for (int i = 0; i < count; ++i)
        {
            uint             uid  = (uint)msg.monster_uids[i];
            SpacecraftEntity ship = m_GameplayProxy.GetEntityById <SpacecraftEntity>(uid);
            if (ship != null && ship.GetHeroType() == Assets.Scripts.Define.KHeroType.htEliteMonster2)
            {
                m_HasCallBossSuccess = true;
            }
        }
    }
コード例 #9
0
    /// <summary>
    /// 标记创建时
    /// </summary>
    /// <param name="flag">视图</param>
    /// <param name="entity">实体</param>
    private void OnTargetCreate(RectTransform flag, SpacecraftEntity entity)
    {
        Image flagIcon = flag.transform.Find("IconMissionElement/Icon").GetComponent <Image>();

        if (flagIcon)
        {
            uint iconID = 0;
            switch (entity.GetHeroType())
            {
            case KHeroType.htPreicous: iconID = 32008; break;

            case KHeroType.htDetector: iconID = 32009; break;
            }
            if (iconID != 0)
            {
                flagIcon.gameObject.SetActive(true);
                UIUtil.SetIconImage(flagIcon, iconID);
            }
            else
            {
                flagIcon.gameObject.SetActive(false);
            }
        }
    }
コード例 #10
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;
    }
コード例 #11
0
    /// <summary>
    /// 干扰器与封印守卫的音效
    /// 和干扰器数量相关
    /// </summary>
    public void DisturborSoundEffect(uint ownerHeroID)
    {
        if (ownerHeroID == 0)
        {
            return;
        }

        SpacecraftEntity ownerEntity = m_GameplayProxy.GetEntityById <SpacecraftEntity>(ownerHeroID);

        /// WwiseUtil.PlaySound((int)WwiseMusic.Treasure_Disturbor_Sound5, false, ownerEntity.GetSkinTransform());
        ownerEntity.SendEvent(ComponentEventName.PlaySound, new PlaySound()
        {
            SoundID   = (int)WwiseMusic.Treasure_Disturbor_Sound5,
            Transform = ownerEntity.GetSkinTransform()
        });

        List <SpacecraftEntity> entites      = m_GameplayProxy.GetEntities <SpacecraftEntity>();
        List <SpacecraftEntity> entitesCache = new List <SpacecraftEntity>();
        int count = 0;

        for (int i = 0; i < entites.Count; i++)
        {
            SpacecraftEntity entity = entites[i];
            if (!entity.IsDead() && entity.GetHeroType() == KHeroType.htDisturbor && entity.m_EntityFatherOwnerID == ownerHeroID)
            {
                count++;
                entitesCache.Add(entity);
            }
        }

        Debug.Log("KHeroType.htDisturbor count" + count);
        /// TODO.
        int soundId = 0;

        if (count == 6)
        {
            soundId = (int)WwiseMusic.Treasure_Disturbor_Sound1;
        }
        else if (count == 5 || count == 4)
        {
            soundId = (int)WwiseMusic.Treasure_Disturbor_Sound2;
        }
        else if (count == 3 || count == 2)
        {
            soundId = (int)WwiseMusic.Treasure_Disturbor_Sound3;
        }
        else if (count == 1)
        {
            soundId = (int)WwiseMusic.Treasure_Disturbor_Sound4;
        }

        if (soundId != 0)
        {
            entitesCache.Add(ownerEntity);
            for (int i = 0; i < entitesCache.Count; i++)
            {
                /// WwiseUtil.PlaySound(soundId, false, entitesCache[i].GetSkinTransform());
                entitesCache[i].SendEvent(ComponentEventName.PlaySound, new PlaySound()
                {
                    SoundID   = soundId,
                    Transform = entitesCache[i].GetSkinTransform()
                });
            }
        }
    }
コード例 #12
0
    /// <summary>
    /// 更新UI
    /// </summary>
    protected override void Update()
    {
        GameplayProxy    gameplayProxy = Facade.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;
        SpacecraftEntity main          = gameplayProxy.GetEntityById <SpacecraftEntity>(gameplayProxy.GetMainPlayerUID());

        if (main == null)
        {
            return;
        }

        bool needCrosshair = !IsWatchOrUIInputMode() && !IsDead() && !IsLeaping() && !IsBattling();
        bool hasMineral    = false;

        if (needCrosshair)
        {
            SpacecraftEntity target = m_RaycastProxy.Raycast();
            hasMineral = target != null && target.GetHeroType() == Assets.Scripts.Define.KHeroType.htMine && target.GetAttribute(AttributeName.kHP) > 0;
        }
        m_Crosshair.gameObject.SetActive(needCrosshair);
        m_JumpCrosshair.gameObject.SetActive(!hasMineral);
        m_MineralCrosshair.gameObject.SetActive(hasMineral);

        float w = m_Root.rect.width;
        float h = m_Root.rect.height;

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

        m_HaveMissionFlagPoints.Clear();
        List <TaskTrackingProxy.TrackingInfo> trackingList = m_TaskTracking.GetAllTrackings();

        for (int i = 0; i < trackingList.Count; i++)
        {
            if (trackingList[i].Mode == TaskTrackingProxy.TrackingMode.LeapPoint)
            {
                m_HaveMissionFlagPoints.Add((uint)trackingList[i].LeapPointID);
            }
        }

        ulong currentAreaID = MapManager.GetInstance().GetCurrentAreaUid();

        uint[] visibleLeapIDs = null;
        for (int i = 0; i < m_LeapCfgs.Count; i++)
        {
            if (m_LeapCfgs[i].LeapId == currentAreaID)
            {
                visibleLeapIDs = m_LeapCfgs[i].GetVisibleLeapListArray();
                break;
            }
        }

        int     hitedPointIndex = -1;
        bool    allowVisible    = !IsDead() && !IsWatchOrUIInputMode();// && !IsBattling();
        Vector2 screenCenter    = new Vector2(Screen.width / 2, Screen.height / 2);

        for (int i = 0; i < m_LeapCfgs.Count; i++)
        {
            RectTransform point = m_PointBox.GetChild(i).GetComponent <RectTransform>();
            RectTransform arrow = m_ArrowBox.GetChild(i).GetComponent <RectTransform>();

            if (!allowVisible)
            {
                arrow.gameObject.SetActive(false);
                point.gameObject.SetActive(false);
                continue;
            }

            LeapItem leapVO = m_LeapCfgs[i];
            uint     leapID = (uint)leapVO.LeapId;

            if (visibleLeapIDs != null && System.Array.IndexOf(visibleLeapIDs, leapID) == -1)
            {
                arrow.gameObject.SetActive(false);
                point.gameObject.SetActive(false);
                continue;
            }

            Vector3 targetWorldPosition = gameplayProxy.WorldPositionToServerAreaOffsetPosition(new Vector3((float)leapVO.Position.Value.X, (float)leapVO.Position.Value.Y, (float)leapVO.Position.Value.Z));

            //目标过远,忽略
            float distance = Vector3.Distance(targetWorldPosition, main.transform.position);
            if (distance <= leapVO.Range * GameConstant.METRE_PER_UNIT)
            {
                arrow.gameObject.SetActive(false);
                point.gameObject.SetActive(false);
                continue;
            }

            Vector3 viewportPoint = Camera.main.WorldToViewportPoint(targetWorldPosition);
            if (viewportPoint.x >= 0 && viewportPoint.y >= 0 && viewportPoint.x <= 1 && viewportPoint.y <= 1 && viewportPoint.z >= Camera.main.nearClipPlane)
            {
                //屏幕内
                Vector3 screenPoint = Camera.main.WorldToScreenPoint(targetWorldPosition);

                Vector2 iconPosition;
                if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_PointBox, screenPoint, m_Camera, out iconPosition))
                {
                    arrow.gameObject.SetActive(false);
                    point.gameObject.SetActive(true);

                    point.anchoredPosition = iconPosition;
                    point.localScale       = Vector3.one * LEAP_POINT_SCALE;
                    point.Find("JumpTips/TextBox/Distance").GetComponent <TMP_Text>().text = FormatMetre(distance * GameConstant.METRE_PER_UNIT);

                    if (hitedPointIndex == -1)
                    {
                        Vector2 crosshairPosition;
                        if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_Crosshair, screenPoint, m_Camera, out crosshairPosition))
                        {
                            //确定选中项
                            if (crosshairPosition.magnitude <= m_Crosshair.rect.width * 0.5f)
                            {
                                hitedPointIndex = i;
                            }
                        }
                    }
                }
            }
            else
            {
                if (m_HaveMissionFlagPoints.Contains(leapID))
                {
                    arrow.gameObject.SetActive(false);
                    point.gameObject.SetActive(false);
                    continue;
                }

                //屏幕外
                point.gameObject.SetActive(false);
                arrow.gameObject.SetActive(true);

                Vector3 inCameraPosition = Camera.main.transform.InverseTransformPoint(targetWorldPosition);

                Vector2 arrowPosition = m_ScaleBox.InverseTransformPoint(m_Root.TransformPoint(((Vector2)inCameraPosition)));
                arrowPosition = arrowPosition.normalized * (Mathf.Max(m_Root.rect.width, m_Root.rect.height) / 2);
                arrowPosition = m_Root.InverseTransformPoint(m_ScaleBox.TransformPoint(arrowPosition));


                arrow.anchoredPosition = arrowPosition;
                arrow.localScale       = Vector3.one * ARROW_SCALE;

                RectTransform arrowArrow = FindComponent <RectTransform>(arrow, "Arrow");
                arrowArrow.localRotation = Quaternion.Euler(0, 0, Mathf.Atan2(inCameraPosition.y, inCameraPosition.x) * Mathf.Rad2Deg - 90);
            }
        }

        //如果处理战斗状态,强制取消选中
        if (IsBattling())
        {
            hitedPointIndex = -1;
        }

        //只能在NORMAL状态下换目标
        if (m_LeapState == LEAP_PHASE.NORMAL && m_CurrentIndex != hitedPointIndex)
        {
            if (m_CurrentIndex != -1)
            {
                RectTransform point          = m_PointBox.GetChild(m_CurrentIndex).GetComponent <RectTransform>();
                Animator      tipAnimator    = point.Find("JumpTips").GetComponent <Animator>();
                Animator      iconBgAnimator = point.Find("IconBg").GetComponent <Animator>();
                Animator      iconAnimator   = point.Find("Icon").GetComponent <Animator>();
                Transform     missionBox     = point.Find("MissionBox");

                tipAnimator.ResetTrigger("Closed");
                tipAnimator.ResetTrigger("Open");
                tipAnimator.SetTrigger("Closed");

                iconBgAnimator.ResetTrigger("Closed");
                iconBgAnimator.ResetTrigger("Open");
                iconBgAnimator.SetTrigger("Closed");

                iconAnimator.SetBool("selected", false);

                missionBox.gameObject.SetActive(true);
            }
            //Debug.LogError(m_LeapState + "=>" + m_CurrentIndex + " -> " + hitedPointIndex);
            m_CurrentIndex = hitedPointIndex;

            if (m_CurrentIndex != -1)
            {
                RectTransform point          = m_PointBox.GetChild(m_CurrentIndex).GetComponent <RectTransform>();
                Animator      tipAnimator    = point.Find("JumpTips").GetComponent <Animator>();
                Animator      iconBgAnimator = point.Find("IconBg").GetComponent <Animator>();
                Animator      iconAnimator   = point.Find("Icon").GetComponent <Animator>();
                Transform     missionBox     = point.Find("MissionBox");

                tipAnimator.ResetTrigger("Closed");
                tipAnimator.ResetTrigger("Open");
                tipAnimator.SetTrigger("Open");

                iconBgAnimator.ResetTrigger("Closed");
                iconBgAnimator.ResetTrigger("Open");
                iconBgAnimator.SetTrigger("Open");

                iconAnimator.SetBool("selected", true);

                missionBox.gameObject.SetActive(false);

                m_HotKeyBox.SetParent(point.Find("JumpTips/TextBox/HotKeyBox"));
                m_HotKeyBox.gameObject.SetActive(true);
                SetHotKeyVisible("f_hold", true);
                SetHotKeyVisible("f_press", false);
            }
            else
            {
                m_HotKeyBox.SetParent(GetTransform());
                m_HotKeyBox.gameObject.SetActive(false);
                SetHotKeyVisible("f_hold", false);
                SetHotKeyVisible("f_press", false);
            }
        }

        UpdateMissionState();
    }
コード例 #13
0
    /// <summary>
    /// 技能命中效果
    /// </summary>
    /// <param name="buf"></param>
    private void OnSkillEffect_ServerMessage(IComponentEvent componentEvent)
    {
        S2C_SKILL_EFFECT_Event respond = componentEvent as S2C_SKILL_EFFECT_Event;

        uint MainID = m_GameplayProxy.GetMainPlayerUID();

        SpacecraftEntity caster = m_GameplayProxy.GetEntityById <SpacecraftEntity>(respond.msg.wCasterID) as SpacecraftEntity;
        SpacecraftEntity target = m_GameplayProxy.GetEntityById <SpacecraftEntity>(respond.msg.wTargetHeroID) as SpacecraftEntity;

        if ((caster != null && caster.IsMain()) ||
            (target != null && target.IsMain()) ||
            (caster != null && caster.GetEntityFatherOwnerID() == MainID) ||
            (target != null && target.GetEntityFatherOwnerID() == MainID)
            )
        {
            SkillHurtInfo hurtInfo = MessageSingleton.Get <SkillHurtInfo>();
            hurtInfo.TargetID          = respond.msg.wTargetHeroID;
            hurtInfo.IsCrit            = respond.msg.crit_type != 0;
            hurtInfo.PenetrationDamage = (int)respond.msg.PenetrationDamage;
            hurtInfo.IsDodge           = respond.msg.isdoge != 0;
            hurtInfo.EffectID          = (int)(respond.msg.byAttackEvent == (byte)EffectType.TriggerAnomaly ? respond.msg.wTriggerID : 0);
            hurtInfo.IsWeak            = respond.msg.crit_type == 3;

            for (int iDamage = 0; iDamage < respond.msg.count; iDamage++)
            {
                hurtInfo.Damage = (int)(respond.msg.wDamage / respond.msg.count);
                GameFacade.Instance.SendNotification(NotificationName.SkillHurt, hurtInfo);
            }

            // 采矿的表现 (矿物碎裂)
            SpacecraftEntity currentTargetEntity = m_Property.GetTarget();
            if (currentTargetEntity != null && currentTargetEntity.GetHeroType() == KHeroType.htMine && caster.GetTargetCollider() != null)
            {
                MineDamage mineEvent = new MineDamage();
                mineEvent.HitCollider = caster.GetTargetCollider();
                mineEvent.Damage      = respond.msg.wDamage;
                currentTargetEntity.SendEvent(ComponentEventName.MineDamage, mineEvent);
            }
        }

        if (target && target.IsMain())
        {
            if (m_Property.GetUnderAttackWarningToneCountdown() == 0)
            {
                WwiseUtil.PlaySound(WwiseManager.voiceComboID, WwiseMusicSpecialType.SpecialType_Voice_Be_Attacked, WwiseMusicPalce.Palce_1st, false, null);
            }

            float countDown = m_CfgEternityProxy.GetGamingConfig(1).Value.Sound.Value.CountDown.Value.UnderAttackWarningTone;
            m_Property.SetUnderAttackWarningToneCountdown(countDown);
        }

        /// 播放弱点攻击声音提示
        /// TODO.crit_type暂时没有枚举
        if (caster && caster.IsMain())
        {
            if (m_WeakSoundTmpCD >= m_WeakSoundCD && respond.msg.crit_type == 3)
            {
                float val = Random.value;
                if (val <= m_WeakSoundProbability)
                {
                    SendEvent(ComponentEventName.PlayVideoSound, new PlayVideoSound()
                    {
                        GroupID = (int)m_CfgEternityProxy.GetGamingConfig(1).Value.Mine.Value.Sound.Value.WeaknessSoundVideo
                    });
                    m_WeakSoundTmpCD = 0;
                }
            }
        }
    }
コード例 #14
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;
    }
コード例 #15
0
    /// <summary>
    /// 更新
    /// </summary>
    protected override void Update()
    {
        bool visibleOld = GetTransform().gameObject.activeSelf;
        bool visibleNew = !IsWatchOrUIInputMode() && !IsDead() && !IsLeaping();

        if (visibleNew != visibleOld)
        {
            GetTransform().gameObject.SetActive(visibleNew);
        }

        if (!visibleNew)
        {
            return;
        }

        GameplayProxy proxy = Facade.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;

        SpacecraftEntity main = proxy.GetEntityById <SpacecraftEntity>(proxy.GetMainPlayerUID());

        if (main != null)
        {
            m_Arrow.localEulerAngles    = new Vector3(0, 0, -main.transform.eulerAngles.y);
            m_Viewport.localEulerAngles = new Vector3(0, 0, -Camera.main.transform.eulerAngles.y);

            int   index       = 0;
            float maxDistance = m_RangeImage.rect.width / 2;
            List <SpacecraftEntity> entitys = proxy.GetEntities <SpacecraftEntity>();
            for (int i = 0; i < entitys.Count; i++)
            {
                SpacecraftEntity entity = entitys[i];
                /// 过滤掉主角
                if (entity != main)
                {
                    float distance = Vector3.Distance(entity.transform.position, main.transform.position) * GameConstant.METRE_PER_UNIT;
                    /// 是否更新小地图
                    bool update = false;
                    /// 玩家没有npc,不考虑贴边显示
                    if (entity.GetHeroType() == KHeroType.htPlayer)
                    {
                        update = distance < GameConstant.DEFAULT_VISIBILITY_METRE_FOR_SHIP;
                    }
                    else
                    {
                        Npc  npc      = entity.GetNPCTemplateVO();
                        bool overView = npc.OverView;
                        if (overView)
                        {
                            distance = Mathf.Min(distance, GameConstant.DEFAULT_VISIBILITY_METRE_FOR_SHIP);
                            update   = true;
                        }
                        else if (distance < GameConstant.DEFAULT_VISIBILITY_METRE_FOR_SHIP)
                        {
                            update = true;
                        }
                    }

                    if (update)
                    {
                        if (index >= m_ImageView.childCount)
                        {
                            Object.Instantiate(m_Enemy, m_ImageView);
                        }
                        m_ImageView.GetChild(index).localEulerAngles = new Vector3(0, 0, 0);
                        UpdateTarget(m_ImageView.GetChild(index).GetComponent <RectTransform>(), maxDistance * (distance / GameConstant.DEFAULT_VISIBILITY_METRE_FOR_SHIP), main, entity);
                        index++;
                    }
                }
            }

            for (int i = index; i < m_ImageView.childCount; i++)
            {
                m_ImageView.GetChild(i).gameObject.SetActive(false);
            }
        }
    }
コード例 #16
0
    /// <summary>
    /// 更新目标
    /// </summary>
    /// <param name="main">主角</param>
    /// <param name="target">目标</param>
    /// <param name="view">UI</param>
    /// <param name="anchoredPosition">坐标</param>
    /// <param name="distance">距离</param>
    private void OnTargetUpdate(SpacecraftEntity main, SpacecraftEntity target, RectTransform view, Vector3 anchoredPosition, float distance, float visibleDistance, bool mouseMoved, bool IsNew)
    {
        TaskTrackingProxy taskTrackingProxy = Facade.RetrieveProxy(ProxyName.TaskTrackingProxy) as TaskTrackingProxy;

        float hp    = (float)target.GetAttribute(AttributeName.kHP);
        float hpMax = (float)target.GetAttribute(AttributeName.kHPMax);
        float mp    = (float)target.GetAttribute(AttributeName.kShieldValue);
        float mpMax = (float)target.GetAttribute(AttributeName.kShieldMax);

        float hpProgress = hpMax <= 0 ? 0.0f : hp / hpMax;
        float mpProgress = mpMax <= 0 ? 0.0f : mp / mpMax;

        //坐标
        view.anchoredPosition = anchoredPosition;

        if (target.GetHeroType() == KHeroType.htMine)
        {
            m_BloodImage            = FindComponent <Image>(view, "Slider/Image_Bar");
            m_BloodImage.fillAmount = hpProgress;
            TMP_Text hpText = FindComponent <TMP_Text>(view, "Name/Name/Label_Value");//血值比率
            if (hpText)
            {
                int textID = 1025;
                if (hpProgress <= 0.0f)
                {
                    textID = 1021;
                }
                else if (hpProgress <= 0.2f)
                {
                    textID = 1022;
                }
                else if (hpProgress <= 0.4f)
                {
                    textID = 1023;
                }
                else if (hpProgress <= 0.6f)
                {
                    textID = 1024;
                }

                hpText.text = GetLocalization("hud_text_id_" + textID);
            }

            //动画
            Animator animator = view.GetComponent <Animator>();
            if (animator)
            {
                SpacecraftEntity currentTarget = m_RaycastProxy.Raycast();

                animator.SetBool("isBattle", IsBattling());
                animator.SetBool("isTarget", currentTarget == target);
                if (mouseMoved)
                {
                    animator.SetTrigger("mouseMoved");
                }
            }
        }
        else
        {
            //血值
            Slider mpSlider = FindComponent <Slider>(view, "Slider/Slider_MP");
            if (mpSlider)
            {
                mpSlider.value = mpProgress;
            }

            //护甲
            Slider hpSlider = FindComponent <Slider>(view, "Slider/Slider_Hp");
            if (hpSlider)
            {
                hpSlider.value = hpProgress;
            }

            //距离
            TMP_Text distanceField = FindComponent <TMP_Text>(view, "Name/Distance");
            if (distanceField)
            {
                distanceField.text = FormatMetre(distance);
            }

            //任务
            RectTransform missionBox = FindComponent <RectTransform>(view, "MissionIconBox");
            if (missionBox)
            {
                bool needShowMissionFlag = distance < visibleDistance;
                if (needShowMissionFlag && !taskTrackingProxy.GetAreadyAddMissionInfo(target.GetUId(), target.GetTemplateID()))
                {
                    TaskTrackingProxy.TrackingInfo tracking = taskTrackingProxy.GetNpcMission(target.GetUId(), target.GetTemplateID());
                    MissionType missionType = tracking != null ? tracking.MissionType : MissionType.None;

                    missionBox.gameObject.SetActive(missionType != MissionType.None);
                    if (missionBox.gameObject.activeSelf)
                    {
                        Animator missionAniamtor = FindComponent <Animator>(missionBox, "IconMissionElement");
                        Image    missionIcon     = FindComponent <Image>(missionAniamtor, "Icon");

                        UIUtil.SetIconImage(missionIcon, GameConstant.FUNCTION_ICON_ATLAS_ASSETADDRESS, GetMissionIcon(missionType));

                        missionAniamtor.SetBool("Finished", tracking != null && tracking.MissionState == MissionState.Finished);
                    }
                }
                else
                {
                    missionBox.gameObject.SetActive(false);
                }
            }

            //逃跑
            Transform escapeTransform = FindComponent <Transform>(view, "RunIconBox ");
            if (escapeTransform != null && escapeTransform.gameObject.activeSelf != m_RunIconBoxActive)
            {
                escapeTransform.gameObject.SetActive(m_RunIconBoxActive);
            }

            //动画
            Animator      animator        = view.GetComponent <Animator>();
            Transform     buffIconBoxTras = view.Find("BuffIconBox");
            RectTransform bufferIconBox   = null;
            if (buffIconBoxTras)
            {
                bufferIconBox = buffIconBoxTras.GetComponent <RectTransform>();
            }
            if (animator)
            {
                if (distance < GameConstant.DEFAULT_VISIBILITY_METRE_FOR_SHIP / 2)
                {
                    if (main.GetTarget() == target)
                    {
                        if (bufferIconBox)
                        {
                            bufferIconBox.localPosition = m_NormalBufferPos;
                        }
                        animator.SetInteger("State", 2);
                    }
                    else
                    {
                        if (bufferIconBox)
                        {
                            bufferIconBox.localPosition = m_NormalBufferPos;
                        }
                        animator.SetInteger("State", 1);
                    }
                }
                else
                {
                    if (bufferIconBox)
                    {
                        bufferIconBox.localPosition = m_AwayFromBufferPos;
                    }
                    animator.SetInteger("State", 0);
                }

                if (target == main)
                {
                    if (bufferIconBox)
                    {
                        bufferIconBox.localPosition = m_SelfBufferPos;
                    }
                    animator.SetInteger("State", 0);
                    view.Find("Icon").gameObject.SetActive(false);
                }
            }

            if (IsNew)
            {
                OnAddBufferIcon(target);
            }
        }
    }
コード例 #17
0
    /// <summary>
    /// 显示开宝箱
    /// </summary>
    public void ShowOpenChest()
    {
        if (!IsDead() && !IsBattling() && !IsLeaping() && !IsWatchOrUIInputMode())
        {
            SpacecraftEntity entity = m_RaycastProxy.Raycast();
            if (entity && (entity.GetCurrentState().GetMainState() != EnumMainState.Dead) && entity.GetHeroType() == KHeroType.htLockChest)
            {
                Vector3 titleOffset = Vector3.zero;
                m_TargetNpcUID = entity.GetUId();
                //头顶偏移

                Npc entityVO = m_CfgEternityProxy.GetNpcByKey(entity.GetTemplateID());
                if (Vector3.Distance(entity.transform.position, m_MainEntity.transform.position) > entityVO.TriggerRange)
                {
                    return;
                }
                if (entityVO.HeroHeaderLength >= 3)
                {
                    titleOffset = new Vector3(entityVO.HeroHeader(0), entityVO.HeroHeader(1), entityVO.HeroHeader(2));
                }

                //忽略屏幕外的
                Vector3 screenPosition = m_MainCamera.WorldToScreenPoint(entity.transform.TransformPoint(titleOffset));
                if (screenPosition.z > m_MainCamera.nearClipPlane && screenPosition.x >= 0 && screenPosition.x <= m_MainCamera.pixelWidth && screenPosition.y > 0 && screenPosition.y <= Camera.main.pixelHeight)
                {
                    Vector2 anchoredPosition;
                    if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_Root, screenPosition, m_Camera, out anchoredPosition))
                    {
                        m_Content.anchorMin        = m_Content.anchorMax = Vector2.one * 0.5f;
                        m_Content.anchoredPosition = anchoredPosition;
                    }

                    if (!m_Content.gameObject.activeSelf && entity.GetIsActive())
                    {
                        m_Content.gameObject.SetActive(true);
                        ResetAnimators(null, HotkeyPhase.Disabled, true);
                    }
                }
                else
                {
                    m_Content.gameObject.SetActive(false);
                }
                return;
            }
            else
            {
                m_Content.gameObject.SetActive(false);
            }
        }
        else
        {
            m_Content.gameObject.SetActive(false);
        }
    }