Пример #1
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;
                        }
                    }
                }
            }
        }
Пример #2
0
 public static float ComputeZScaling(Fish fish, float scaling)
 {
     return(Mathf.Max(1.0f, (fish.Position.z / 1000)) * scaling);
 }
Пример #3
0
        public void ShowGoldEffect(CatchedData cd, Fish fish)
        {
            if (MatchJudge.IsMatch() && cd.ClientSeat != SceneRuntime.MyClientSeat)//比赛只显示自己的效果
            {
                return;
            }
            Vector3 vecGoldEndpos = Vector3.one;

            if (MatchJudge.IsMatch())//比赛
            {
                if (cd.ClientSeat == SceneRuntime.MyClientSeat)
                {
                    //vecGoldEndpos = GlobalHallUIMgr.Instance.MatchScorePos();
                }
                else
                {
                    vecGoldEndpos = SceneRuntime.GetLauncherGoldIconPos(cd.ClientSeat);
                }
            }
            else
            {
                vecGoldEndpos = SceneRuntime.GetLauncherGoldIconPos(cd.ClientSeat);
            }

            const int perGoldNum = 30;
            //这里的金币用的还是鱼的类型
            Vector3 FishPos = UIManager.Instance.WordToScenePoint(fish.Position);
            //鱼的价值
            uint fishOrgGold = (uint)FishSetting.FishDataList[fish.FishType].Gold;
            uint fishGold    = 0;

            if (cd.CatchType == (byte)CatchedType.CATCHED_SKILL)
            {
                fishGold = fishOrgGold * SkillSetting.SkillDataList[cd.SubType].multiple;
            }
            else
            {
                fishGold = fishOrgGold * BulletSetting.BulletRate[cd.RateIndex];
            }


            if (!MatchJudge.IsMatch() && cd.ClientSeat == SceneRuntime.MyClientSeat)
            {
                //GlobalHallUIMgr.Instance.GameShare.AddGlod((int)fishGold);
            }


            uint goldNum = fishOrgGold / perGoldNum;
            uint perNum  = 0;
            uint lastNum = 0;

            if (goldNum == 0)
            {
                goldNum = 1;
                lastNum = fishGold;
            }
            else
            {
                perNum  = fishGold / goldNum;
                lastNum = perNum + (fishGold - perNum * goldNum);
            }
            uint num = 0;

            for (byte i = 0; i < goldNum; ++i)
            {
                GoldEffectData ged = new GoldEffectData();
                ged.catchedData = cd;

                if (MatchJudge.IsMatch())
                {
                    ged.GameObj = Initobj(m_ScoreObj);
                }
                else
                {
                    ged.GameObj = Initobj(m_GoldObj);
                }

                ged.GameObj.transform.position = FishPos + (new Vector3(Utility.RandFloat() * 100, Utility.RandFloat(), 0)) * (fish.IsBossFish() ? 0.45f : 0.15f);
                //ged.m_Tween.m_Pos = ged.GameObj.transform.GetComponents<DOTweenAnimation>()[0];
                //ged.m_Tween.m_Sclae = ged.GameObj.transform.GetComponents<DOTweenAnimation>()[1];

                ged.ScaleGoldTR(1.0f, fish.IsBossFish() ? 1.0f : 0.6f);
                if (i > 0 && !fish.IsBossFish())
                {
                    ged.m_DelayTime += i * 0.1f;
                }
                if (fish.IsBossFish())
                {
                    ged.m_DelayTime = 1.5f;
                }

                if (i == goldNum - 1)
                {
                    ged.GoldNum = lastNum;
                }
                else
                {
                    ged.GoldNum = perNum;
                }
                num           += ged.GoldNum;
                ged.ClientSeat = cd.ClientSeat;
                ged.PlayTween(true);
                ged.m_vecpathend = vecGoldEndpos;

                DOTween.To(() => ged.GameObj.transform.position, r => ged.GameObj.transform.position = r, vecGoldEndpos, 0.5f).SetDelay(1 + i * 0.1f).OnComplete(() =>
                {
                    ged.DsetorySelf();
                }
                                                                                                                                                                 );
            }
            ShowGoldNumLabel(fishGold, FishPos, fish);
        }
Пример #4
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);
                            }
                        }
                    }
                }
            }
        }