예제 #1
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);
            }
        }
    }
예제 #2
0
    /// <summary>
    /// 加载模型
    /// </summary>
    /// <param name="target"></param>
    private void LoadViewerModel(SpacecraftEntity target)
    {
        if (m_NearestTarget != target)
        {
            m_NearestTarget = target;
            if (m_NearestTarget)
            {
                m_TargetList.Clear();
                if (m_NearestTarget.m_EntityFatherOwnerID == 0 && m_NearestTarget.HeroGroupId == 0)
                {
                    m_TargetViewer.LoadModel(ASSET_UI3DShip, FindSingleMine(), ASSET_UI3DEffect);
                }
                else
                {
                    m_TargetViewer.LoadModel(ASSET_UI3DShip, FindSubsidiaryMine(), ASSET_UI3DEffect);
                }

                if (!m_NearestTargetLast)
                {
                    PlaySound(WwiseMusicSpecialType.SpecialType_Voice_minera_event1);
                }
            }
            else
            {
                m_TargetViewer.ClearModel();
            }

            if (m_NearestTargetLast && m_NearestTargetLast.GetAttribute(AttributeName.kHP) <= 0)
            {
                PlaySound(WwiseMusicSpecialType.SpecialType_Voice_minera_event2);
            }
            m_NearestTargetLast = m_NearestTarget;
        }
    }
예제 #3
0
    public void TryToLockThisTarget(SpacecraftEntity newTarget)
    {
        // UNDONE. 需要添加阵营判断逻辑. 判断是不是敌人. 等待阵营功能完成
        if (newTarget == null)
        {
            return;
        }
        else
        {
            SLog("选中此目标进行锁定. {0}", newTarget.name);
        }

        // 新的目标有两种可能. 1. 不在当前目标列表里面 且 不为空, 2. 在目标列表里, 但是此目标已经锁定完成, 可以进行下一轮锁定
        if (!m_LockTargeMap.ContainsKey(newTarget))
        {
            TargetLockInfo targetLockInfo = new TargetLockInfo();
            targetLockInfo.LockState         = TargetLockState.Locking;
            targetLockInfo.LockTimeRemaining = m_LockonTimeParam;
            targetLockInfo.LockTimes         = 0;
            m_LockTargeMap.Add(newTarget, targetLockInfo);

            SLog("锁定新目标. {0}", newTarget.name);
        }
        else if (IsLockedEntity(newTarget))
        {
            m_LockTargeMap[newTarget].LockTimeRemaining = m_LockonTimeParam;
            m_LockTargeMap[newTarget].LockState         = TargetLockState.Locking;

            SLog("锁定老目标, 为其增加一层锁定层数. {0}", newTarget.name);
        }
        else
        {
            //SLog("目标正在锁定中, 却作为新目标被选中了. {0}", newTarget.name);
        }
    }
예제 #4
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);
    }
예제 #5
0
    /// <summary>
    /// 播放入侵语音
    /// </summary>
    private void PlayInvaded()
    {
        if (m_CurrentAIUid <= 0)
        {
            return;
        }

        AddEffectOnPlayer(1);
        SpacecraftEntity AI = m_GameplayProxy.GetEntityById <SpacecraftEntity>((uint)m_CurrentAIUid);

        if (AI == null)
        {
            return;
        }

        Vector3 targetPosition = AI.transform.position;
        Vector3 viewportPoint  = Camera.main.WorldToViewportPoint(targetPosition);
        bool    inScreen       = viewportPoint.x >= 0 && viewportPoint.y >= 0 &&
                                 viewportPoint.x <= 1 && viewportPoint.y <= 1 && viewportPoint.z > Camera.main.nearClipPlane;

        if (inScreen)
        {
            m_IsPlayIngEff = true;
            PlayFoundEnemyPanel();
        }


        SendNotification((int)m_JujubeBattlefield.SystemVoice.Value.HackedWarning);
    }
