Exemplo n.º 1
0
    GrassSkillInfo DataToInfo(GrassSkillData data)
    {
        GrassSkillInfo info = new GrassSkillInfo();

        info.prefabID = data.spreadDir;
        info.delay    = (float)data.delay / 1000f;
        info.duration = (float)data.duration / 1000f;
        info.scale    = Vector3.one;
        if (!string.IsNullOrEmpty(data.size))
        {
            if (data.spreadDir.StartsWith("3"))
            {
                var strs = data.size.Split(',');
                info.scale = new Vector3(float.Parse(strs [0]) * 1.5f, 1, float.Parse(strs [1]) * 1.5f);
            }
            else
            {
                float rad = float.Parse(data.size);
                info.scale = new Vector3(rad * 2 * 1.5f, 1, rad * 2 * 1.5f);
            }
        }
        if (!string.IsNullOrEmpty(data.angle))
        {
            var strs = data.angle.Split(',');
            info.angle1 = float.Parse(strs [0]);
            info.angle2 = float.Parse(strs [1]);
        }
        if (!string.IsNullOrEmpty(data.offset))
        {
            var strs = data.offset.Split(',');
            info.offset = new Vector2(float.Parse(strs [0]), float.Parse(strs [1]));
        }

        return(info);
    }
Exemplo n.º 2
0
    public void PlaySkill(Vector3 pos, Vector3 dir, GrassSkillData data)
    {
        if (data == null)
        {
            Debug.LogError("GrassSkillData数据为空,请联系陶恩恩");
        }
        GrassSkillInfo info = DataToInfo(data);
        //GameObject go = Instantiate(GetPrefab(info.prefabID)) as GameObject;
        GameObject go = EasyPoolManager.Instantiate(GetPrefab(info.prefabID)) as GameObject;


        GrassSkillShape shape = go.GetComponent <GrassSkillShape> ();

        shape.Play(pos, dir, info);
    }
Exemplo n.º 3
0
    public virtual void Play(Vector3 pos, Vector3 dir, GrassSkillInfo _info)
    {
        Reset();
        posOrigin                  = pos;
        info                       = _info;
        transform.position         = new Vector3(pos.x, GrassFP_Manager.BasicHeight + 1.5f, pos.z);
        transform.localEulerAngles = dir;
        transform.localScale       = info.scale;
        transform.position        += transform.forward * info.offset.y;
        transform.position        += transform.right * info.offset.x;

        initScale     = transform.localScale;
        mat           = GetComponentInChildren <MeshRenderer> ().material;
        playCoroutine = StartCoroutine(IEPlay());
    }
Exemplo n.º 4
0
    public void CreateQuad(GrassSkillShape shape, GrassSkillInfo info, float pcg)
    {
        Transform tOri  = null;
        Vector3   scale = Vector3.one;

        //301 front
        if (info.prefabID == "301")
        {
            scale = shape.transform.GetChild(0).localScale;

            tOri = shape.transform.GetChild(0).GetChild(0);
        }
        //302 back
        else if (info.prefabID == "302")
        {
            scale = shape.transform.GetChild(0).localScale;
            tOri  = shape.transform.GetChild(0).GetChild(0);
        }
        //303 split up
        else if (info.prefabID == "303")
        {
            scale = shape.transform.localScale;
            tOri  = shape.transform;
        }
        count = GetCount_Quad(info.scale, info.duration);

        for (int i = 0; i < count; i++)
        {
            Vector3 offset = RandomInQuad(scale);
            Vector3 p      = tOri.position;
            p += tOri.forward * offset.z * 0.5f;
            p += tOri.right * offset.x * 0.5f;

            float h = GetHeight(p, shape.posOrigin.y);

            p = new Vector3(p.x, h, p.z);
            CreateFX(shape, p);
        }
    }
Exemplo n.º 5
0
    public void CreateSwing(GrassSkillShape shape, GrassSkillInfo info, float pcg)
    {
        count = GetCount_Tri(info.scale, info.duration, info.angle1, info.angle2);

        float rad = info.scale.x * 0.5f;

        rad *= Random.Range(0f, 1f);
        for (int i = 0; i < count; i++)
        {
            Vector2 v   = Random.insideUnitCircle;
            Vector3 dir = new Vector3(v.x, 0, v.y);
            dir.Normalize();

            float angleBe = Vector3.Angle(dir, shape.sectorDir);
            if (angleBe < shape.sectorRange)
            {
                Vector3 p = shape.transform.position + dir * rad;
                float   h = GetHeight(p, shape.posOrigin.y);
                p = new Vector3(p.x, h, p.z);
                CreateFX(shape, p);
            }
        }
    }
Exemplo n.º 6
0
 public override void Play(Vector3 pos, Vector3 dir, GrassSkillInfo _info)
 {
     base.Play(pos, dir, _info);
     transform.position += transform.forward * info.scale.z * 0.4f;
 }
Exemplo n.º 7
0
 public override void Play(Vector3 pos, Vector3 dir, GrassSkillInfo _info)
 {
     base.Play(pos, dir, _info);
     //Sector
     SetSector(info.angle1, info.angle2);
 }