Esempio n. 1
0
    /// <summary>
    /// 计算高度
    /// </summary>
    private void CalculateHeight()
    {
        if (m_MainEntity == null || m_MainEntity.GetRootTransform() == null)
        {
            return;
        }
        m_DifferenceTreasure = m_MainEntity.GetRootTransform().position.y - m_HeightTreasure;
        m_Scale        = m_DifferenceTreasure / (m_DifferenceMax * 0.5f);
        m_Scale        = Mathf.Sqrt(1 - m_Scale * m_Scale);
        m_Scale        = Mathf.Clamp01(m_Scale);
        m_RatioY       = m_DifferenceTreasure / m_DifferenceMax;
        m_OffsetY      = Mathf.Abs(m_RatioY * m_ImageRect.sizeDelta.y);
        m_Radius_Image = m_ImageRect.sizeDelta.y * 0.5f;
        float a = m_Radius_Image - Mathf.Sqrt(m_Radius_Image * m_Radius_Image - m_OffsetY * m_OffsetY);

        if (m_RatioY > 0)//高
        {
            m_HeightRect.localPosition   = new Vector3(m_InitialValueX + a, m_OffsetY, m_HeightRect.localPosition.z);
            m_CircularRect.localPosition = new Vector3(m_CircularRect.localPosition.x, m_OffsetY, m_CircularRect.localPosition.z);
        }
        else//低
        {
            m_HeightRect.localPosition   = new Vector3(m_InitialValueX + a, -m_OffsetY, m_HeightRect.localPosition.z);
            m_CircularRect.localPosition = new Vector3(m_CircularRect.localPosition.x, -m_OffsetY, m_CircularRect.localPosition.z);
        }
        m_CircularRect.localScale = m_Scale * Vector3.one;
    }
Esempio n. 2
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);
                }
            }
        }
    }
Esempio n. 3
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);
        }
    }
Esempio n. 4
0
    /// <summary>
    /// 根据这次射击的弹道方向, 计算命中的目标Entity和目标点
    /// </summary>
    /// <param name="camDirAffectedByRecoil"></param>
    /// <returns></returns>
    protected SkillTarget CalulateTargetDataByShootingDirection(Vector3 camDirAffectedByRecoil)
    {
        // 计算射线碰到的目标点, 并重新计算从Launcher到目标点的方向
        PlayerSkillVO   skillVO     = m_PlayerSkillProxy.GetCurrentWeaponSkill();
        SkillSystemGrow skillGrow   = skillVO.GetSkillGrow();
        float           maxDistance = skillGrow.Range * SceneController.SPACE_ACCURACY_TO_CLIENT;
        Ray             ray         = new Ray(CameraManager.GetInstance().GetMainCamereComponent().GetPosition(), camDirAffectedByRecoil);
        RaycastHit      hitInfo     = new RaycastHit();

        if (Physics.Raycast(ray, out hitInfo, maxDistance, LayerUtil.GetLayersIntersectWithSkillProjectile(true)))
        {
            return(new SkillTarget(hitInfo.collider.attachedRigidbody?.GetComponent <SpacecraftEntity>(), hitInfo.point));
        }
        else
        {
            Vector3 skillReleasingDir = (ray.GetPoint(maxDistance) - m_MainPlayer.GetRootTransform().position).normalized;
            return(new SkillTarget(null, m_MainPlayer.GetRootTransform().position + skillReleasingDir * maxDistance));
        }
    }