예제 #6
0
    /// <summary>
    /// 主角正在释放武器技能
    /// </summary>
    /// <returns></returns>
    public bool IsMainPlayerUsingWeaponSkill()
    {
        SpacecraftEntity mainPlayer = m_GameplayProxy.GetEntityById <SpacecraftEntity>(m_GameplayProxy.GetMainPlayerUID());

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

        int skillID = mainPlayer.GetCurrSkillId();

        if (skillID > 0 && m_CfgSkillProxy.IsWeaponSkill(skillID) &&
            (mainPlayer.GetCurrentSkillState() == SkillState.Channelling ||
             mainPlayer.GetCurrentSkillState() == SkillState.ManualChannelling ||
             mainPlayer.GetCurrentSkillState() == SkillState.AutoChannelling ||
             mainPlayer.GetCurrentSkillState() == SkillState.RapidFire))
        {
            return(true);
        }

        if (mainPlayer.IsReleasingTriggerSkill() &&
            mainPlayer.GetTriggerSkillID() > 0 &&
            m_CfgSkillProxy.IsWeaponSkill(mainPlayer.GetTriggerSkillID()))
        {
            return(true);
        }

        return(false);
    }
예제 #7
0
    public Buff(BuffVO vo, IBuffProperty property)
    {
        VO           = vo;
        BuffProperty = property;

        // Cache
        m_SkillProxy    = GameFacade.Instance.RetrieveProxy(ProxyName.CfgSkillSystemProxy) as CfgSkillSystemProxy;
        m_GameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;

        Leyoutech.Utility.DebugUtility.LogWarning("Buff", string.Format("创建一个Buff ---> 归属entity = {0} , Buff ID = {1}", BuffProperty.EntityId(), VO.ID));

        SkillBuff configVO = m_SkillProxy.GetBuff((int)VO.ID);

        if (configVO.ByteBuffer != null)
        {
            BuffEffect = BuffEffectBase.GetBuffEffectByType((BuffEffectType)configVO.BuffEffectId, this);
            Transform        selfTf      = BuffProperty.GetRootTransform();
            SpacecraftEntity otherEntity = m_GameplayProxy.GetEntityById <SpacecraftEntity>(VO.Link_id) as SpacecraftEntity;
            Transform        otherTf     = null;
            if (otherEntity != null && !otherEntity.IsDead())
            {
                otherTf = otherEntity.GetRootTransform();
            }

            BuffEffect.Init(selfTf, otherTf);
        }
        else
        {
            BuffEffect = new BuffEffectBase(this);
        }
    }
예제 #8
0
    /// <summary>
    /// 同步HP、MP
    /// </summary>
    /// <param name="buf"></param>
    private void OnHeroHpMpAnger(KProtoBuf buf)
    {
        S2C_SYNC_HERO_HPMP_ANGER msg    = buf as S2C_SYNC_HERO_HPMP_ANGER;
        SpacecraftEntity         entity = m_GameplayProxy.GetEntityById <SpacecraftEntity>(msg.heroID);

        if (entity != null)
        {
            entity.SetAttribute(AttributeName.kHP, msg.hp);
            entity.SetAttribute(AttributeName.kShieldValue, msg.shield_value);
            entity.SetAttribute(AttributeName.kPowerValue, msg.energyPower);
            //新屬性目前沒有
            //entity.SetAttribute(AttributeName.DefenseShield, msg.defense_shield_value);
            //entity.SetAttribute(AttributeName.ManaShield, msg.mana_shield_value);
            //entity.SetAttribute(AttributeName.SuperMagnetic, msg.superMagnetic);

            double oldPeerless = entity.GetAttribute(AttributeName.kConverterValue);             /// entity.GetPeerless();
            /// entity.SetPeerless((uint)msg.current_peerless);
            entity.SetAttribute(AttributeName.kConverterValue, msg.current_peerless);

            if (entity.IsMain() && oldPeerless != entity.GetAttribute(AttributeName.kConverterMax) &&
                entity.GetAttribute(AttributeName.kConverterValue) == entity.GetAttribute(AttributeName.kConverterMax))
            {
                entity.SendEvent(ComponentEventName.MaxPeerlessReached, null);
            }
        }
    }
