void RemoveFish(Fishing_Fish fish) { if (!m_PathFishList.ContainsKey(fish.m_SplineMove.pathContainer)) { return; } PathManager pm = fish.m_SplineMove.pathContainer; PathInfo pi = m_PathFishList[pm]; if (!pi.fishList.Contains(fish)) { return; } m_FishDict.Remove(fish.m_nOnlyId); pi.fishList.Remove(fish); GameObject.Destroy(fish.transform.parent.gameObject); if (pi.fishList.Count == 0) { RemovePath(pm); } }
int SortByMultiple(Fishing_Fish a, Fishing_Fish b)//按倍率从大到小排列 { FishingFishData dataA = Fishing_Data.GetInstance().m_FishData[a.m_nTypeId]; FishingFishData dataB = Fishing_Data.GetInstance().m_FishData[b.m_nTypeId]; return(dataB.m_nMultiple - dataA.m_nMultiple); }
public void OnCatch(uint fishId, long reward, long leftCoin, FishType_Enum fishType = FishType_Enum.FishType_Init, byte getSkillId = 0, int specialId = 0) { UpdateInfoUI(leftCoin); Fishing_Fish fish = GameBase.FishMgr.GetFishById(fishId); if (fish != null) { fish.OnCatch(m_Cannon, IsLocal(), reward, fishType, getSkillId, specialId); } }
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); }
public void OtherFire(float angle, byte num, long coin, uint lockId) { UpdateInfoUI(coin); Fishing_Fish fish = GameBase.FishMgr.GetFishById(lockId); ChangeLockFish(fish); if (m_nIndex > 1) { angle = 180f - angle; } m_Cannon.OtherFire(angle, num, fish == null ? null : fish.gameObject); }
void OnHit(GameObject obj, Vector3 hitpoint, Canvas cv) { Fishing_Fish fish = obj.GetComponent <Fishing_Fish>(); if (fish == null) { return; } Destroy(gameObject); GameObject prefab = (GameObject)OwnerCannon.BelongRole.GameBase.FishingAssetBundle.LoadAsset(m_szNet); Vector3 pos = GameFunction.WorldToLocalPointInRectangle(hitpoint, Camera.main, cv, cv.worldCamera); Transform root = cv.transform.Find("Root"); GameObject explosion = (GameObject)Instantiate(prefab, pos, Quaternion.identity); explosion.transform.SetParent(root, false); OwnerCannon.BelongRole.GameBase.m_AddItems.Add(explosion); prefab = (GameObject)OwnerCannon.BelongRole.GameBase.FishingAssetBundle.LoadAsset("FishHit"); GameObject bubble = (GameObject)Instantiate(prefab, pos, Quaternion.identity); bubble.transform.SetParent(root, false); OwnerCannon.BelongRole.GameBase.m_AddItems.Add(bubble); GameMain.WaitForCall(1f, () => { OwnerCannon.BelongRole.GameBase.m_AddItems.Remove(explosion); Destroy(explosion); OwnerCannon.BelongRole.GameBase.m_AddItems.Remove(bubble); Destroy(bubble); }); bool bLocal = m_Id != 0; fish.OnHit(bLocal); if (bLocal)//local player send { UMessage msg = new UMessage((uint)GameCity.EMSG_ENUM.CCMsg_FISHING_CM_FIRERESULT); msg.Add(GameMain.hall_.GetPlayerId()); msg.Add(fish.m_nOnlyId); msg.Add(m_Id); HallMain.SendMsgToRoomSer(msg); } }
public void ChangeLockFish(Fishing_Fish fish) { if (fish == null) { return; } if (LockFish != null) { LockFish.Unlock(m_nIndex); } LockFish = fish; LockFish.Lock(m_nIndex); if (IsLocal()) { UMessage msg = new UMessage((uint)GameCity.EMSG_ENUM.CCMsg_FISHING_CM_TRACECHANGETARGET); msg.Add(GameMain.hall_.GetPlayerId()); msg.Add(LockFish.m_nOnlyId); HallMain.SendMsgToRoomSer(msg); } }
IEnumerator PopCoin(Fishing_Fish fish, FishingFishData fd, bool bLocal, long getCoin, Vector3 center, Vector3 targetPos, byte getSkillId) { //DebugLog.Log("num:" + num + " center:" + center + " target:" + targetPos); if (getCoin <= 0) { yield break; } CGame_Fishing game = fish.m_CatchRole.GameBase; AssetBundle ab = game.FishingAssetBundle; Canvas cv = game.GameCanvas; Transform root = cv.transform.Find("Root"); GameObject prefab; GameObject big = null; if (fd.m_nMultiple >= 20) { prefab = (GameObject)ab.LoadAsset("FishCoin_big"); big = ((GameObject)GameMain.instantiate(prefab)); big.transform.SetParent(root, false); big.transform.localPosition = center; game.m_AddItems.Add(big); Camera.main.DOShakePosition(1f, 1f).OnComplete(() => { Camera.main.transform.position = game.CameraSourcePos; }); CustomAudioDataManager.GetInstance().PlayAudio(1004); } else { CustomAudioDataManager.GetInstance().PlayAudio(1003); } yield return(new WaitUntil(() => m_bDeathEnd)); Transform effectTfm = fish.transform.parent.Find("Effect"); if (effectTfm != null) { effectTfm.DOScale(Vector3.zero, 1f); } fish.transform.parent.DOScale(Vector3.zero, 1f); prefab = (GameObject)ab.LoadAsset(bLocal ? "Text_HurtNum" : "Text_HurtNum_other"); GameObject textObj = ((GameObject)GameMain.instantiate(prefab)); textObj.transform.SetParent(root.Find("HurtNum"), false); textObj.transform.localPosition = center; textObj.transform.localScale = Vector3.zero; textObj.transform.GetComponent <Text>().text = GameFunction.FormatCoinText(getCoin, true, false); game.m_AddItems.Add(textObj); textObj.transform.DOScale(new Vector3(1f, 1f, 1f), 0.5f).OnComplete(() => { textObj.transform.DOScale(new Vector3(1f, 1f, 1f), 0.5f).OnComplete(() => { game.m_AddItems.Remove(textObj); Destroy(textObj); }); }); bool bCoin = true; if (getSkillId > 0 && bLocal) { if (getSkillId == RoomInfo.NoSit)//lottery { prefab = (GameObject)ab.LoadAsset("Skill_Ticket"); bCoin = false; } else { prefab = (GameObject)ab.LoadAsset("Skill_" + getSkillId); } if (prefab != null) { GameObject skillObj = Instantiate(prefab); skillObj.transform.SetParent(root, false); skillObj.transform.localPosition = center; game.m_AddItems.Add(skillObj); skillObj.transform.DOLocalMove(center + new Vector3(0, 100f, 0f), 1f).OnComplete(() => { game.m_AddItems.Remove(skillObj); Destroy(skillObj); }); } } if (bCoin) { int num = Mathf.CeilToInt((float)fd.m_nMultiple / 5) + 2; float radius = (num - 1) * 10f; float halfPi = Mathf.PI * 0.5f; float angle; prefab = (GameObject)ab.LoadAsset("FishCoin"); GameObject coin; Vector3 pos; List <GameObject> coinList = new List <GameObject>(); for (int i = 0; i < num; i++) { angle = Random.Range(0f, halfPi) * 4f; coin = ((GameObject)GameMain.instantiate(prefab)); coin.transform.SetParent(root, false); coin.transform.localPosition = center; pos = center + new Vector3(Mathf.Sin(angle), Mathf.Cos(angle)) * Random.Range(0f, radius); coin.transform.DOLocalMove(pos, 0.5f); //DebugLog.Log(i + ": angle:" + angle + " pos:" + pos); coinList.Add(coin); game.m_AddItems.Add(coin); yield return(new WaitForEndOfFrame()); } yield return(new WaitForSecondsRealtime(1f)); CustomAudioDataManager.GetInstance().PlayAudio(1002); float flyTime = 0.5f; foreach (GameObject obj in coinList) { if (obj == null) { continue; } Vector3 dir = targetPos - obj.transform.localPosition; Vector3 speed = new Vector3(dir.x / flyTime, 0f); float a = dir.y * 2f / (flyTime * flyTime); DOTween.To(() => obj.transform.localPosition, r => { obj.transform.localPosition += (speed * Time.unscaledDeltaTime); speed.y = speed.y + a * Time.unscaledDeltaTime; }, targetPos, flyTime); } yield return(new WaitForSecondsRealtime(flyTime)); foreach (GameObject obj in coinList) { if (obj == null) { continue; } game.m_AddItems.Remove(obj); Destroy(obj); } } if (big != null) { game.m_AddItems.Remove(big); Destroy(big); } }