Example #1
0
    System.Collections.IEnumerator CreateFishGroupData(object obj)
    {
        const float TIME = 0.0f;

        System.IO.File.Delete("e:/fishGroup.dat");
        System.IO.FileStream   fs = new System.IO.FileStream("e:/fishGroup.dat", System.IO.FileMode.CreateNew, System.IO.FileAccess.Write);
        System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs);
        int groupCount            = FishResManager.Instance.GetGroupCount();

        // groupCount = 4;
        bw.Write(delta);
        bw.Write(groupCount);

        for (int i = 0; i < groupCount; ++i)
        {
            GroupDataList gdl = FishResManager.Instance.GetFishGroup((ushort)i);
            bw.Write(gdl.PathGroupData != null);
            if (gdl.PathGroupData != null)
            {
                FishPathGroupData        pathgroup  = gdl.PathGroupData;
                PathLinearInterpolator[] interpList = PathManager.Instance.GetPathGroup(pathgroup.PathGroupIndex, false);
                bw.Write(interpList.Length);
                foreach (PathLinearInterpolator interp in interpList)
                {
                    Fish fish = new Fish();
                    fish.Init(0, pathgroup.FishIndex, pathgroup.FishScaling, TIME, pathgroup.ActionSpeed, pathgroup.ActionUnite, pathgroup.Speed, interp);
                    WriteToList(fish, bw);
                }
            }
            else
            {
                bw.Write(gdl.PathList.Length);
                for (int t = 0; t < gdl.PathList.Length; ++t)
                {
                    PathLinearInterpolator pi = PathManager.Instance.GetPath(gdl.PathList[t]);

                    bw.Write(gdl.GroupDataArray.Length);
                    for (int j = 0; j < gdl.GroupDataArray.Length; ++j)
                    {
                        GroupData gd = gdl.GroupDataArray[j];
                        bw.Write(gd.FishNum);
                        for (int n = 0; n < gd.FishNum; ++n)
                        {
                            float time = Utility.GetPathTimeByDist(gdl.FrontPosition.x, gd.PosList[n].x, pi) + TIME;
                            Fish  fish = new Fish();
                            fish.Init(0, gd.FishIndex, gd.FishScaling, time, gd.ActionSpeed, gd.ActionUnite, gd.SpeedScaling, pi);
                            fish.SetOffset(new Vector3(0, gd.PosList[n].y, gd.PosList[n].z));
                            WriteToList(fish, bw);
                        }
                    }
                }
            }
            yield return(new WaitForEndOfFrame());

            Debug.Log("groupIndex:" + i + "/" + groupCount);
        }
        Debug.Log("完成.");
        bw.Close();
        fs.Close();
    }
Example #2
0
        PathLinearInterpolator ReadPathData(BinaryReader br)
        {
            PathLinearInterpolator pi = new PathLinearInterpolator();

            pi.m_WorldMatrix   = Utility.ReadMatrix4x4(br);
            pi.m_WorldRotation = Utility.ReadQuaternion(br);

            pi.m_MaxDistance       = br.ReadSingle();
            pi.m_SampleMaxDistance = br.ReadSingle();
            pi.m_HasPathEvent      = br.ReadBoolean();
            int sampleCount = br.ReadInt32();
            int nodeCount   = br.ReadInt32();

            pi.m_NodeList       = new LinearNodeData[nodeCount];
            pi.m_SplineDataList = new SplineSampleData[sampleCount];
            for (int i = 0; i < nodeCount; ++i)
            {
                LinearNodeData node = new LinearNodeData();
                node.EventType   = br.ReadByte();
                node.Times       = br.ReadUInt16();
                pi.m_NodeList[i] = node;
            }
            m_NodeCount += sampleCount;
            for (int j = 0; j < sampleCount; ++j)
            {
                SplineSampleData node = new SplineSampleData();
                node.pos               = Utility.ReadVec3(br);
                node.rot               = Utility.ReadQuaternion(br);
                node.timeScaling       = br.ReadSingle();
                node.nodeIdx           = br.ReadInt16();
                pi.m_SplineDataList[j] = node;
            }
            return(pi);
        }
Example #3
0
 public FishOptTimer(ILifeTimer timer, PathLinearInterpolator path, bool leftToRight)
     : base(FishOptType.FOT_TIMER)
 {
     m_Timer       = timer;
     m_Path        = path;
     m_LeftToRight = leftToRight;
 }