예제 #9
0
    public bool CanAttackToTarget(SpacecraftEntity attacker, SpacecraftEntity target)
    {
        if (attacker == null || target == null)
        {
            return(false);
        }

        //优先判断是否可被攻击
        if (!target.GetCanBeAttack())
        {
            return(false);
        }

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

        //直接调用获取阵营关系的函数,岂不简单些?
        CampRelation relation = cfgEternityProxy.GetRelation(attacker.GetCampID(), target.GetCampID());

        return(relation == CampRelation.Enemy);

        //int attCamp = attacker.GetCampID();
        //int tarCamp = target.GetCampID();
        //CampVO_MergeObject? campVO = cfgCampProxy.GetCampRelationVO(attCamp, tarCamp);
        //if (campVO == null)
        //{
        //	Debug.LogErrorFormat("阵营信息不存在. Camp1: {0}, Camp2: {1}", attCamp, tarCamp);
        //	return false;
        //}
        //else
        //{
        //	int prestage = attacker.GetPrestige(tarCamp);
        //	// 通过声望值判断是否可攻击
        //	return prestage > campVO.Value.PrestigeEnemyMin && prestage < campVO.Value.PrestigeEnemyMax;
        //}
    }
예제 #10
0
    /// <summary>
    /// 根据死亡延时创建宝箱
    /// </summary>
    public void CreateDropItemByDeath(ulong key, SpacecraftEntity spe)
    {
        Debug.Log("CreateDropItemByDeath key:" + key + " SpacecraftEntity:" + spe);
        m_SpacecraftEntityDic.Add(key, spe);

        Npc npcVO = spe.GetNPCTemplateVO();
        CfgEternityProxy cfgEternityProxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;
        Model            model            = cfgEternityProxy.GetModel(npcVO.Model);
        int ruinTime = model.RuinTime;

        if (ruinTime > 0)
        {
            UIManager.Instance.StartCoroutine(DelayToCreateDropItemByDeath(key, spe, ruinTime / 1000.0f));
        }
        else
        {
            CreateDropItem((uint)key, spe, 2);
        }
        /// TODO.宝藏特殊处理
        /// 服务器创建后立马死亡,没有死亡特效
        ///if (spe.GetHeroType() == KHeroType.htPreicous)
        ///{
        ///	CreateDropItem((uint)key, spe, 2);
        ///}
        ///else
        ///{
        ///	UIManager.Instance.StartCoroutine(DelayToCreateDropItemByDeath(key, spe));
        ///}
        ///CreateDropItem((uint)key, spe, 2);
    }
예제 #11
0
    /// <summary>
    /// 使用传入射线与当前Avatar的所有Collider做碰撞检测
    /// 返回第一个碰撞点, 也就是最外层的碰撞点
    /// </summary>
    public bool GetHitPoint(SpacecraftEntity spacecraft, Ray ray, out Collider hitCollider, out Vector3 hitPoint)
    {
        hitCollider = null;

        // 这里使用Motion.HorizontAxix 的位置而不是transoform.position是因为HeroEntity.transform.position是服务器的位置, 是跳动的
        // Motion.HorizontAxis的位置才是客户端插值后的位置
        float rayDistance = RAYCAST_LENGTH;

        bool hit = false;

        hitPoint = spacecraft.transform.position;
        float nearestHitDistance = float.MaxValue;

        foreach (Collider collider in spacecraft.GetAllColliders())
        {
            RaycastHit hitInfo;
            if (collider.Raycast(ray, out hitInfo, rayDistance))
            {
                // 用射线与所有Collider求交, 找到距射线发射位置最近的碰撞点
                // TODO 祝锐: 缓存一个最外层的最大的Collider, 不要每次遍历所有的Collider
                float sqrHitPointToOrigin = (hitInfo.point - ray.origin).sqrMagnitude;
                if (sqrHitPointToOrigin < nearestHitDistance)
                {
                    nearestHitDistance = sqrHitPointToOrigin;
                    hitPoint           = hitInfo.point;
                    hitCollider        = collider;
                    hit = true;
                }
            }
        }

        return(hit);
    }
예제 #12
0
    protected override void Update()
    {
        GameplayProxy    gameplayProxy = Facade.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;
        SpacecraftEntity entity        = gameplayProxy.GetEntityById <SpacecraftEntity>((uint)m_AIUid);

        if (entity == null || entity.transform == null)
        {
            UIManager.Instance.ClosePanel(this);
            return;
        }

        bool isInScreen = IsInScreen(entity.transform.position, Camera.main);

        //忽略屏幕外的
        if (isInScreen)
        {
            //屏幕内显示图标
            Vector3 screenPoint = Camera.main.WorldToScreenPoint(entity.transform.position);
            Vector2 localPoint  = Vector2.zero;
            if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_Root, screenPoint, m_Camera, out localPoint))
            {
                m_Icon.gameObject.SetActive(true);
                m_Icon.anchoredPosition = localPoint;
                //m_Animation.anchoredPosition = localPoint;
                //m_Icon.localScale = Vector3.one;
                //m_Animation.localScale = Vector3.one;
            }
        }
        else
        {
            m_Icon.gameObject.SetActive(false);
        }
    }
