public int AreaBombOddLimit = 300; //炸弹倍数限制,超过倍数之后的鱼不参与赔率计算 public override int GetFishOddBonus(Bullet bullet) { var bulletTs = bullet.transform; //生成碰撞范围 var results = Physics.SphereCastAll(bulletTs.position - Bullet.ColliderOffsetZ, AreaBombRadius, Vector3.forward); //计算是否爆炸 FishAffect = new List <Fish> { this }; var oddTotalForCaclDieratio = 0; //计算死亡几率的倍率 foreach (var hitObj in results) //需要碰撞的鱼 { var tmpFish = hitObj.transform.GetComponent <Fish>(); if (tmpFish != null && tmpFish.Attackable && tmpFish.HittableType == HittableType.Normal) { FishAffect.Add(tmpFish); var otherOddBonus = HitProcessor.GetFishOddBonus(bullet, tmpFish, this);//用于赔率计算; oddTotalForCaclDieratio += otherOddBonus; tmpFish.OddBonus = oddTotalForCaclDieratio; } if (oddTotalForCaclDieratio > AreaBombOddLimit) { break; } } return(oddTotalForCaclDieratio); }
//private List<GameObject>[] mTmpFishGatheredView;//用于显示已收集的鱼 void Awake() { //HitProcessor.FuncGetFishAddtiveForDieRatio += Func_GetFishOddAddtiveForDieRatio; HitProcessor.AddFunc_Odd(Func_GetFishOddAddtiveForDieRatio, null); GameMain.EvtFishKilled += Evt_FishKilled; GameMain.EvtBGClearAllData_Before += Evt_BGClearAllData_Before; //mTmpFishGatheredView = new List<GameObject>[Defines.MaxNumPlayer]; //for (int i = 0; i != mTmpFishGatheredView.Length; ++i) // mTmpFishGatheredView[i] = new List<GameObject>(); Players = GameMain.Singleton.Players; mPrefabNeedGatherFishCache = new Dictionary <int, int>(); for (int i = 0; i != Prefab_GatherFishAry.Length; ++i) { mPrefabNeedGatherFishCache.Add(Prefab_GatherFishAry[i].TypeIndex, i); } //创建PersistentData if (PlayerGatheredFishRecs == null) { PlayerGatheredFishRecs = new PersistentData <uint, uint> [Defines.MaxNumPlayer]; for (int i = 0; i != Defines.MaxNumPlayer; ++i) { PlayerGatheredFishRecs[i] = new PersistentData <uint, uint>("PlayerGatheredFishRecs" + i.ToString()); } } if (PlayerGatheredScore == null) { PlayerGatheredScore = new PersistentData <int, int> [Defines.MaxNumPlayer]; for (int i = 0; i != Defines.MaxNumPlayer; ++i) { PlayerGatheredScore[i] = new PersistentData <int, int>("PlayerGatheredScore" + i.ToString()); } } //创建 PlayerGatheredFish PlayerGatheredFish = new Dictionary <int, object> [Defines.MaxNumPlayer]; //由PlayerGatheredFishRec得出字典PlayerGatheredFish for (int playerIdx = 0; playerIdx != Defines.MaxNumPlayer; ++playerIdx) { PlayerGatheredFish[playerIdx] = new Dictionary <int, object>(); for (int gIdx = 0; gIdx != Prefab_GatherFishAry.Length; ++gIdx)//收集索引 { if (((PlayerGatheredFishRecs[playerIdx].Val >> gIdx) & 1) == 1) { PlayerGatheredFish[playerIdx].Add(gIdx, null); //_tmpAddViewAniFish(gIdx, Players[playerIdx]; } } } }
// Use this for initialization void Start() { if (nameSetAniBulletLizi == null || nameSetAniBulletNor == null || Prefab_AniBullet == null) { Debug.LogError("Module_BulletSplit有变量未赋值"); return; } for (int i = 0; i != ModuleBullet.Fireable.Length; ++i) { ModuleBullet.Fireable[i] = false; } GameMain.EvtPlayerGunFired += Handle_GunFire; HitProcessor.AddFunc_Odd(Func_GetFishDieRatioAddtive, null); }
public Fish[] Prefab_SameTypeBombAffect;//如果是同类鱼炸弹,是炸那个类型的 public override int GetFishOddBonus(Bullet bullet) { var prefabAffects = Prefab_SameTypeBombAffect; var numTypeToBomb = prefabAffects.Length; var fishDicts = new Dictionary <int, Fish> [numTypeToBomb]; var fishTypeIndexMap = GameMain.Singleton.FishGenerator.FishTypeIndexMap; for (var i = 0; i < numTypeToBomb; ++i) { var type = prefabAffects[i].TypeIndex; if (!fishTypeIndexMap.ContainsKey(type)) { continue; } fishDicts[i] = fishTypeIndexMap[type]; } //计算是否爆炸 FishAffect = new List <Fish> { this }; OddBonus = HitProcessor.GetFishOddBonus(bullet, this, this); var oddTotalForCaclDieratio = OddBonus;//fishFirst.Odds * oddMulti + GetFishOddForDieRatio(bulletOwner, b, fishFirst);//用于赔率计算 foreach (var fishDict in fishDicts) { if (fishDict == null) { continue; } foreach (var fKv in fishDict) { var tmpFish = fKv.Value; if (!tmpFish.Attackable || tmpFish.HittableType != HittableType.Normal) { continue; } FishAffect.Add(tmpFish); var otherOddBonus = HitProcessor.GetFishOddBonus(bullet, tmpFish, this); tmpFish.OddBonus = otherOddBonus; oddTotalForCaclDieratio += otherOddBonus; } } return(oddTotalForCaclDieratio); }
private Dictionary <int, Fish> mSlayFishCache; //可被杀死鱼cache,与Prefab_SlayFish关联 void Awake() { //HitProcessor.FuncGetFishAddtiveForDieRatio += Func_GetFishOddAddtiveForDieRatio; HitProcessor.AddFunc_Odd(Func_GetFishOddAddtiveForDieRatio, null); /*GameMain.EvtFishKilled += Event_FishKilled; * GameMain.EvtMainProcessFinishPrelude += Event_MainProcess_FinishPrelude; * GameMain.EvtMainProcessFirstEnterScene += Event_MainProcess_FirstEnterScene; * GameMain.EvtBgClearAllDataBefore += Event_BackGroundClearAllData_Before;*///adq DragonSlayerScores = new PersistentData <int, int> [Defines.MaxNumPlayer]; for (int i = 0; i != Defines.MaxNumPlayer; ++i) { DragonSlayerScores[i] = new PersistentData <int, int>("DragonSlayerScores" + i.ToString()); } foreach (Fish f in Prefab_SlayFish) { RandomOddsNum rndOdd = f.GetComponent <RandomOddsNum>(); if (rndOdd != null) { mSlayFishAveragyOdd += (rndOdd.MinOdds + rndOdd.MaxOdds) / 2; } else { mSlayFishAveragyOdd += f.Odds; } } mSlayFishCache = new Dictionary <int, Fish>(); foreach (Fish f in Prefab_SlayFish) { mSlayFishCache.Add(f.TypeIndex, f); } mSlayFishAveragyOdd /= Prefab_SlayFish.Length; //GenerateDragonSlayer(0); }
void OnTriggerEnter(Collider other) { if (mIsDestroyed) { return; } Fish fishFirst = other.GetComponent <Fish>();//被子弹击中的鱼 if (fishFirst == null) { Debug.LogError("Fish在这里不可能是null!"); return; } if (IsLockingFish && mTargetFish != null && mTargetFish.ID != fishFirst.ID)//锁目标 { return; } HitProcessor.ProcessHit(this, fishFirst); }
public virtual void ParseHookCollisionData(Player player, RaycastHit2D[] col, List <Type> targets, HitProcessor action) { foreach (RaycastHit2D i in col) { if (null != i.transform.gameObject.GetComponent <Identifier>()) { LiveEntity target = i.transform.gameObject.GetComponent <Identifier>().linkedScript; //TODO: DO THIS BETTER LATER 2 (REPLACE GETTYPE with getsubclass or something) if (targets.Contains(target.GetType())) { action(player, target, i); //hookStatesList.Last().ProcessHookHit(this, target, i); } } ; } }
// Use this for initialization void Start() { HitProcessor.AddFunc_Odd(Func_GetFishOddAdditive, Func_GetFishOddAdditive); }
/// <summary> /// 碰鱼事件 /// </summary> /// <param name="killer"></param> /// <param name="fish"></param> /// <param name="bulletScore"></param> /// <param name="rate"></param> /// <param name="isLockFishBullet"></param> /// <param name="reward"></param> protected virtual void OnHitFishEvent(Player killer, Fish fish, int bulletScore, int rate, bool isLockFishBullet, int reward) { HitProcessor.HitFishEvent(killer, this, bulletScore, rate, isLockFishBullet); }
public virtual int GetFishOddBonus(Bullet bullet) { OddBonus = HitProcessor.GetFishOddBonus(bullet, this, this);; //显示倍率 return(OddBonus); }