Example #1
0
    Fishing_Fish[] CreatFish(byte fishTypeId, FishingPathData pd, Transform parent, PathManager pm, uint fishId, int count, float passTime, byte group, byte index)
    {
        if (!Fishing_Data.GetInstance().m_FishData.ContainsKey(fishTypeId))
        {
            DebugLog.LogError("fish:" + fishTypeId + " data is error!!");
            return(null);
        }

        FishingFishData fd     = Fishing_Data.GetInstance().m_FishData[fishTypeId];
        GameObject      prefab = (GameObject)m_GameBase.FishingAssetBundle.LoadAsset(fd.m_szFish);

        int arrayCount = pd.m_Offsets.Count > 0 ? pd.m_Offsets.Count : 1;

        Debug.Assert(count != 0 && count <= arrayCount, "create fish count wrong!!");

        Fishing_Fish[] fishs = new Fishing_Fish[count];
        for (uint j = 0; j < count; j++)
        {
            GameObject go = (GameObject)GameMain.instantiate(prefab);
            go.transform.SetParent(parent, false);
            splineMove sm = go.AddComponent <splineMove>();
            sm.local            = true;
            sm.lookAhead        = 0.01f;
            sm.forwardDir       = Vector3.right;
            sm.pathMode         = PathMode.Ignore;
            sm.offset           = index < pd.m_Offsets.Count ? pd.m_Offsets[index] : Vector3.zero;
            sm.waypointRotation = (fd.m_nRotType == 1) ? splineMove.RotationType.all : splineMove.RotationType.none;
            if (m_GameBase.IsMirror())
            {
                sm.eulerAngles = (fd.m_nRotType == 1) ? new Vector3(180f, 0f, 0f) : new Vector3(0f, 0f, 180f);
            }
            else
            {
                sm.eulerAngles = Vector3.zero;
            }
            sm.speed    = fd.m_GroupSpeed[group];
            sm.loopType = pd.m_bLoop ? splineMove.LoopType.loop : splineMove.LoopType.none;
            sm.SetPath(pm);
            sm.GoTo(GetPathPassTime(passTime, sm, pd));

            if (FishPause)
            {
                sm.Pause();
            }

            Fishing_Fish fish = go.transform.Find("skin").gameObject.AddComponent <Fishing_Fish>();
            fish.Init(m_GameBase, sm, fishId + j, fishTypeId);
            fish.OnDeath += RemoveFish;
            fishs[j]      = fish;
            m_FishDict.Add(fish.m_nOnlyId, fish);
        }
        return(fishs);
    }