예제 #13
0
    /// <summary>
    /// 初始化
    /// </summary>
    public virtual void Init()
    {
        m_MainPlayer = m_GameplayProxy.GetMainPlayer();
        SkillData skillData = m_CfgEternityProxy.GetSkillData((int)m_SkillID);

        m_SkillMaxDistance = skillData.BaseData.Value.MaxDistance;//* SceneController.SPACE_ACCURACY_TO_CLIENT;
    }
    /// <summary>
    /// 清理正在锁定但是已经不在瞄准框中的目标
    /// </summary>
    private void ClearLockingTargetWhichIsNotInLockingRect()
    {
        List <SpacecraftEntity> targetList = new List <SpacecraftEntity>();
        bool targetSelected = GetAllEntitySelectedByVirtualCamera(ref targetList);

        List <SpacecraftEntity> cancelLockList = new List <SpacecraftEntity>();

        foreach (var pair in m_LockTargeMap)
        {
            SpacecraftEntity lockTarget = pair.Key;
            TargetLockInfo   lockInfo   = pair.Value;
            // 正在锁定的目标如果已经不在框中, 就取消锁定
            if (lockInfo.LockState == TargetLockState.Locking && !targetList.Contains(lockTarget))
            {
                cancelLockList.Add(lockTarget);
            }
        }

        for (int iEntity = 0; iEntity < cancelLockList.Count; iEntity++)
        {
            SpacecraftEntity entity = cancelLockList[iEntity];
            if (m_LockTargeMap[entity].LockTimes == 0)
            {
                m_LockTargeMap.Remove(entity);
            }
            else
            {
                m_LockTargeMap[entity].LockState         = TargetLockState.Locked;
                m_LockTargeMap[entity].LockTimeRemaining = 0;
            }
            SLog("目标在锁定完成前出框了, 失去锁定. {0}", iEntity);
        }
    }
예제 #15
0
    public override void OnInitialize(IChangeMaterialProperty property)
    {
        m_Property = property;
        Npc npcVO = m_Property.GetNPCTemplateVO();

        /// npcVO.TriggerRange
        m_CfgEternityProxy  = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;
        m_TreasureHuntProxy = GameFacade.Instance.RetrieveProxy(ProxyName.TreasureHuntProxy) as TreasureHuntProxy;
        m_GameplayProxy     = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;
        m_MainEntity        = m_GameplayProxy.GetMainPlayer();

        GamingConfigTreasure      gamingConfigTreasure = m_CfgEternityProxy.GetGamingConfig(1).Value.Treasure.Value;
        GamingConfigTreasureColor colour = gamingConfigTreasure.Colour.Value;

        m_Colors[DistanceType.discovery] = colour.DiscoveryDistance;
        m_Colors[DistanceType.strong]    = colour.StrongSignalDistance;
        m_Colors[DistanceType.medium]    = colour.MediumSignalDistance;
        m_Colors[DistanceType.weak]      = colour.WeakSignalDistance;

        GamingConfigTreasureFrequency frequency = gamingConfigTreasure.Frequency.Value;

        m_Frequencys[DistanceType.discovery] = frequency.DiscoveryDistance;
        m_Frequencys[DistanceType.strong]    = frequency.StrongSignalDistance;
        m_Frequencys[DistanceType.medium]    = frequency.MediumSignalDistance;
        m_Frequencys[DistanceType.weak]      = frequency.WeakSignalDistance;

        GamingConfigTreasureSound sound = gamingConfigTreasure.Sound.Value;

        m_Sounds[DistanceType.none]   = (int)sound.NoSignalDetector;
        m_Sounds[DistanceType.strong] = (int)sound.StrongSignalDetector;
        m_Sounds[DistanceType.medium] = (int)sound.MediumSignalDetector;
        m_Sounds[DistanceType.weak]   = (int)sound.WeakSignalDetector;
    }