Esempio n. 5
0
    public override void OnLateUpdate()
    {
        if (m_StartType == DistanceType.none)
        {
            return;
        }

        /// 检测音效范围
        Npc   npcVO  = m_Property.GetNPCTemplateVO();
        float range  = npcVO.TriggerRange;
        float dis    = Vector3.Distance(m_MainEntity.GetRootTransform().position, m_Property.GetRootTransform().position);
        uint  curUID = m_TreasureHuntProxy.GetCurDetectorUID();
        uint  uid    = m_Property.GetUId();

        if (dis > range)
        {
            if (uid == curUID)
            {
                WwiseUtil.PlaySound(m_Sounds[DistanceType.none], false, m_TreasureHuntProxy.GetCurDetectorTransfrom());
                m_TreasureHuntProxy.SetCurDetectorSoundInfo(0, null);
            }
        }
        else
        {
            if (curUID == 0)
            {
                WwiseUtil.PlaySound(m_Sounds[m_StartType], false, m_Property.GetRootTransform());
                m_TreasureHuntProxy.SetCurDetectorSoundInfo(uid, m_Property.GetRootTransform());
            }
            else if (uid != curUID)
            {
                SpacecraftEntity entity = m_GameplayProxy.GetEntityById <SpacecraftEntity>(curUID);
                /// 距离当前正在播的距离
                float curDis = Vector3.Distance(m_MainEntity.GetRootTransform().position, entity.GetRootTransform().position);
                if (dis < curDis)
                {
                    WwiseUtil.PlaySound(m_Sounds[DistanceType.none], false, m_TreasureHuntProxy.GetCurDetectorTransfrom());
                    WwiseUtil.PlaySound(m_Sounds[m_StartType], false, m_Property.GetRootTransform());
                    m_TreasureHuntProxy.SetCurDetectorSoundInfo(uid, m_Property.GetRootTransform());
                }
            }
        }
    }
Esempio n. 6
0
    /// <summary>
    /// 目标是否在射程内 (考虑目标体积, 粗略检查)
    /// </summary>
    /// <param name="caster"></param>
    /// <param name="target"></param>
    /// <param name="range"></param>
    /// <returns></returns>
    public static bool TargetIsInRange_SimpleCheck(SpacecraftEntity caster, SpacecraftEntity target, float range)
    {
        float distanceToTarget = Vector3.Distance(caster.GetRootTransform().position, target.GetRootTransform().position);
        float validRange       = range;

        if (target.GetPresentation().GetCapsuleCollider() != null)
        {
            // 粗略计算, 使用目标胶囊体长度的一半加技能射程作为这次判断的有效距离
            // 假设只有一个胶囊体, 也不该有多个
            CapsuleCollider targetCapsule = target.GetPresentation().GetCapsuleCollider();
            validRange += targetCapsule.height / 2;
        }

        return(distanceToTarget < validRange);
    }
Esempio n. 7
0
 private void LateUpdate()
 {
     if (m_SpacecraftEntity && m_DropItemState == DropItemState.Stay)
     {
         Vector3 playerPos  = m_SpacecraftEntity.GetRootTransform().position;
         Vector3 currentPos = gameObject.transform.position;
         float   square     = GetInteractableDistanceSquare();
         float   dis        = (playerPos - currentPos).sqrMagnitude;
         if (dis <= square)
         {
             /// 拾取
             m_DropItemState = DropItemState.Gather;
             MineDropItemManager.Instance.AutoPickUp(m_UID);
         }
     }
 }
