Пример #1
0
    public override void OnBuffRemove()
    {
        base.OnBuffRemove();
        GameplayProxy    gameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;
        SpacecraftEntity mainPlayer    = gameplayProxy.GetMainPlayer();

        if (mainPlayer != null)
        {
            if (gameplayProxy.CanAttackToTarget(mainPlayer, m_Buff.BuffProperty.GetOwner()))
            {
                // 隐身的时候只剩下特效. 如果是敌方隐身, 连特效都看不见了
                // 隐身时隐藏船的本体的功能是在VFXReplaceMeshWithSpacecraft里面做的
                if (gameplayProxy.CanAttackToTarget(mainPlayer, m_Buff.BuffProperty.GetOwner()))
                {
                    List <EffectController> vfxList = m_Buff.BuffProperty.GetAllVFXs();
                    foreach (EffectController iVfx in vfxList)
                    {
                        iVfx.SetCreateForMainPlayer(false);
                        iVfx.PlayFX();
                    }
                }

                m_Buff.BuffProperty.GetPresentation().SetVisibilityOfVFX(true);

                // 现在创建隐身特效时直接把SkinRoot下面的所有东西都隐藏了.
                int spacecraftLayer = LayerUtil.GetLayerByHeroType(m_Buff.BuffProperty.GetHeroType(), m_Buff.BuffProperty.IsMain());
                LayerUtil.SetGameObjectToLayer(m_Buff.BuffProperty.GetSkinRootTransform().gameObject, spacecraftLayer, true);
            }
        }

        m_Buff.BuffProperty.SetInvisible(false);
    }
Пример #2
0
    public override void OnLoopFXLoaded(EffectController vfx)
    {
        GameplayProxy    gameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;
        SpacecraftEntity mainPlayer    = gameplayProxy.GetMainPlayer();

        if (mainPlayer != null)
        {
            if (gameplayProxy.CanAttackToTarget(mainPlayer, m_Buff.BuffProperty.GetOwner()))
            {
                // 隐身的时候只剩下特效. 如果是敌方隐身, 连特效都看不见了
                List <EffectController> vfxList = m_Buff.BuffProperty.GetAllVFXs();
                foreach (EffectController iVfx in vfxList)
                {
                    // HACK. 如果不加这个if判断, 就会把隐身启动的特效一起隐藏掉
                    // 这里如果要完善这个逻辑, 需要做较多的工作. 我就直接偷个懒了.
                    if (!iVfx.GetEffectObject().AutoStop)
                    {
                        iVfx.StopAndRecycleFX(true);
                    }
                }

                m_Buff.BuffProperty.GetPresentation().SetVisibilityOfVFX(false);

                LayerUtil.SetGameObjectToLayer(m_Buff.BuffProperty.GetSkinRootTransform().gameObject, LayerTypeID.UnselectableSpacecraft, true);
            }
        }
    }
Пример #3
0
    /// <summary>
    /// 目标检测
    /// </summary>
    private void RaycastTarget_OLD()
    { 
        //检测目标
		m_CurrentTarget =  m_RaycastProxy.RaycastTarget(m_AutoLockDistance);
		m_CurrentTargetIsFar = m_RaycastProxy.GetCurrentTargetIsFar();
		//准星点追踪
		GameplayProxy sceneProxy = Facade.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;
        SpacecraftEntity main = sceneProxy.GetEntityById<SpacecraftEntity>(sceneProxy.GetMainPlayerUID());

        if (main != null && m_Point && m_Frame)
        {
            SpacecraftEntity target = main.GetTarget();

            m_Point.gameObject.SetActive(true);
            m_Frame.gameObject.SetActive(true);


            //通过阵营或者类型判断
            bool targetIsEnemy = false;
            if (target != null)
            {
				//是否可攻击
				targetIsEnemy = sceneProxy.CanAttackToTarget(main, target);
			}

            if (target != null && !m_CurrentTargetIsFar)
            {
                m_Point.anchoredPosition = Vector2.zero;
                ChangeCrosshairColor(target);
            }
            else
            {
                bool locked = false;

                Vector2 iconPosition = Vector2.zero;
                if (target != null)
                {
                    Vector3 targetPosition = target.transform.position;
                    Vector3 viewportPoint = Camera.main.WorldToViewportPoint(targetPosition);
                    if (viewportPoint.x >= 0 && viewportPoint.y >= 0 && viewportPoint.x <= 1 && viewportPoint.y <= 1 && viewportPoint.z >= Camera.main.nearClipPlane)
                    {
                        Vector2 position2D = Vector2.zero;
                        if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_Root, Camera.main.WorldToScreenPoint(targetPosition), m_Camera, out position2D))
                        {
                            iconPosition = position2D;
                            locked = true;
                        }
                    }
                }

                m_Point.anchoredPosition = m_AutoLockDistance > 0 ? Vector2.Lerp(m_Point.anchoredPosition, iconPosition, m_LerpValue) : Vector2.zero;
                ChangeCrosshairColor(target);
            }

            float radius = Mathf.Max(m_Frame.sizeDelta.x, m_Frame.sizeDelta.y) / 2.0f;
            Vector2 centerPoint = RectTransformUtility.WorldToScreenPoint(m_Camera, m_Frame.transform.position);
            Vector2 rightPoint = RectTransformUtility.WorldToScreenPoint(m_Camera, m_Frame.transform.TransformPoint(Vector3.right * radius));

            m_AutoLockDistance = m_AutoLockEnabled ? Mathf.Abs(centerPoint.x - rightPoint.x) : 0;
        }
    }