예제 #16
0
    /// <summary>
    /// 响应服务器消息释放技能
    /// 如果目前存在指定ID的技能实例, 则停止原来的技能, 释放新的技能.  (完全相信服务器)
    /// </summary>
    /// <param name="skillID"></param>
    private void ReleaseSkillByServerMessage(int skillID, uint targetID, Vector3 offset, int launcherIndex, bool ignorePrediction = false)
    {
        if (IsReleasingSkill(skillID))
        {
            StopSkill(skillID, false);
        }

        if (IsPredict(skillID))
        {
            return;
        }

        SkillBase newSkill = CreateSkill(skillID);

        if (newSkill != null)
        {
            if (m_RemoveSkillList.Contains(skillID))
            {
                m_RemoveSkillList.Remove(skillID);
            }

            m_IDToSkill[skillID] = newSkill;
            m_Property.SetCurrentSkillID(skillID);
        }

        SpacecraftEntity target = m_GameplayProxy.GetEntityById <SpacecraftEntity>(targetID) as SpacecraftEntity;

        m_State = newSkill.ReleaseSkillByServerMessage(targetID, offset, launcherIndex, ignorePrediction);
        m_Property.SetCurrentSkillState(m_State);
    }
예제 #17
0
    /// <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));
    }
예제 #18
0
    /// <summary>
    /// 创建音乐盒子
    /// </summary>
    /// <param name="aiUid"></param>
    private void CreateSoundBox(ulong aiUid)
    {
        if (aiUid <= 0 || m_AISoundBoxs.ContainsKey(aiUid))
        {
            /// TODO.
            /// or play sound box begin music
            Debug.LogError("aiUid is 0 or Plot repeated trigger the Invaded2");
            return;
        }

        SpacecraftEntity AI = m_GameplayProxy.GetEntityById <SpacecraftEntity>((uint)aiUid);

        if (AI)
        {
            Npc npc = AI.GetNPCTemplateVO();
            if (npc.Behavior > 0)
            {
                PlotBehavior plotBehavior = m_CfgEternityProxy.PlotBehaviorsByKey((uint)npc.Behavior);
                if (plotBehavior.FightBeginSound > 0)
                {
                    GameObject soundBox = WwiseManager.CreatTAkAmbientSphereBox((int)plotBehavior.FightBeginSound, (int)plotBehavior.FightEndSound);
                    soundBox.transform.position = AI.GetRootTransform().position;
                    float scale = plotBehavior.SoundBoxSize;
                    soundBox.transform.localScale = new Vector3(scale, scale, scale);
                    m_AISoundBoxs.Add(aiUid, soundBox);
                }
            }
        }
    }
예제 #19
0
    /// <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);
        }
    }
예제 #20
0
    /// <summary>
    /// 获取当前武器武器准星对象
    /// </summary>
    /// <returns></returns>
    public WeaponAndCrossSight GetCurrentWeaponAndCrossSight()
    {
        SpacecraftEntity mainPlayer = m_GameplayProxy.GetEntityById <SpacecraftEntity>(m_GameplayProxy.GetMainPlayerUID());

        if (mainPlayer == null)
        {
            return(null);
        }

        WeaponAndCrossSight result = null;

        if (UsingReformer())
        {
            //转化炉武器
            IReformer reformer = GetReformer();
            if (reformer != null && mainPlayer.HaveWeaponAndCrossSight(reformer.GetUID()))
            {
                result = mainPlayer.GetWeaponAndCrossSight(reformer.GetUID());
            }
        }
        else
        {
            //普通武器
            IWeapon weapon = GetCurrentWeapon();
            if (weapon != null && mainPlayer.HaveWeaponAndCrossSight(weapon.GetUID()))
            {
                result = mainPlayer.GetWeaponAndCrossSight(weapon.GetUID());
            }
        }

        return(result);
    }
