Exemple #1
0
    private string PreSaveData()
    {
        string skp    = XEditorLibrary.GetPath("Skill" + "/" + _directory) + _name + ".txt";
        string config = XEditorLibrary.GetEditorBasedPath("Skill" + "/" + _directory) + _name + ".config";

        XConfigData conf = new XConfigData();

        if (!_combined)
        {
            conf.SkillClip     = AssetDatabase.GetAssetPath(_skillClip);
            conf.SkillClipName = _skillClip.name;
        }
        conf.Player    = _id;
        conf.Directory = _directory;
        conf.SkillName = _name;

        XSkillData data = new XSkillData();

        data.Name = _name;
        if (!_combined)
        {
            data.ClipName = conf.SkillClip.Remove(conf.SkillClip.LastIndexOf('.'));
            data.ClipName = data.ClipName.Remove(0, 17);
        }
        data.TypeToken = _combined ? 2 : 0;
        XDataIO <XSkillData> .singleton.SerializeData(skp, data);

        using (FileStream writer = new FileStream(config, FileMode.Create))
        {
            XmlSerializer formatter = new XmlSerializer(typeof(XConfigData));
            formatter.Serialize(writer, conf);
        }
        AssetDatabase.Refresh();
        return(skp);
    }
Exemple #2
0
 private void AddHurtTarget(XSkillData data, IHitHoster hit, int triggerTime)
 {
     if (!data.Result[triggerTime].Loop && !data.Result[triggerTime].LongAttackEffect)
     {
         if (!_hurt_target.ContainsKey(triggerTime))
         {
             _hurt_target[triggerTime] = new HashSet <IHitHoster>();
         }
         _hurt_target[triggerTime].Add(hit);
     }
 }
Exemple #3
0
 public void CastSkill(string file)
 {
     if (_src_skill != file)
     {
         _src_skill = file;
         Stream        stream    = XResources.ReadText("Table/Skill/" + file);
         XmlSerializer formatter = new XmlSerializer(typeof(XSkillData));
         _current = (XSkillData)formatter.Deserialize(stream);
         RebuildSkillAniamtion();
     }
     Fire();
 }
Exemple #4
0
    public void InnerResult(int triggerTime, Vector3 forward, Vector3 pos, XSkillData data, IHitHoster hitted = null)
    {
        nHotID = triggerTime;

        if (hitted == null)
        {
            pos           += XCommon.singleton.VectorToQuaternion(host.Transform.forward) * new Vector3(data.Result[triggerTime].Offset_X, 0, data.Result[triggerTime].Offset_Z);
            nResultForward = forward;
            for (int i = 0, max = host.Hits.Length; i < max; i++)
            {
                var hit = host.Hits[i];
                if (IsHurtEntity(hit, triggerTime))
                {
                    continue;
                }
                Vector3 dir = hit.RadiusCenter - pos;
                dir.y = 0;
                float distance = dir.magnitude;
                if (distance > hit.Attr.radius)
                {
                    distance -= hit.Attr.radius;
                }
                if (dir.sqrMagnitude == 0)
                {
                    dir = forward;
                }
                dir.Normalize();

                if (data.IsInField(triggerTime, pos, forward, hit.RadiusCenter, Vector3.Angle(forward, dir), distance))
                {
                    Vector3 vHitDir = data.Result[triggerTime].Affect_Direction == XResultAffectDirection.AttackDir ? (hit.RadiusCenter - pos).normalized : host.Attribute.GetRotateTo();
                    AddHurtTarget(data, hit, triggerTime);
                    hit.Begin(host, data.Hit[triggerTime], vHitDir, data.Logical.AttackOnHitDown);
                }
            }
        }
        else
        {
            Vector3 vHitDir = data.Result[triggerTime].Affect_Direction == XResultAffectDirection.AttackDir ? hitted.RadiusCenter - pos : host.Attribute.GetRotateTo();
            vHitDir.y = 0;
            vHitDir.Normalize();
            hitted.Begin(host, data.Hit[triggerTime], vHitDir, data.Logical.AttackOnHitDown);
        }
    }
