コード例 #1
0
    ///
    /// 只考虑爆炸1, 爆炸2,爆炸3
    ///
    public static GameObject CreateParticle(GameObject Ground_FX, Vector3 position)
    {
        GameObject go = null;

        string name = Ground_FX.name;

        if (name == "Baozha_1" || name == "baozha_2" || name == "Baozha_3")
        {
            Interlocked.Increment(ref currentCount);

            float realRate = 1f;
            if (currentCount >= MAX_COUNT)
            {
                realRate = MAX_COUNT * 1.0f / currentCount;
                if (realRate > 1f)
                {
                    realRate = 1f;
                }
            }

            go = EmptyLoad.CreateObj(Ground_FX, position, Quaternion.identity);
            ParticleSystem[] PartTemp = go.GetComponentsInChildren <ParticleSystem>();
            foreach (ParticleSystem aPartTemp in PartTemp)
            {
                aPartTemp.emissionRate *= realRate;
            }
        }
        else
        {
            go = EmptyLoad.CreateObj(Ground_FX, position, Quaternion.identity);
        }

        return(go);
    }
コード例 #2
0
    public static GameObject CreateParticle(GameObject Ground_FX, Vector3 position)
    {
        Interlocked.Increment(ref currentCount);

        int realRate = currentCount / PerCount;

        realRate = INIT_RATE - realRate;
        if (realRate <= 0)
        {
            realRate = 1;
        }

        if (currentCount >= MAX_COUNT)
        {
            Interlocked.Decrement(ref currentCount);
            return(null);
        }

        GameObject go = EmptyLoad.CreateObj(Ground_FX, new Vector3(position.x, 0, position.x), Quaternion.identity);

        ParticleSystem[] PartTemp = go.GetComponentsInChildren <ParticleSystem>();
        foreach (ParticleSystem aPartTemp in PartTemp)
        {
            aPartTemp.emissionRate = realRate;
        }

        return(go);
    }
コード例 #3
0
    void RandFX()
    {
        if (myFX.Length > 0)
        {
            float temp_X = 0f;
            float temp_Y = 0f;
            float temp_Z = 0f;
            if (RandRot_X)
            {
                temp_X = Random.Range(0, 360);
            }
            if (RandRot_Y)
            {
                temp_Y = Random.Range(0, 360);
            }
            if (RandRot_Z)
            {
                temp_Z = Random.Range(0, 360);
            }

            NewRot = new Vector3(temp_X, temp_Y, temp_Z);

            if (RandRot_X || RandRot_Y || RandRot_Z)
            {
                EmptyLoad.CreateObj(myFX[FX_ID], this.gameObject.transform.position, Quaternion.Euler(NewRot));
            }
            else
            {
                EmptyLoad.CreateObj(myFX[FX_ID], this.gameObject.transform.position, this.gameObject.transform.rotation);
            }

            if (myFX.Length > 1)
            {
                if (!OutOfOrder)
                {
                    FX_ID++;
                    if (FX_ID >= myFX.Length)
                    {
                        FX_ID = 0;
                    }
                }
                else
                {
                    FX_ID = Random.Range(0, myFX.Length);
                }
            }


            if (RandTime)
            {
                Invoke("RandFX", Random.Range(IntervalTime1, IntervalTime2));
            }
            else
            {
                Invoke("RandFX", IntervalTime1);
            }
        }
    }
コード例 #4
0
ファイル: BanTools.cs プロジェクト: mengtest/DragonBallNew
    public static GameObject CreateNGUIOject(Object aObject, Vector3 v3, Quaternion q4, Transform parent)
    {
        Vector3    oldScale = (aObject as GameObject).transform.localScale;
        GameObject temp     = EmptyLoad.CreateObj(aObject, v3, q4);

        temp.transform.transform.parent = parent;
        temp.transform.localScale       = oldScale;
        return(temp);
    }