Example #4
0
    public static float GetPathTimeByDist(float startX, float curX, PathLinearInterpolator pi)
    {
        float dist  = startX - curX;
        float dist2 = pi.GetPos(0).x - pi.GetPos(0.01666f).x;

        return(dist / dist2 * 0.01666f);
    }
Example #5
0
 public void ResetController(PathLinearInterpolator interpolator, float speed, float time, float laughTime)
 {
     CtrlEvent = ControllerEvent.EVENT_NONE;
     m_PathEvent.Reset(laughTime);
     m_Interp = interpolator;
     m_TimeController.Reset(m_Interp.SampleMaxDistance, speed, time);
     CheckGetPRT();
 }
Example #6
0
 PathLinearInterpolator[] ReadPathGroupData(BinaryReader br, int pathCount)
 {
     PathLinearInterpolator[] piList = new PathLinearInterpolator[pathCount];
     for (int n = 0; n < pathCount; ++n)
     {
         piList[n] = ReadPathData(br);
     }
     return(piList);
 }
Example #7
0
 public FishOptPath(PathLinearInterpolator path, float transRotate, float pathRotate, float speed, float transTime, Vector3 offset, bool bScaling = true) : base(FishOptType.FOT_PATH)
 {
     m_InitData        = new InitData();
     m_InitData.Path   = path;
     m_InitData.Speed  = speed;
     m_InitData.Offset = offset;
     m_TransTime       = transTime;
     m_TransRotate     = transRotate;
     m_PathRotate      = pathRotate;
     m_bPathUpdate     = false;
     m_bScaling        = bScaling;
     m_DeadTime        = Utility.Range(0.6f, 0.9f);
 }
Example #8
0
    System.Collections.IEnumerator CreateFishPathData(object obj)
    {
        System.IO.File.Delete("e:/fish.dat");
        System.IO.FileStream   fs = new System.IO.FileStream("e:/fish.dat", System.IO.FileMode.CreateNew, System.IO.FileAccess.Write);
        System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs);
        bw.Write(delta);
        bw.Write(PathManager.Instance.PathCount);
        bw.Write(PathManager.Instance.PathGroupCount);
        Debug.Log("PathCount:" + PathManager.Instance.PathCount + ", GroupCount:" + PathManager.Instance.PathGroupCount);

        for (int i = 0; i < PathManager.Instance.PathCount; ++i)
        {
            PathLinearInterpolator pi = PathManager.Instance.GetPath(i);
            Fish f = new Fish();
            f.Init(0, 0, 1.0f, 0.0f, 1.0f, false, 1.5f, pi);
            WriteToList(f, bw);
            Debug.Log("Path:" + i);
            yield return(new WaitForEndOfFrame());
        }

        for (int i = 0; i < PathManager.Instance.PathGroupCount; ++i)
        {
            PathLinearInterpolator[] pi = PathManager.Instance.GetPathGroup(i);
            bw.Write(pi.Length);
            for (int j = 0; j < pi.Length; ++j)
            {
                Fish f = new Fish();
                f.Init(0, 0, 1.0f, 0.0f, 1.0f, false, 1.5f, pi[j]);
                WriteToList(f, bw);
            }

            Debug.Log("Group:" + i);
            yield return(new WaitForEndOfFrame());
        }
        Debug.Log("完成.");
        bw.Close();
        fs.Close();
    }
Example #9
0
 public FishOptOffset(float duration, PathLinearInterpolator path) : base(FishOptType.FOT_OFFSET)
 {
     m_Duration = duration;
     m_Path     = path;
 }
