/// <summary>
    /// 状态改变
    /// </summary>
    private void OnStateChanged()
    {
        GameplayProxy    proxy  = Facade.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;
        SpacecraftEntity entity = proxy.GetEntityById <SpacecraftEntity>(proxy.GetMainPlayerUID());

        if (entity != null)
        {
            //Debug.LogError(entity.GetCurrentState().IsHasSubState(EnumSubState.LeapPrepare)+", "+ entity.GetCurrentState().IsHasSubState(EnumSubState.Leaping)+", "+ entity.GetCurrentState().IsHasSubState(EnumSubState.LeapCancel));
            if (entity.GetCurrentState().IsHasSubState(EnumSubState.LeapPrepare))
            {
                OnLeapStart(proxy.GetLeapTargetAreaUid());
                SetLeapState(LEAP_PHASE.READY);
            }
            else if (entity.GetCurrentState().IsHasSubState(EnumSubState.Leaping))
            {
                SetLeapState(LEAP_PHASE.LEAP);
            }
            else
            {
                SetLeapState(LEAP_PHASE.NORMAL);
            }
        }
        else
        {
            SetLeapState(LEAP_PHASE.NORMAL);
        }
    }
    /// <summary>
    /// 是否可以取消跃迁
    /// </summary>
    /// <returns></returns>
    private bool IsCanCancelLeap()
    {
        GameplayProxy    gameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;
        SpacecraftEntity entity        = gameplayProxy.GetEntityById <SpacecraftEntity>(gameplayProxy.GetMainPlayerUID());

        return(!entity.GetCurrentState().IsHasSubState(EnumSubState.LeapCancel));
    }
    /// <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);
        }
    }
Exemple #4
0
    /// <summary>
    /// 是否为死亡状态
    /// </summary>
    /// <returns>bool</returns>
    protected bool IsDead()
    {
        SpacecraftEntity entity = GetMainEntity();

        if (entity)
        {
            return(entity.GetCurrentState().GetMainState() == EnumMainState.Dead);
        }
        else
        {
            return(false);
        }
    }
Exemple #5
0
    /// <summary>
    /// 是否为转化炉状态
    /// </summary>
    /// <returns></returns>
    protected bool IsPeerless()
    {
        SpacecraftEntity entity = GetMainEntity();

        if (entity)
        {
            return(entity.GetCurrentState().IsHasSubState(EnumSubState.Peerless));
        }
        else
        {
            return(false);
        }
    }
Exemple #6
0
    /// <summary>
    /// 是否在战斗状态
    /// </summary>
    /// <returns>bool</returns>
    protected bool IsBattling()
    {
        SpacecraftEntity entity = GetMainEntity();

        if (entity)
        {
            return(entity.GetCurrentState().GetMainState() == EnumMainState.Fight);
        }
        else
        {
            return(false);
        }
    }
    public bool UsingReformer()
    {
        SpacecraftEntity mainEntity = m_GameplayProxy.GetEntityById <SpacecraftEntity>(m_GameplayProxy.GetMainPlayerUID());

        if (mainEntity != null)
        {
            //return mainEntity.HasState(ComposableState.PeerlessStatus);
            return(mainEntity.GetCurrentState().IsHasSubState(EnumSubState.Peerless));
        }
        else
        {
            return(false);
        }
    }
    /// <summary>
    /// 是否可以跃迁
    /// </summary>
    /// <returns></returns>
    private bool IsCanLeap()
    {
        GameplayProxy    gameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;
        SpacecraftEntity entity        = gameplayProxy.GetEntityById <SpacecraftEntity>(gameplayProxy.GetMainPlayerUID());

        return((entity.GetCurrentState().GetMainState() == EnumMainState.Cruise || entity.GetCurrentState().GetMainState() == EnumMainState.Born) &&
               !entity.GetCurrentState().IsHasSubState(EnumSubState.Peerless) &&
               !entity.GetCurrentState().IsHasSubState(EnumSubState.LeapPrepare) &&
               !entity.GetCurrentState().IsHasSubState(EnumSubState.Leaping) &&
               !entity.GetCurrentState().IsHasSubState(EnumSubState.LeapCancel));
    }
Exemple #9
0
    /// <summary>
    /// 请求终止跃迁
    /// </summary>
    public void RequestStopLeap(ulong currentAreaID, ulong targetAreaID)
    {
        GameplayProxy    gameplayProxy    = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;
        SpacecraftEntity spacecraftEntity = gameplayProxy.GetMainPlayer();

        Assert.IsTrue(spacecraftEntity != null, "gameplayProxy.GetMainPlayer() is null !!!");
        Rigidbody rigidbody = spacecraftEntity.GetRigidbody();

        Assert.IsTrue(rigidbody != null, "rigidbody is null !!!");

        HeroMoveHandler.SyncLeapCancel(
            spacecraftEntity.GetCurrentState().GetOnlyServerState(),
            (uint)currentAreaID,
            gameplayProxy.ClientToServerAreaOffset(rigidbody.position),
            rigidbody.rotation,
            rigidbody.velocity,
            rigidbody.angularVelocity);
    }
    public bool CanCurrentWeaponRelease()
    {
        SpacecraftEntity mainEntity = m_GameplayProxy.GetEntityById <SpacecraftEntity>(m_GameplayProxy.GetMainPlayerUID());

        if (mainEntity.GetCurrentState().GetMainState() != EnumMainState.Fight || mainEntity.GetCurrSkillId() > 0) //非战斗状态 || 有技能在释放中
        {
            return(false);
        }


        if (UsingReformer())
        {
            return(true);
        }

        IWeapon curWeapon = GetCurrentWeapon();

        if (curWeapon == null)
        {
            return(false);
        }

        return(CanWeaponRelease(curWeapon.GetUID()));
    }
Exemple #11
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;
    }
Exemple #12
0
 public void OnShowTargetHudComponent(SpacecraftEntity entity)
 {
     m_RunIconBoxActive = entity.GetCurrentState().IsHasSubState(EnumSubState.BackToanchor);
 }
    /// <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;
    }