Esempio n. 8
0
    private void OnSkillEffect(IComponentEvent componentEvent)
    {
        S2C_SKILL_EFFECT_Event respond = componentEvent as S2C_SKILL_EFFECT_Event;

        SpacecraftEntity caster  = m_GameplayProxy.GetEntityById <SpacecraftEntity>(respond.msg.wCasterID) as SpacecraftEntity;
        SpacecraftEntity target  = m_GameplayProxy.GetEntityById <SpacecraftEntity>(respond.msg.wTargetHeroID) as SpacecraftEntity;
        Camera           mainCam = CameraManager.GetInstance().GetMainCamereComponent()?.GetCamera();

        if (caster != null && target != null && target.IsMain() && mainCam != null)
        {
            Vector3 targetToAttacker          = caster.GetRootTransform().position - target.GetRootTransform().position;
            AttackWarningDirection warningDir = GetAttackDirection(targetToAttacker);

            Debug.LogFormat("HitWarning | SKillEffect. {0}", warningDir);

            EffectController hitWarningFX = EffectManager.GetInstance().CreateEffect(m_WarningMap[warningDir], EffectManager.GetEffectGroupNameInSpace(true));
            hitWarningFX.transform.SetParent(m_Property.GetSkinRootTransform(), false);
        }
    }
    private void CreateDropItem(string key, MineDropItemInfo mineDropItemInfo, bool needFly = false)
    {
        NpcCombat?nc = m_CfgEternityProxy.GetNpcCombatByKey(mineDropItemInfo.tid);

        if (!nc.HasValue)
        {
            return;
        }

        PackageBoxAttr?pb = m_CfgEternityProxy.GetPackageBoxAttrByModelIdAndGrade((uint)nc.Value.BoxModel, mineDropItemInfo.ship_tlv);

        if (!pb.HasValue)
        {
            return;
        }

        int   modelid = pb.Value.BoxModel;
        Model?mdata   = m_CfgEternityProxy.GetModel(modelid);

        if (mdata.Value.AssetName.Equals(string.Empty))
        {
            return;
        }

        Vector3          curPos = Vector3.zero;
        SpacecraftEntity spe    = m_GameplayProxy.GetEntityById <SpacecraftEntity>((uint)mineDropItemInfo.parentid) as SpacecraftEntity;

        if (spe)
        {
            curPos = spe.GetRootTransform().position;
        }

        AssetUtil.InstanceAssetAsync(mdata.Value.AssetName, (address, uObj, userData) =>
        {
            mineDropItemInfo.obj = uObj as GameObject;
            MineDropComponent mineDropComponent = mineDropItemInfo.obj.GetComponent <MineDropComponent>();
            if (!mineDropComponent)
            {
                mineDropComponent = mineDropItemInfo.obj.AddComponent <MineDropComponent>();
            }

            SpacecraftEntity mainPlayer = m_GameplayProxy.GetMainPlayer();
            mineDropComponent.Initialize(mainPlayer, mineDropItemInfo.uid, mineDropItemInfo.tid, mineDropItemInfo.item_tid, pb);
            if (needFly)
            {
                mineDropItemInfo.obj.transform.position = curPos;
                mineDropComponent.AddFlyEffect(mineDropItemInfo.positon_x, mineDropItemInfo.positon_y, mineDropItemInfo.positon_z);
            }
            else
            {
                Vector3 endPos         = new Vector3(mineDropItemInfo.positon_x, mineDropItemInfo.positon_y, mineDropItemInfo.positon_z);
                Vector3 clientPosition = m_GameplayProxy.ServerAreaOffsetToClientPosition(endPos);
                mineDropItemInfo.obj.transform.position = clientPosition;
                mineDropComponent.SetDropItemState(DropItemState.Stay);
                mineDropComponent.AddEffect(true);
            }

            /// 跃迁客户端不清数据
            if (m_GatherDropItemInfos.ContainsKey(key))
            {
                m_GatherDropItemInfos.Remove(key);
            }
            m_GatherDropItemInfos.Add(key, mineDropItemInfo);
        });
    }