Example #10
0
        public void Init(ushort id, byte type, float scl, float time, float actionSpeed, bool actionUnite, float speed, PathLinearInterpolator interp)
        {
            ResFishData fd = FishResManager.Instance.GetFishData(type);

            if (fd == null)
            {
                Debug.Log("不存在的鱼模型:" + type.ToString());
                return;
            }
            m_CatchSeat = 0xff;
            m_bCatched  = false;
            m_Delay     = false;
            m_Scaling   = scl;
            m_FishID    = id;
            m_FishType  = type;

            m_PathCtrl = new PathController();
            m_PathCtrl.ResetController(interp, speed, time, fd.ClipLength[(byte)FishClipType.CLIP_CHAOFENG]);

            m_Model                   = (GameObject)GameObject.Instantiate(FishResManager.Instance.GetFishObj(type));
            m_ModelTransform          = m_Model.GetComponent <Transform>();
            m_ModelTransform.position = FishInitPos;
            m_Anim       = m_Model.GetComponent <Animator>();
            m_OrgRot     = m_ModelTransform.localRotation;
            m_Model.name = m_FishID.ToString();
            SetScaling(scl);
            m_Renderer = m_ModelTransform.GetChild(0).gameObject.GetComponent <Renderer>();
            if (m_Renderer == null)
            {
                m_Renderer = m_ModelTransform.GetChild(1).gameObject.GetComponent <Renderer>();
            }
            m_Anim.speed = actionSpeed;
            if (!actionUnite)
            {
                m_Anim.Play(YouYongHashName, 0, Utility.Range(0.0f, 1.0f));
            }
            if (IsBossFish())
            {
                m_bgsoundDelay = 2;
                AudioManager.Instance.StopBgMusic();
                //AudioManager.Instance.PlayOrdianryMusic(Audio.OrdianryMusic.m_bosscoming);

                //KonnoTool.ShowBossComingWindow();
            }
        }
Example #11
0
        public void LaunchFish(NetCmdPack pack)
        {
            NetCmdFish    cmdFish     = (NetCmdFish)pack.cmd;
            GroupDataList gdl         = FishResManager.Instance.GetFishGroup(cmdFish.GroupID);
            ushort        startID     = cmdFish.StartID;
            float         elapsedTime = Utility.TickSpan(pack.tick) + SceneRuntime.NetDelayTime;

            if (gdl.PathGroupData != null)
            {
                FishPathGroupData        pathgroup  = gdl.PathGroupData;
                PathLinearInterpolator[] interpList = PathManager.Instance.GetPathGroup(pathgroup.PathGroupIndex, SceneRuntime.Inversion);
                foreach (PathLinearInterpolator interp in interpList)
                {
                    Fish fish = new Fish();
                    fish.Init(startID, pathgroup.FishIndex, pathgroup.FishScaling, 0, pathgroup.ActionSpeed, pathgroup.ActionUnite, pathgroup.Speed, interp);
#if UNITY_EDITOR
                    fish.SetModelName("Fish_PathGroup_" + cmdFish.GroupID);
#endif
                    if (fish.AddElapsedTime(elapsedTime))
                    {
                        SetFish(fish);
                    }
                    else
                    {
                        fish.Destroy();
                    }

                    if (++startID >= FishSetting.FISH_MAX_NUM)
                    {
                        startID = 0;
                    }
                }
            }
            else
            {
                float fInv                = SceneRuntime.Inversion ? -1.0f : 1.0f;
                int   pathIndex           = cmdFish.PathID;
                PathLinearInterpolator pi = PathManager.Instance.GetPath(pathIndex, SceneRuntime.Inversion);
                float startX              = gdl.FrontPosition.x;
                foreach (GroupData gd in gdl.GroupDataArray)
                {
                    if (gd == null)
                    {
                        break;
                    }
                    if (gd.FishNum > gd.PosList.Length)
                    {
                        LogMgr.Log("错误的鱼群路径点:" + gd.FishNum + ", posnum:" + gd.PosList.Length);
                        return;
                    }
                    for (int i = 0; i < gd.FishNum; ++i)
                    {
                        float time = BuYuUtils.GetPathTimeByDist(startX, gd.PosList[i].x, pi);
                        Fish  fish = new Fish();
                        fish.Init(startID, gd.FishIndex, gd.FishScaling, time, gd.ActionSpeed, gd.ActionUnite, gd.SpeedScaling, pi);
#if UNITY_EDITOR
                        fish.SetModelName("Fish_FishGroup_" + cmdFish.GroupID + "_Path_" + pathIndex);
#endif
                        if (fish.AddElapsedTime(elapsedTime))
                        {
                            fish.SetOffset(new Vector3(0, fInv * gd.PosList[i].y, gd.PosList[i].z));
                            SetFish(fish);
                        }
                        else
                        {
                            fish.Destroy();
                        }
                        if (++startID == FishSetting.FISH_MAX_NUM)
                        {
                            startID = 0;
                        }
                    }
                }
            }
        }