예제 #21
0
    /// <summary>
    /// 更新准星的位置
    /// </summary>
    protected override void Update()
    {
        RaycastTarget_OLD();

        m_Root.gameObject.SetActive(!IsWatchOrUIInputMode() && !IsDead() && !IsLeaping());

        if (m_Crosshair == null)
            return;

        if (m_WeaponStyle == WeaponAndCrossSight.WeaponAndCrossSightTypes.Null)
		{
			if (m_CurrentTarget != null)
			{
				GameplayProxy sceneProxy = Facade.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;
				SpacecraftEntity main = sceneProxy.GetEntityById<SpacecraftEntity>(sceneProxy.GetMainPlayerUID());

				m_CurrentTarget = null;
				m_RaycastProxy.SetCurrentTarget(null);
				main.SetTarget(null, null);
			}
			return;
		}

        UpdateCrossHairPosition();
        UpdateWeaponBullets();
        UpdateWeaponCrosshairOffset();
        UpdateTargetList();
        UpdateShotPoint();

		//RaycastTarget_OLD();
    }
예제 #22
0
        /// <summary>
        /// 弹夹信息,只有主角才有
        /// </summary>
        /// <param name="result"></param>
        private static void DisposeSyncClipInfo(SyncClipInfo result)
        {
            //Leyoutech.Utility.DebugUtility.LogWarning("广播", string.Format("弹夹信息, 武器ID = {0}", result.CurWeaponUid));
            GameplayProxy    m_GameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;
            SpacecraftEntity entity          = m_GameplayProxy.GetEntityById <SpacecraftEntity>(m_GameplayProxy.GetMainPlayerUID());

            if (entity == null)
            {
                return;
            }

            PlayerSkillProxy m_PlayerSkillProxy = GameFacade.Instance.RetrieveProxy(ProxyName.PlayerSkillProxy) as PlayerSkillProxy;

            m_PlayerSkillProxy.ChangeCurrentWeaponByServer(result.CurWeaponUid);

            foreach (WeaponValue info in result.Infos)
            {
                ulong weaponUID = info.WeaponUid;

                WeaponPowerVO power = entity.GetWeaponPower(weaponUID);
                if (power == null)
                {
                    entity.SetWeaponPower(weaponUID, new WeaponPowerVO());
                    power = entity.GetWeaponPower(weaponUID);
                }

                power.WeaponUID    = info.WeaponUid;
                power.CurrentValue = info.CurValue;
                power.MaxValue     = info.MaxValue;
                power.SafeValue    = info.SaftyValue;

                IWeapon weapon = m_PlayerSkillProxy.GetWeaponByUID(power.WeaponUID);
                if (weapon != null && weapon.GetConfig().ClipType != (int)WeaponL1.Treasure)
                {
                    if (power.CurrentValue <= 0)
                    {
                        power.ForceCooldown = true;
                    }
                    else if (power.CurrentValue >= power.SafeValue)
                    {
                        power.ForceCooldown = false;
                    }
                }
                else
                {
                    if (power.CurrentValue >= power.MaxValue)
                    {
                        power.ForceCooldown = true;
                    }
                    else if (power.CurrentValue <= power.SafeValue)
                    {
                        power.ForceCooldown = false;
                    }
                }
            }

            GameFacade.Instance.SendNotification(NotificationName.MSG_CHARACTER_WEAPON_POWER_CHANGED);
            entity.SendEvent(ComponentEventName.WeaponPowerChanged, null);
        }