Exemple #5
0
 void Update()
 {
     if (_state != DummyState.Fire)
     {
         if (Input.GetKeyDown(KeyCode.Space))
         {
             if (_xData.TypeToken == 1 && ComboSkills.Count > 0)
             {
                 oVerrideController[Clip.Art] = Resources.Load(_xData.ClipName) as AnimationClip;
             }
             _current = _xData;
             Fire();
         }
         _action_framecount = 0;
     }
     else
     {
         _action_framecount += Time.deltaTime;
         if (_action_framecount > _current.Time)
         {
             StopFire();
         }
     }
 }
Exemple #6
0
    public XBulletData(ISkillHoster firer, XSkillData data, GameObject target, int idx, float diviation, int wid, IHitHoster[] hits)
    {
        _sequnce     = idx;
        _data        = data;
        _hoster      = firer;
        _hits        = hits;
        _warning_pos = Vector3.zero;

        if (data.Result[idx].Attack_All)
        {
            _warning_pos = target.transform.position;
        }
        else if (data.Result[idx].Warning)
        {
            _warning_pos = firer.Attribute.skillWarning.warningPosAt[data.Result[idx].Warning_Idx][wid];
        }

        _warning = _warning_pos.sqrMagnitude > 0;
        float   height = _hoster.Present_data.BoundHeight;
        Vector3 begin  = _hoster.Transform.position; begin.y += height * 0.5f;
        Vector3 dir    = _warning ? (_warning_pos - _hoster.Transform.position) : firer.Transform.forward;

        begin += firer.Transform.rotation * new Vector3(
            data.Result[idx].LongAttackData.At_X,
            data.Result[idx].LongAttackData.At_Y,
            data.Result[idx].LongAttackData.At_Z);
        dir.y = 0;
        Vector3 flyTo = XCommon.singleton.HorizontalRotateVetor3(dir.normalized, diviation);
        float   h     = (_data.Result[_sequnce].LongAttackData.AimTargetCenter && firer.Target != null) ? (begin.y - height * 0.5f) : 0;

        _velocity = Warning ? (WarningPos - begin).magnitude / Runningtime : _data.Result[_sequnce].LongAttackData.Velocity;
        flyTo     = (h == 0 || _velocity == 0) ? flyTo : (h * Vector3.down + _velocity * Runningtime * flyTo).normalized;

        BulletRay = new Ray(begin, flyTo);
        _target   = _data.Result[_sequnce].LongAttackData.Follow ? firer.Target : null;
    }
Exemple #7
0
        public void HotBuildEx(XSkillHoster hoster, XConfigData conf)
        {
            XSkillDataExtra edata = hoster.SkillDataExtra;
            XSkillData      data  = hoster.SkillData;

            edata.ResultEx.Clear();
            edata.Fx.Clear();
            edata.HitEx.Clear();

            if (data.Result != null)
            {
                foreach (XResultData result in data.Result)
                {
                    XResultDataExtraEx rdee = new XResultDataExtraEx();
                    if (result.LongAttackEffect)
                    {
                        rdee.BulletPrefab      = Resources.Load(result.LongAttackData.Prefab) as GameObject;
                        rdee.BulletEndFx       = Resources.Load(result.LongAttackData.End_Fx) as GameObject;
                        rdee.BulletHitGroundFx = Resources.Load(result.LongAttackData.HitGround_Fx) as GameObject;
                    }
                    edata.ResultEx.Add(rdee);
                }
            }
            if (data.Hit != null)
            {
                foreach (XHitData hit in data.Hit)
                {
                    XHitDataExtraEx hee = new XHitDataExtraEx();
                    hee.Fx = Resources.Load(hit.Fx) as GameObject;
                    edata.HitEx.Add(hee);
                }
            }
            if (data.Fx != null)
            {
                foreach (XFxData fx in data.Fx)
                {
                    XFxDataExtra fxe = new XFxDataExtra();
                    fxe.Fx = Resources.Load(fx.Fx) as GameObject;
                    if (fx.Bone != null && fx.Bone.Length > 0)
                    {
                        Transform attachPoint = hoster.gameObject.transform.Find(fx.Bone);
                        if (attachPoint != null)
                        {
                            fxe.BindTo = attachPoint.gameObject;
                        }
                        else
                        {
                            int index = fx.Bone.LastIndexOf("/");
                            if (index >= 0)
                            {
                                string bone = fx.Bone.Substring(index + 1);
                                attachPoint = hoster.gameObject.transform.Find(bone);
                                if (attachPoint != null)
                                {
                                    fxe.BindTo = attachPoint.gameObject;
                                }
                            }
                        }
                    }
                    fxe.Ratio = fx.At / data.Time;
                    edata.Fx.Add(fxe);
                }
            }
            if (data.Manipulation != null)
            {
                foreach (XManipulationData manipulation in data.Manipulation)
                {
                    XManipulationDataExtra me = new XManipulationDataExtra();
                    edata.ManipulationEx.Add(me);
                }
            }
            if (data.Warning != null)
            {
                foreach (XWarningData warning in data.Warning)
                {
                    XWarningDataExtra we = new XWarningDataExtra();
                    we.Fx    = Resources.Load(warning.Fx) as GameObject;
                    we.Ratio = warning.At / data.Time;
                    edata.WarningEx.Add(we);
                }
            }
            if (data.Mob != null)
            {
                foreach (XMobUnitData mob in data.Mob)
                {
                    XMobUnitDataExtra me = new XMobUnitDataExtra();
                    me.Ratio = mob.At / data.Time;
                    edata.MobEx.Add(me);
                }
            }
        }