Example #12
0
        void NewInitProcedure(object od)
        {
            BinaryReader br             = (BinaryReader)od;
            ushort       pathCount      = br.ReadUInt16();
            ushort       pathGroupCount = br.ReadUInt16();
            ushort       fishGroupCount = br.ReadUInt16();
            ushort       fishDataCount  = br.ReadUInt16();

            for (ushort i = 0; i < pathCount; ++i)
            {
                PathLinearInterpolator pi    = ReadPathData(br);
                PathLinearInterpolator piInv = ReadPathData(br);
                m_PathInterpList.Add(pi);
                m_PathInterpListInv.Add(piInv);
            }

            for (ushort i = 0; i < pathGroupCount; ++i)
            {
                short subPathCount             = br.ReadInt16();
                PathLinearInterpolator[] pi    = ReadPathGroupData(br, subPathCount);
                PathLinearInterpolator[] piInv = ReadPathGroupData(br, subPathCount);
                m_PathGroupList.Add(pi);
                m_PathGroupListInv.Add(piInv);
            }
            for (ushort i = 0; i < fishDataCount; ++i)
            {
                ResFishData fd = new ResFishData();
                fd.Size = Utility.ReadVec3(br);
                Utility.ReadQuaternion(br);
                for (int j = 0; j < (int)FishClipType.CLIP_MAX; ++j)
                {
                    fd.ClipLength[j] = br.ReadSingle();
                }
                FishResManager.Instance.AddFishData(fd);
            }
            for (ushort i = 0; i < fishGroupCount; ++i)
            {
                GroupDataList gdl = new GroupDataList();
                FishResManager.Instance.AddGroupData(gdl);
                bool bFishPathGroup = br.ReadBoolean();
                if (bFishPathGroup)
                {
                    gdl.PathGroupData = new FishPathGroupData();
                    gdl.PathGroupData.PathGroupIndex = br.ReadUInt16();
                    gdl.PathGroupData.Speed          = br.ReadSingle();
                    gdl.PathGroupData.FishIndex      = br.ReadByte();
                    gdl.PathGroupData.FishScaling    = br.ReadSingle();
                    gdl.PathGroupData.ActionSpeed    = br.ReadSingle();
                    gdl.PathGroupData.ActionUnite    = br.ReadBoolean();
                    //重复次数和间隔
                    br.ReadUInt16();
                    br.ReadUInt16();
                }
                else
                {
                    gdl.FrontPosition = Utility.ReadVec3(br);
                    ushort subPathCount = br.ReadUInt16();
                    gdl.PathList = new ushort[subPathCount];
                    for (ushort j = 0; j < subPathCount; ++j)
                    {
                        gdl.PathList[j] = br.ReadUInt16();
                    }
                    ushort groupDataCount = br.ReadUInt16();
                    gdl.GroupDataArray = new GroupData[groupDataCount];
                    for (ushort j = 0; j < groupDataCount; ++j)
                    {
                        GroupData gd = new GroupData();
                        gd.FishIndex    = br.ReadByte();
                        gd.FishNum      = br.ReadUInt16();
                        gd.FishScaling  = br.ReadSingle();
                        gd.SpeedScaling = br.ReadSingle();
                        gd.ActionSpeed  = br.ReadSingle();
                        gd.ActionUnite  = br.ReadBoolean();
                        gd.PosList      = new Vector3[gd.FishNum];
                        for (int n = 0; n < gd.FishNum; ++n)
                        {
                            gd.PosList[n] = Utility.ReadVec3(br);
                        }
                        gdl.GroupDataArray[j] = gd;
                    }
                }// end if (pd.FishGroupByPathGroup)
            }

            m_BoLang      = ReadPathData(br);
            m_DouDongPath = ReadPathData(br);
            short subPathCount2 = br.ReadInt16();

            m_LongJuanFeng = ReadPathGroupData(br, subPathCount2);

            m_BoLang.SetWorldPosition(Vector3.zero);
            m_DouDongPath.SetWorldPosition(Vector3.zero);

            for (int i = 0; i < m_LongJuanFeng.Length; ++i)
            {
                m_LongJuanFeng[i].SetWorldPosition(Vector3.zero);
            }

            uint endmagic = br.ReadUInt32();

            if (endmagic != ConstValue.FILE_END_MAGIC)
            {
                LogMgr.Log("路径文件结束不正确.");
            }
            br        = null;
            od        = null;
            m_bInitOK = true;
        }