コード例 #5
0
    //private bool b_InUse = false;

    void Update()
    {
        if (temp_Ground_FX != null)
        {
            temp_Ground_FX.transform.position = new Vector3(this.transform.position.x, 0, this.transform.position.z);
            if (this.transform.position.y < 2)
            {
                PartSystem_ONOFF(true);
            }
            else
            {
                PartSystem_ONOFF(false);
            }
        }

        if (b_WillDie)
        {
            return;
        }

        this.transform.position += v3_Speed * Time.deltaTime;
        Vector3 target_Minus_This = finalPos - this.transform.position;

        if (Vector3.Dot(v3_Speed, target_Minus_This) < 0)
        {
            Destroy(this.gameObject, DeleteSelfTime);
            if (prefab_Explosion != null)
            {
                EmptyLoad.CreateObj(prefab_Explosion, transform.position, Quaternion.identity);
            }
            foreach (ParticleSystem aParticleSystem in GetComponentsInChildren <ParticleSystem>())
            {
                aParticleSystem.enableEmission = false;
            }

            foreach (MeshRenderer aRenderer in GetComponentsInChildren <MeshRenderer>())
            {
                aRenderer.enabled = false;
            }

            b_WillDie = true;
            return;
        }

        Vector3 dir = Vector3.Normalize(target_Minus_This);

        v3_Speed += dir * f_AddSpeed * Time.deltaTime;
        if (Vector3.SqrMagnitude(v3_Speed) > f_MaxSpeed * f_MaxSpeed)
        {
            v3_Speed = Vector3.Normalize(v3_Speed) * f_MaxSpeed;
        }
    }
コード例 #6
0
    void Start()
    {
        //设置随机偏移范围
        v3_TargetRandomOffset = new Vector3(
            Random.Range(v3_TargetRandomOffset.x, -v3_TargetRandomOffset.x),
            Random.Range(v3_TargetRandomOffset.y, -v3_TargetRandomOffset.y),
            Random.Range(v3_TargetRandomOffset.z, -v3_TargetRandomOffset.z)
            );

        if (target != null)
        {
            finalPos = target.transform.position + v3_TargetRandomOffset;
        }
        else
        {
            finalPos = v3_TargetRandomOffset;
        }


        //计算最大速度
        f_MaxSpeed = Vector3.Distance(finalPos, this.transform.position) / f_Time;
        //计算加速度
        f_AddSpeed = f_MaxSpeed * f_BeiShu;
        //横向偏移角度
        float angleX = Random.Range(TrackRandomOffset_UD.x, TrackRandomOffset_UD.y);
        //纵向偏移角度
        float angleY = Random.Range(TrackRandomOffset_LR.x, TrackRandomOffset_LR.y);
        //Z为前进方向
        float angleZ = 0;
        //设置初始角度四位数
        Quaternion rotation = Quaternion.Euler(angleX, angleY, angleZ);

        //求两点之间的单位向量(以this.transform.position为0点指向finalPos的单位1线段长度的XYZ坐标)
        Vector3 dir = (finalPos - this.transform.position).normalized;

        //最终角度 = 旋转向量*偏转单位向量得到正确的偏移后的角度
        dir = rotation * dir;
        //最终速度 = 初始角度*速度
        v3_Speed = dir * f_MaxSpeed;

        //地面烟尘特效生成
        if (Ground_FX != null)
        {
            //创建烟尘
            temp_Ground_FX = EmptyLoad.CreateObj(Ground_FX, new Vector3(this.transform.position.x, 0, this.transform.position.x), Quaternion.identity);
            //首先关闭显示
            PartSystem_ONOFF(true);
        }
    }
コード例 #7
0
    IEnumerator CreateFx(int ID)
    {
        if (ShowFX != null && ShowFX.Length != 0)
        {
            for (int i = 0; i < ShowFX.Length; i++)
            {
                if (ShowFX[i].ON_OFF && ShowFX[i].Prefab_FX != null && ShowFX[i].PlayID == ID)
                {
                    yield return(new WaitForSeconds(ShowFX[i].FXtime));

                    GameObject temp;

                    temp = EmptyLoad.CreateObj(
                        ShowFX[i].Prefab_FX, this.transform.position, this.transform.localRotation);

                    temp.transform.parent = this.gameObject.transform;

                    temp.transform.Translate(ShowFX[i].v3_FXPos_offset);
                    temp.transform.Rotate(ShowFX[i].v3_FXRot_offset);
                }
            }
        }
    }