Esempio n. 10
0
    /// <summary>
    /// 添加出生或刷新特效
    /// </summary>
    /// <param name="key">宝箱唯一id</param>
    /// <param name="type">1为刷新特效, 2为拾取特效 3为拾取到主角身上的特效</param>
    private void AddBrothOrPickEffect(ulong key, int type)
    {
        if (!m_ChestGosDic.ContainsKey(key) || m_ChestGosDic[key] == null)
        {
            return;
        }

        if (m_BrothEffectGosDic.ContainsKey(key) && type == 1)
        {
            return;
        }

        if (m_PickupEffectGosDic.ContainsKey(key) && type == 2)
        {
            return;
        }

        if (m_PickupNextEffectGosDic.ContainsKey(key) && type == 3)
        {
            return;
        }

        GameObject dropItem = null;         // m_ChestGosDic[key]这样不行吗???

        if (!m_ChestGosDic.TryGetValue(key, out dropItem))
        {
            return;
        }

        CfgEternityProxy cfgEternityProxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;
        PackageBoxAttr?  pb = cfgEternityProxy.GetPackageBoxAttrByModelIdAndGrade(m_ChestInfoDic[key].tid, m_ChestInfoDic[key].shipgrade);

        if (pb == null)
        {
            return;
        }

        if (m_MainPlayerTransform == null)
        {
            GameplayProxy    gameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;
            SpacecraftEntity mainPlayer    = gameplayProxy.GetMainPlayer();
            m_MainPlayerTransform = (mainPlayer != null) ? mainPlayer.GetRootTransform() : null;
        }

        GameObject pgo = null;

        if (!m_ChestGosDic.TryGetValue(key, out pgo))
        {
            return;
        }

        string    effName = string.Empty;
        Transform parent  = null;

        if (type == 1)
        {
            //effName = pb.Value.RefreshGfx;
            //parent = dropItem.transform;
            if (!string.IsNullOrEmpty(pb.Value.RefreshGfx))
            {
                EffectController fxInstance = EffectManager.GetInstance().CreateEffect(pb.Value.RefreshGfx, EffectManager.GetEffectGroupNameInSpace(false),
                                                                                       (EffectController effect, System.Object usedata) =>
                {
                    /// m_BrothEffectGosDic[key] = effect.gameObject;
                    ///if (!string.IsNullOrEmpty(pb.Value.ContinuousGfx))
                    ///{
                    ///	EffectController gfxInstance = EffectManager.GetInstance().CreateEffect(pb.Value.ContinuousGfx, EffectManager.GetEffectGroupNameInSpace(false));
                    ///	gfxInstance.transform.SetParent(dropItem.transform, false);
                    ///	gfxInstance.SetCreateForMainPlayer(false);
                    ///}
                });
                fxInstance.transform.SetParent(dropItem.transform, false);
                fxInstance.SetCreateForMainPlayer(false);
                UIManager.Instance.StartCoroutine(DelayToAddEffect(key));
            }
            return;
        }
        else if (type == 2)
        {
            /// effName = pb.Value.PickUpGfx;
            effName = "Effect_skill_nengliang_path";
        }
        else if (type == 3)
        {
            /// effName = pb.Value.PickUpHfx;
            effName = "Effect_skill_nengliang_hit";
            parent  = m_MainPlayerTransform;
        }

        if (string.IsNullOrEmpty(effName))
        {
            return;
        }

        AssetUtil.InstanceAssetAsync(effName,
                                     (pathOrAddress, returnObject, userData) =>
        {
            if (returnObject != null)
            {
                GameObject go = (GameObject)returnObject;
                go.transform.SetParent(parent, false);

                if (dropItem != null)
                {
                    /// 飞
                    if (type == 2)
                    {
                        pgo.SetActive(false);
                        m_PickupEffectGosDic[key] = go;
                        go.transform.position     = pgo.transform.position;

                        float t         = Time.time;
                        m_TweenDic[key] = go.transform.DOMove(m_MainPlayerTransform.position, 1.0f).OnComplete(
                            () =>
                        {
                            go.SetActive(false);
                            m_TweenDic.Remove(key);
                            pgo.transform.position = go.transform.position;
                            AddBrothOrPickEffect(key, 3);
                        }
                            ).OnUpdate(
                            () =>
                        {
                            float a = m_TweenDic[key].Duration() - (Time.time - t);
                            t       = Time.time;
                            if (a > 0)
                            {
                                m_TweenDic[key].ChangeEndValue(m_MainPlayerTransform.position, a, true);
                            }
                        }
                            ).SetAutoKill(true);

                        m_NeedAddUpdate += 1;
                        //UIManager.Instance.StartCoroutine(DelayToDestory(key));
                        //if (m_SpacecraftEntityDic[key])
                        //{
                        //	m_SpacecraftEntityDic[key].SetFocus(false);
                        //	Interaction.InteractionManager.GetInstance().UnregisterInteractable(m_SpacecraftEntityDic[key]);
                        //}
                    }
                    else if (type == 3)
                    {
                        pgo.SetActive(false);
                        m_PickupNextEffectGosDic[key] = go;
                        //go.transform.position = m_MainPlayerTransform.position;
                        m_NeedAddUpdate -= 1;
                        UIManager.Instance.StartCoroutine(DelayToDestory(key));
                    }


                    /// 不飞
                    /// if (type == 2)
                    /// {
                    ///     m_PickupEffectGosDic[key] = go;
                    ///     go.transform.position = dropItem.transform.position;
                    ///     if (m_BrothEffectGosDic.ContainsKey(key))
                    ///     {
                    ///         GameObject.DestroyImmediate(m_BrothEffectGosDic[key]);
                    ///         m_BrothEffectGosDic.Remove(key);
                    ///     }
                    ///     dropItem.SetActive(false);
                    ///     ParticleSystem p = go.GetComponentInChildren<ParticleSystem>();
                    ///     float duration = 1.0f;
                    ///     if (p != null)
                    ///     {
                    ///         duration = p.main.duration;
                    ///     }
                    ///     UIManager.Instance.StartCoroutine(DelayToPickNext(key, duration));
                    ///
                    ///     /// 果果牛掰的移除缓存的逻辑,不敢动
                    ///     UIManager.Instance.StartCoroutine(DelayToDestory(key));
                    /// }
                }
                else
                {
                    GameObject.DestroyImmediate(go);
                }
            }
            else
            {
                Debug.LogError(string.Format("资源加载成功,但返回null,  pathOrAddress = {0}", pathOrAddress));
            }
        });
    }