Example #13
0
    public void  LaunchFishByAsycScene(NetCmdPack pack)
    {
        NetCmdSyncFish cmdFish     = (NetCmdSyncFish)pack.cmd;
        GroupDataList  gdl         = FishResManager.Instance.GetFishGroup(cmdFish.GroupID);
        float          elapsedTime = Utility.TickSpan(pack.tick) + SceneRuntime.NetDelayTime;

        if (gdl.PathGroupData != null)
        {
            FishPathGroupData        pathgroup  = gdl.PathGroupData;
            PathLinearInterpolator[] interpList = PathManager.Instance.GetPathGroup(pathgroup.PathGroupIndex, SceneRuntime.Inversion);
            if (cmdFish.PathIdx >= interpList.Length)
            {
                LogMgr.Log("路径数量和服务器不一致,路径群:" + cmdFish.PathGroup + ", 索引:" + cmdFish.PathIdx);
            }
            {
                Fish fish = new Fish();
                fish.Init(cmdFish.FishID, pathgroup.FishIndex, pathgroup.FishScaling, cmdFish.FishTime, pathgroup.ActionSpeed, pathgroup.ActionUnite, pathgroup.Speed, interpList[cmdFish.PathIdx]);
#if UNITY_EDITOR
                fish.SetModelName("Fish_PathGroup_" + cmdFish.GroupID);
#endif
                if (fish.Update(elapsedTime))
                {
                    SetFish(fish);
                    fish.Controller.CheckCurrentEvent(cmdFish.IsActiveEvent);
                    fish.Controller.PathEvent.m_CurElapsedTime = cmdFish.ElapsedTime * 0.001f;
                    if (cmdFish.Package != 255)
                    {
                        fish.SetPackage(cmdFish.Package);
                    }
                    if (cmdFish.DelayType != (byte)FISH_DELAY_TYPE.DELAY_NONE)
                    {
                        float   scl;
                        float[] dur = new float[3];
                        Utility.ReductionToFloat(cmdFish.DelayScaling, cmdFish.DelayDuration1, cmdFish.DelayDuration2, cmdFish.DelayDuration3,
                                                 out scl, dur);
                        float time = cmdFish.DelayCurrentTime * 0.001f;
                        fish.Controller.TimeController.AddSkillTimeScaling(scl, dur, (FISH_DELAY_TYPE)cmdFish.DelayType, time);
                    }
                }
            }
        }
        else
        {
            float fInv      = SceneRuntime.Inversion ? -1.0f : 1.0f;
            int   pathIndex = cmdFish.PathGroup;
            int   gdIdx     = cmdFish.PathIdx >> 8;
            int   fishIdx   = cmdFish.PathIdx & 0xff;

            PathLinearInterpolator pi = PathManager.Instance.GetPath(pathIndex, SceneRuntime.Inversion);
            if (gdIdx >= gdl.GroupDataArray.Length)
            {
                LogMgr.Log("场景鱼同步,索引超出界限1:" + gdIdx);
                return;
            }
            GroupData gd = gdl.GroupDataArray[gdIdx];
            {
                {
                    Fish fish = new Fish();
                    fish.Init(cmdFish.FishID, gd.FishIndex, gd.FishScaling, cmdFish.FishTime, gd.ActionSpeed, gd.ActionUnite, gd.SpeedScaling, pi);
#if UNITY_EDITOR
                    fish.SetModelName("Fish_FishGroup_" + cmdFish.GroupID + "_Path_" + pathIndex);
#endif
                    if (fish.Update(elapsedTime))
                    {
                        if (fishIdx >= gd.PosList.Length)
                        {
                            LogMgr.Log("场景鱼同步,索引超出界限2:" + gdIdx);
                            return;
                        }
                        fish.SetOffset(new Vector3(0, fInv * gd.PosList[fishIdx].y, gd.PosList[fishIdx].z));
                        SetFish(fish);
                        if (cmdFish.Package != 255)
                        {
                            fish.SetPackage(cmdFish.Package);
                        }
                        fish.Controller.CheckCurrentEvent(cmdFish.IsActiveEvent);
                        fish.Controller.PathEvent.m_CurElapsedTime = cmdFish.ElapsedTime * 0.001f;
                        if (cmdFish.DelayType != (byte)FISH_DELAY_TYPE.DELAY_NONE)
                        {
                            float   scl;
                            float[] dur = new float[3];
                            Utility.ReductionToFloat(cmdFish.DelayScaling, cmdFish.DelayDuration1, cmdFish.DelayDuration2, cmdFish.DelayDuration3,
                                                     out scl, dur);
                            float time = cmdFish.DelayCurrentTime * 0.001f;
                            fish.Controller.TimeController.AddSkillTimeScaling(scl, dur, (FISH_DELAY_TYPE)cmdFish.DelayType, time);
                        }
                    }
                }
            }
        }
    }