Exemple #8
0
    private void StripData(XSkillData data)
    {
        if (string.IsNullOrEmpty(data.Name))
        {
            data.Name = null;
        }
        if (string.IsNullOrEmpty(data.ClipName))
        {
            data.ClipName = null;
        }

        if (data.Result != null && data.Result.Count > 0)
        {
            foreach (XResultData r in data.Result)
            {
                if (r.LongAttackEffect)
                {
                    if (string.IsNullOrEmpty(r.LongAttackData.Prefab))
                    {
                        r.LongAttackData.Prefab = null;
                    }
                    if (string.IsNullOrEmpty(r.LongAttackData.HitGround_Fx))
                    {
                        r.LongAttackData.HitGround_Fx = null;
                    }
                    if (string.IsNullOrEmpty(r.LongAttackData.End_Fx))
                    {
                        r.LongAttackData.End_Fx = null;
                    }
                    if (string.IsNullOrEmpty(r.LongAttackData.Audio))
                    {
                        r.LongAttackData.Audio = null;
                    }
                    if (string.IsNullOrEmpty(r.LongAttackData.End_Audio))
                    {
                        r.LongAttackData.End_Audio = null;
                    }

                    if (!r.LongAttackData.Manipulation || r.LongAttackData.Type == XResultBulletType.Ring)
                    {
                        r.LongAttackData.Manipulation       = false;
                        r.LongAttackData.ManipulationForce  = 0;
                        r.LongAttackData.ManipulationRadius = 0;
                    }
                    if (!data.NeedTarget || r.LongAttackData.Type == XResultBulletType.Satellite || r.LongAttackData.Type == XResultBulletType.Ring)
                    {
                        r.LongAttackData.AimTargetCenter = false;
                        r.LongAttackData.Follow          = false;
                    }
                    if (r.LongAttackData.Type == XResultBulletType.Satellite || r.LongAttackData.Type == XResultBulletType.Ring)
                    {
                        r.LongAttackData.At_X       = 0;
                        r.LongAttackData.At_Y       = 0;
                        r.LongAttackData.At_Z       = 0;
                        r.LongAttackData.IsPingPong = false;
                        r.LongAttackData.Velocity   = 0;
                        r.LongAttackData.Stickytime = 0;
                        if (r.LongAttackData.Type == XResultBulletType.Ring)
                        {
                            r.LongAttackData.Radius         = 0;
                            r.LongAttackData.FireAngle      = 0;
                            r.LongAttackData.TriggerAtEnd   = false;
                            r.LongAttackData.FlyWithTerrain = false;
                        }
                    }
                    if (r.LongAttackData.Type != XResultBulletType.Ring)
                    {
                        r.LongAttackData.RingFull = false;
                    }
                    if (r.LongAttackData.Type != XResultBulletType.Satellite && r.LongAttackData.Type != XResultBulletType.Ring)
                    {
                        r.LongAttackData.RingRadius   = 0;
                        r.LongAttackData.RingVelocity = 0;
                        r.LongAttackData.Palstance    = 0;
                    }
                    if (!r.LongAttackData.TriggerAtEnd)
                    {
                        r.LongAttackData.TriggerAtEnd_Count = 0;
                    }
                    if (r.LongAttackData.TriggerAtEnd_Count == 0)
                    {
                        r.LongAttackData.TriggerAtEnd_Cycle = 0;
                    }
                }
                else
                {
                    r.LongAttackData = null;
                }
            }
        }
        else
        {
            data.Result = null;
        }

        ///////////////////////////////////////////////////
        if (data.Hit != null && data.Hit.Count > 0)
        {
            foreach (XHitData h in data.Hit)
            {
                if (string.IsNullOrEmpty(h.Fx))
                {
                    h.Fx = null;
                }

                if (h.Additional_Using_Default)
                {
                    h.Additional_Hit_Time_Present_Straight = 0;
                    h.Additional_Hit_Time_Hard_Straight    = 0;
                    h.Additional_Hit_Offset = 0;
                    h.Additional_Hit_Height = 0;
                }
            }
        }
        else
        {
            data.Hit = null;
        }
        ///////////////////////////////////////////////////
        if (data.Ja != null && data.Ja.Count > 0)
        {
            foreach (XJAData j in data.Ja)
            {
                XJAData n = new XJAData();
                n.Index = j.Index;

                if (string.IsNullOrEmpty(j.Next_Name))
                {
                    j.Next_Name = null;
                }
                if (string.IsNullOrEmpty(j.Name))
                {
                    j.Name = null;
                }
            }
        }
        else
        {
            data.Ja = null;
        }

        ///////////////////////////////////////////////////
        if (data.Fx != null && data.Fx.Count > 0)
        {
            foreach (XFxData f in data.Fx)
            {
                if (string.IsNullOrEmpty(f.Fx))
                {
                    f.Fx = null;
                }
                if (string.IsNullOrEmpty(f.Bone))
                {
                    f.Bone = null;
                }
            }
        }
        else
        {
            data.Fx = null;
        }

        ///////////////////////////////////////////////////
        if (data.Warning != null && data.Warning.Count > 0)
        {
            foreach (XWarningData w in data.Warning)
            {
                if (string.IsNullOrEmpty(w.Fx))
                {
                    w.Fx = null;
                }
                switch (w.Type)
                {
                case XWarningType.Warning_None:
                    w.Mobs_Inclusived  = false;
                    w.RandomWarningPos = false;
                    w.MaxRandomTarget  = 0;
                    break;

                case XWarningType.Warning_Target:
                    w.Mobs_Inclusived = false;
                    w.MaxRandomTarget = 0;
                    break;

                case XWarningType.Warning_All:
                    w.OffsetX         = 0;
                    w.OffsetY         = 0;
                    w.OffsetZ         = 0;
                    w.MaxRandomTarget = 0;
                    if (w.RandomWarningPos)
                    {
                        w.Mobs_Inclusived = false;
                    }
                    break;

                case XWarningType.Warning_Multiple:
                    w.OffsetX         = 0;
                    w.OffsetY         = 0;
                    w.OffsetZ         = 0;
                    w.Mobs_Inclusived = false;
                    break;
                }
                if (!w.RandomWarningPos)
                {
                    w.PosRandomRange = 0;
                }
                w.PosRandomCount = 0;
            }
        }
        else
        {
            data.Warning = null;
        }
        ///////////////////////////////////////////////////
        if (data.Mob != null && data.Mob.Count > 0)
        {
            foreach (XMobUnitData m in data.Mob)
            {
                if (m.TemplateID <= 0)
                {
                    m.LifewithinSkill = false;
                    m.Shield          = false;
                    m.Offset_At_X     = m.Offset_At_Y = m.Offset_At_Z = 0;
                }
            }
        }
        else
        {
            data.Mob = null;
        }
    }