예제 #23
0
    /// <summary>
    /// 根据刚体速度更新惯性
    /// </summary>
    /// <param name="rect">要微调的UI</param>
    /// <param name="inertia">惯性设置</param>
    private void UpdateInertanceByVelocity(RectTransform rect, InertiaWithHud inertia)
    {
        SpacecraftEntity main = GetMainEntity();

        if (main == null)
        {
            return;
        }

        Transform mainShadow = main.GetSyncTarget();

        if (mainShadow == null)
        {
            return;
        }

        Rigidbody rigidbody = mainShadow.GetComponent <Rigidbody>();

        if (rigidbody == null)
        {
            return;
        }

        SpacecraftMotionComponent mainMotion = main.GetEntityComponent <SpacecraftMotionComponent>();

        if (mainMotion == null)
        {
            return;
        }

        SpacecraftMotionInfo cruiseMotion = mainMotion.GetCruiseModeMotionInfo();

        Vector3 velocity = rigidbody.transform.InverseTransformDirection(rigidbody.velocity);

        float forwardSpeed        = velocity.z;
        float forwardSpeedMax     = cruiseMotion.LineVelocityMax.z;
        float forwardSpeedPercent = Mathf.Clamp01(Mathf.Abs(forwardSpeed) / Mathf.Abs(forwardSpeedMax));

        float upSpeed        = velocity.y;
        float upSpeedMax     = cruiseMotion.LineVelocityMax.y;
        float upSpeedPercent = Mathf.Clamp01(Mathf.Abs(upSpeed) / Mathf.Abs(upSpeedMax));

        float rotationSpeed        = rigidbody.angularVelocity.y * Mathf.Rad2Deg;
        float rotationSpeedMax     = cruiseMotion.AngularVelocityMax.y;
        float rotationSpeedPercent = Mathf.Clamp01(Mathf.Abs(rotationSpeed) / Mathf.Abs(rotationSpeedMax));

        float forwardDir = Vector3.Dot(rigidbody.velocity.normalized, Camera.main.transform.forward);

        float x = rotationSpeedPercent * inertia.OffsetX * (rotationSpeed > 0 ? 1 : -1);
        float y = upSpeedPercent * inertia.OffsetY * (upSpeed > 0 ? 1 : -1);
        float z = forwardSpeedPercent * inertia.OffsetZ * forwardDir;

        //Debug.LogError("----> " +
        //    string.Format("{0:N2}", forwardSpeed) + "/" + forwardSpeedMax + "          " +
        //    string.Format("{0:N2}", upSpeed) + "/" + upSpeedMax + "           " +
        //    string.Format("{0:N2}", rotationSpeed) + "/" + rotationSpeedMax);

        rect.anchoredPosition3D = new Vector3(x, y, z);
    }
예제 #24
0
 /// <summary>
 /// 获取主角
 /// </summary>
 /// <returns></returns>
 public SpacecraftEntity GetMainSpacecraftEntity()
 {
     if (m_MainSpacecraftEntity == null)
     {
         m_MainSpacecraftEntity = GetGameplayProxy().GetEntityById <SpacecraftEntity>(GetGameplayProxy().GetMainPlayerUID());
     }
     return(m_MainSpacecraftEntity);
 }
예제 #25
0
    /// <summary>
    /// 延时创建宝箱 延时的时间为怪物死亡播放的所有特效和动作时间的总和
    /// </summary>
    private IEnumerator DelayToCreateDropItemByDeath(ulong key, SpacecraftEntity spe, float delayTime)
    {
        /// 特效(蒋小京需求)宝箱出现延迟3秒
        yield return(new WaitForSeconds(delayTime));

        //Debug.LogErrorFormat("CreateDropItem  {0}  ", key);
        CreateDropItem((uint)key, spe, 2);
    }
예제 #26
0
    public virtual void NotifyHUDTargetSelected(SpacecraftEntity targetSelected)
    {
        WeaponSelectedTargetInfo targetInfoNotify = MessageSingleton.Get <WeaponSelectedTargetInfo>();

        // FIXME. 动态内存分配
        targetInfoNotify.selectedTarget = targetSelected;
        GameFacade.Instance.SendNotification(NotificationName.PlayerWeaponSelectedTarget, targetInfoNotify);
    }