Esempio n. 11
0
    /// <summary>
    /// 创建掉落物
    /// </summary>
    /// <param name="uid">怪物唯一id</param>
    /// <param name="pos">怪物位置</param>
    /// <param name="type">1为new消息, 2为死亡消息</param>
    public void CreateDropItem(uint uid, SpacecraftEntity spe, int type)
    {
        ulong key = uid;

        if (!spe)
        {
            if (m_ChestInfoDic.ContainsKey(key))
            {
                m_ChestInfoDic.Remove(key);
            }
            if (m_SpacecraftEntityDic.ContainsKey(key))
            {
                Debug.Log("CreateDropItem !spe m_SpacecraftEntityDic remove key:" + key);
                m_SpacecraftEntityDic.Remove(key);
            }
            return;
        }
        if (type == 1 && !m_SpacecraftEntityDic.ContainsKey(key))
        {
            m_SpacecraftEntityDic.Add(key, spe);
        }
        if (!m_ChestInfoDic.ContainsKey(uid))
        {
            return;
        }

        if (m_ChestGosDic.ContainsKey(uid))
        {
            return;
        }

        CfgEternityProxy cfgEternityProxy = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;
        PackageBoxAttr?  pb = cfgEternityProxy.GetPackageBoxAttrByModelIdAndGrade(m_ChestInfoDic[uid].tid, m_ChestInfoDic[uid].shipgrade);

        if (!pb.HasValue)
        {
            return;
        }

        int   modelid = pb.Value.BoxModel;
        Model?mdata   = m_CfgEternityProxy.GetModel(modelid);

        if (string.IsNullOrEmpty(mdata.Value.AssetName))        /// (mdata.Value.AssetName.Equals(string.Empty))
        {
            Debug.LogErrorFormat("DropItem model assetName is empty  modelid {0}", modelid);
            return;
        }

        AssetUtil.InstanceAssetAsync(mdata.Value.AssetName,
                                     (pathOrAddress, returnObject, userData) =>
        {
            if (returnObject != null)
            {
                if (!spe)
                {
                    Debug.Log("InstanceAssetAsync CreateDropItem !spe m_SpacecraftEntityDic remove key:" + key);
                    GameObject.Destroy(returnObject);
                    m_SpacecraftEntityDic.Remove(key);
                    m_ChestInfoDic.Remove(key);
                    return;
                }
                GameObject go = (GameObject)returnObject;
                go.transform.SetParent(spe.GetRootTransform(), false);

                if (go.transform.parent == null)
                {
                    m_ChestGosDic.Remove(uid);
                    return;
                }

                //美术不去 这玩意没有加collide需求为啥不给去? 吐个槽 xswl
                BoxCollider box = go.GetComponentInChildren <BoxCollider>();
                if (box)
                {
                    box.enabled = false;
                }
                else
                {
                    Debug.LogWarning("找不到没必要的boxcollider 美术去了还是换了别的碰撞");
                }

                spe.GetSkinRootTransform().gameObject.SetActive(false);
                m_ChestGosDic.Add(key, go);
                AddBrothOrPickEffect(key, 1);
            }
            else
            {
                Debug.LogError(string.Format("资源加载成功,但返回null,  pathOrAddress = {0}", pathOrAddress));
            }
        });
    }