SetObjVisible() static private method

static private SetObjVisible ( EntityInfo obj, bool isShow ) : void
obj EntityInfo
isShow bool
return void
示例#1
0
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            if (senderObj.ConfigData.type == (int)SkillOrImpactType.Skill)
            {
                return(false);//track只能在impact或buff里使用
            }
            GameObject obj = senderObj.GfxObj;

            if (null != obj)
            {
                if (curSectionTime >= StartTime)
                {
                    if (!m_IsStarted)
                    {
                        m_IsStarted = true;
                        Vector3 dest;
                        string  trackBone = m_TrackBone.Get(instance);
                        m_BoneTransform = Utility.FindChildRecursive(obj.transform, trackBone);
                        if (null != m_BoneTransform)
                        {
                            dest = m_BoneTransform.position;
                        }
                        else
                        {
                            dest    = obj.transform.position;
                            dest.y += 1.5f;
                            LogSystem.Warn("[skill:{0} dsl skill id:{1}] track bone {2} can't find.", senderObj.SkillId, instance.DslSkillId, trackBone);
                        }
                        m_StartPos = EntityController.Instance.GetImpactSenderPosition(senderObj.ObjId, senderObj.SkillId, senderObj.Seq);
                        dest       = Utility.FrontOfTarget(m_StartPos, dest, 0.1f);
                        object speedObj;
                        if (instance.Variables.TryGetValue("emitSpeed", out speedObj))
                        {
                            m_Speed = (float)speedObj;
                        }
                        else
                        {
                            return(false);
                        }
                        float duration = m_Duration.Get(instance);
                        if (duration > Geometry.c_FloatPrecision)
                        {
                            float d = duration / 1000.0f;
                            m_Lifetime = d;
                            m_Speed    = (dest - m_StartPos).magnitude / m_Lifetime;
                        }
                        else
                        {
                            m_Lifetime = 1.0f;
                            if (m_Speed > Geometry.c_FloatPrecision)
                            {
                                m_Lifetime = (dest - m_StartPos).magnitude / m_Speed;
                            }
                        }
                        long newSectionDuration = StartTime + (long)(m_Lifetime * 1000);
                        if (instance.CurSectionDuration < newSectionDuration)
                        {
                            instance.SetCurSectionDuration(newSectionDuration);
                        }
                        Quaternion dir;
                        object     dirObj;
                        if (instance.Variables.TryGetValue("emitDir", out dirObj))
                        {
                            dir = (Quaternion)dirObj;
                        }
                        else
                        {
                            dir = Quaternion.identity;
                        }
                        Vector3 scale;
                        object  scaleObj;
                        if (instance.Variables.TryGetValue("emitScale", out scaleObj))
                        {
                            scale = (Vector3)scaleObj;
                        }
                        else
                        {
                            scale = Vector3.one;
                        }
                        Vector3    lookDir = dest - m_StartPos;
                        Quaternion q       = Quaternion.LookRotation(lookDir);
                        m_ControlPos = m_StartPos + Vector3.Scale(q * dir * Vector3.forward, scale * lookDir.magnitude * 0.5f);
                        string effectPath = SkillParamUtility.RefixResourceVariable("emitEffect", instance, senderObj.ConfigData.resources);
                        m_Effect = ResourceSystem.Instance.NewObject(effectPath, m_Lifetime) as GameObject;
                        if (null != m_Effect)
                        {
                            senderObj.TrackEffectObj = m_Effect;
                            TriggerUtil.SetObjVisible(m_Effect, true);
                            m_Effect.SetActive(false);
                            m_Effect.transform.position      = m_StartPos;
                            m_Effect.transform.localRotation = q;
                            m_Effect.SetActive(true);
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(effectPath))
                            {
                                LogSystem.Warn("[skill:{0} dsl skill id:{1}] track effect is empty.", senderObj.SkillId, instance.DslSkillId);
                            }
                            else
                            {
                                LogSystem.Warn("[skill:{0} dsl skill id:{1}] track effect {2} can't find.", senderObj.SkillId, instance.DslSkillId, effectPath);
                            }
                        }
                    }
                    else if (null != m_Effect)
                    {
                        if (!m_NotMove && !m_IsHit)
                        {
                            Vector3 dest;
                            if (null != m_BoneTransform)
                            {
                                dest = m_BoneTransform.position;
                            }
                            else
                            {
                                dest    = obj.transform.position;
                                dest.y += 1.5f;
                            }
                            dest = Utility.FrontOfTarget(m_StartPos, dest, 0.1f);
                            //m_Effect.transform.position = Vector3.MoveTowards(m_Effect.transform.position, dest, m_RealSpeed * Time.deltaTime);
                            m_Effect.transform.position = Utility.GetBezierPoint(m_StartPos, m_ControlPos, dest, (curSectionTime - StartTime) / 1000.0f / m_Lifetime);
                            if ((dest - m_Effect.transform.position).sqrMagnitude <= 0.01f)
                            {
                                m_HitEffectRotation = Quaternion.LookRotation(m_StartPos - dest);
                                if (m_NoImpact)
                                {
                                    instance.SetVariable("hitEffectRotation", m_HitEffectRotation);
                                }
                                else
                                {
                                    int impactId = EntityController.Instance.GetTrackSendImpact(senderObj.ObjId, senderObj.Seq, instance.Variables);
                                    Dictionary <string, object> args;
                                    TriggerUtil.CalcImpactConfig(0, impactId, instance, senderObj.ConfigData, out args);
                                    if (args.ContainsKey("hitEffectRotation"))
                                    {
                                        args["hitEffectRotation"] = m_HitEffectRotation;
                                    }
                                    else
                                    {
                                        args.Add("hitEffectRotation", m_HitEffectRotation);
                                    }
                                    EntityController.Instance.TrackSendImpact(senderObj.ObjId, senderObj.SkillId, senderObj.Seq, impactId, args);
                                    int senderId, targetId;
                                    EntityController.Instance.CalcSenderAndTarget(senderObj, out senderId, out targetId);
                                }
                                m_IsHit = true;
                            }
                        }
                        if (curSectionTime > StartTime + m_Lifetime * 1000)
                        {
                            m_Effect.SetActive(false);
                            ResourceSystem.Instance.RecycleObject(m_Effect);
                            m_Effect = null;
                            instance.StopCurSection();
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }

                    //GameFramework.LogSystem.Debug("EmitEffectTriger:{0}", m_EffectPath);
                    return(true);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                instance.StopCurSection();
                return(false);
            }
        }