예제 #27
0
    public WeaponPowerVO GetCurrentWeaponPowerOfMainPlayer()
    {
        GameplayProxy    gameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;
        SpacecraftEntity mainEntity    = gameplayProxy.GetEntityById <SpacecraftEntity>(gameplayProxy.GetMainPlayerUID());
        IWeapon          curWeapon     = GetCurrentWeapon();

        return(curWeapon != null?mainEntity.GetWeaponPower(curWeapon.GetUID()) : null);
    }
    private bool GetAllEntitySelectedByVirtualCamera(ref List <SpacecraftEntity> targetList)
    {
        MainCameraComponent mainCam = CameraManager.GetInstance().GetMainCamereComponent();

        SkillSystemGrow skillGrow = m_PlayerSkillProxy.GetCurrentWeaponSkill().GetSkillGrow();
        float           range     = skillGrow.Range * SceneController.SPACE_ACCURACY_TO_CLIENT;

        // 粗略的拾取.
        // 拾取锥体视为一个相机, 把技能射程视为远裁剪面. 根据FOV取远裁剪面的大小, 投射这个大小的Box, 获取所有拾取到的Entity
        {
            // 所有粗略裁剪的物体 = Physics.BoxCastAll(投射开始点, 盒子边长, 相机方向, SkillLayer)

            float halfBoxVerticalSideLength   = range * Mathf.Tan(m_ReticleHorizontalFOVParam / m_ReticleAspect * 0.5f * Mathf.Deg2Rad);
            float halfBoxHorizontalSideLength = halfBoxVerticalSideLength * m_ReticleAspect;

            // 投射开始的点 = 相机近裁剪面的中心点 + 相机方向 * 盒子边长的一半
            Vector3      startPoint = mainCam.transform.position + (mainCam.GetCamera().nearClipPlane + halfBoxVerticalSideLength) * mainCam.GetForward();
            RaycastHit[] hitInfos   = Physics.BoxCastAll(startPoint,
                                                         new Vector3(halfBoxHorizontalSideLength, halfBoxVerticalSideLength, halfBoxVerticalSideLength),
                                                         mainCam.GetForward(),
                                                         Quaternion.identity, range,
                                                         LayerUtil.GetLayersIntersectWithSkillProjectile(true));

            for (int iHit = 0; iHit < hitInfos.Length; iHit++)
            {
                Rigidbody rigidBody = hitInfos[iHit].rigidbody;
                if (rigidBody == null)
                {
                    continue;
                }

                SpacecraftEntity entity = rigidBody.GetComponent <SpacecraftEntity>();
                if (entity != null)
                {
                    targetList.Add(entity);
                }
            }
        }

        if (m_VirtualCameraForReticleSelection != null)
        {
            // 更新虚拟相机的方向和位置
            m_VirtualCameraForReticleSelection.transform.position = mainCam.transform.position;
            m_VirtualCameraForReticleSelection.transform.rotation = mainCam.transform.rotation;

            // 更精细的判断. 当前版本仅计算目标中心点是不是在 虚拟相机 里面
            for (int iTarget = 0; iTarget < targetList.Count; iTarget++)
            {
                Vector3 viewportPos = m_VirtualCameraForReticleSelection.WorldToViewportPoint(targetList[iTarget].transform.position);
                if (viewportPos.x < 0 || viewportPos.y < 0 || viewportPos.x > 1 || viewportPos.y > 1)
                {
                    targetList.RemoveAt(iTarget);
                    iTarget--;
                }
            }
        }
        return(targetList.Count > 0);
    }
예제 #29
0
    public void RemoveEntityFromEntityGroup(ulong ownerHeroID, SpacecraftEntity entity)
    {
        if (!m_EntityGroupTable.ContainsKey(ownerHeroID))
        {
            return;
        }

        m_EntityGroupTable[ownerHeroID].Remove(entity);
    }
예제 #30
0
    protected override void Update()
    {
        if (!m_Content)
        {
            return;
        }
        if (!m_Content.gameObject.activeSelf)
        {
            return;
        }

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

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

        if (main == null)
        {
            return;
        }

        Transform mainShadow = main.GetSyncTarget();

        if (mainShadow == null)
        {
            return;
        }

        Rigidbody rigidbody = mainShadow.GetComponent <Rigidbody>();

        if (rigidbody == null)
        {
            return;
        }

        SpacecraftMotionComponent mainMotion = main.GetEntityComponent <SpacecraftMotionComponent>();

        if (mainMotion == null)
        {
            return;
        }

        SpacecraftMotionInfo cruiseMotion = mainMotion.GetCruiseModeMotionInfo();

        Vector3 velocity = rigidbody.transform.InverseTransformDirection(rigidbody.velocity);

        float upSpeed        = velocity.y;
        float upSpeedMax     = cruiseMotion.LineVelocityMax.y;
        float upSpeedPercent = Mathf.Clamp01(Mathf.Abs(upSpeed) / Mathf.Abs(upSpeedMax));

        float dir = upSpeedPercent * (upSpeed > 0 ? 1 : -1);

        m_Content.SetBool("Opened", upSpeed != 0);
        m_AltitudeRule.FillAmount  = 0.5f - upSpeedPercent * dir * 0.5f;
        m_AltitudeArrow.FillAmount = 0.5f + upSpeedPercent * dir * 0.5f;

        //Debug.LogError(string.Format("{0:N2}/{1:N2} = {2:N3}", upSpeed, upSpeedMax, upSpeedPercent));
    }