コード例 #8
0
ファイル: BanTools.cs プロジェクト: mengtest/DragonBallNew
    public static GameObject CreateObject(Object aObject, Vector3 v3)
    {
        GameObject temp = EmptyLoad.CreateObj(aObject, v3, Quaternion.identity);

        return(temp);
    }
コード例 #9
0
ファイル: BanTools.cs プロジェクト: mengtest/DragonBallNew
    public static GameObject CreateObject(Object aObject)
    {
        GameObject temp = EmptyLoad.CreateObj(aObject);

        return(temp);
    }
コード例 #10
0
    void CreateBanLine()
    {
        GameObject temp_Screen = EmptyLoad.CreateObj(CreateOBJ, this.gameObject.transform.position, this.gameObject.transform.rotation);

        temp_Screen.GetComponent <BanCurveLine>().target = GoPos;
    }
コード例 #11
0
    //生成一个角色模型
    public CRLuo_PlayAnim_FX GeneratePlayAnim(int index)
    {
        GameObject temp = EmptyLoad.CreateObj(ModelLoader.get3DModel(index));

        return(temp.GetComponent <CRLuo_PlayAnim_FX>());
    }
コード例 #12
0
    //private bool b_InUse = false;

    void Update()
    {
        //烟尘特效是否存在
        if (Ground_FX != null)
        {
            //设置烟尘地面位置匹配
            temp_Ground_FX.transform.position = new Vector3(this.transform.position.x, 0, this.transform.position.z);
            //如果高度小于2显示
            if (this.transform.position.y < 2)
            {
                PartSystem_ONOFF(true);
            }
            else
            {
                PartSystem_ONOFF(false);
            }
        }

        //if (Input.GetKeyDown(KeyCode.A))
        //{
        //      b_InUse = true;
        //}

        //if (!b_InUse)
        //{
        //      return;
        //}

        //如果当前对象消失为真
        if (b_WillDie)
        {
            //跳出程序,不继续运行
            return;
        }

        //当前位置 = 矢量速度*时间累计
        this.transform.position += v3_Speed * Time.deltaTime;
        //目标矢量 = 目标位置 - 当前位置
        Vector3 target_Minus_This = finalPos - this.transform.position;

        //如果距离速度与当前目标矢量距离 小于 0 说明到达攻击目标
        if (Vector3.Dot(v3_Speed, target_Minus_This) < 0)
        {
            //准备删除当前物体
            Destroy(this.gameObject, DeleteSelfTime);
            //如果爆炸特效存在
            if (FX_Boo != null)
            {
                //创建爆炸特效 创建特效(特效,当前位置,与父级或场景旋转对齐)
                EmptyLoad.CreateObj(FX_Boo, this.transform.position, Quaternion.identity);
            }
            //设置所有当前物体下的粒子关闭
            foreach (ParticleSystem aParticleSystem in GetComponentsInChildren <ParticleSystem>())
            {
                aParticleSystem.enableEmission = false;
            }

            foreach (MeshRenderer aRenderer in GetComponentsInChildren <MeshRenderer>())
            {
                aRenderer.enabled = false;
            }
            //当前对象消失为真
            b_WillDie = true;
            //跳出当前程序,屏蔽后方程序
            return;
        }

        //标准化当前矢量方向
        Vector3 dir = Vector3.Normalize(target_Minus_This);

        //加速度结果 = 标准化方向*加速度
        v3_Speed += dir * f_AddSpeed * Time.deltaTime;
        //如果当前速度平方(快速变成1维长度数据) 大于最大速度平方
        if (Vector3.SqrMagnitude(v3_Speed) > f_MaxSpeed * f_MaxSpeed)
        {
            //当前速度 = 矢量标准化单位*速度上限
            v3_Speed = Vector3.Normalize(v3_Speed) * f_MaxSpeed;
        }
    }