private void OnAirdrop(object o, ElapsedEventArgs e) { AirdropTimer.Interval = Rand.Next(cf.MinIntervalSec, cf.MaxIntervalSec + 1); if (Provider.clients.Count < cf.MinPlayers) { return; } int max = cf.VanillaDropWeight + cf.CustomDropWeight + cf.RandomDropWeight + cf.VehicleDropWeight; int rnd = Rand.Next(0, max); AirdropType typ = GetAirdropType(rnd); Vector3 point = GetAirdropPos(typ); Vector3 vector = Vector3.zero; float speed = Provider.modeConfigData.Events.Airdrop_Speed; if (UnityEngine.Random.value < 0.5f) { vector.x = (Level.size / 2) * -Mathf.Sign(point.x); vector.z = UnityEngine.Random.Range(0, (int)(Level.size / 2)) * -Mathf.Sign(point.z); } else { vector.x = UnityEngine.Random.Range(0, (int)(Level.size / 2)) * -Mathf.Sign(point.x); vector.z = (Level.size / 2) * -Mathf.Sign(point.z); } point.y = 0f; Vector3 normalized = (point - vector).normalized; vector += normalized * -2048f; float delay = (point - vector).magnitude / speed; vector.y = 1024f; float force = Provider.modeConfigData.Events.Airdrop_Force; CustomAirdropInfo airdropInfo = new CustomAirdropInfo { State = vector, Direction = normalized, Speed = speed, Force = force, Delay = delay, FinalPos = point }; Airdrops.Add(airdropInfo); LevelManager.instance.channel.send("tellAirdropState", ESteamCall.OTHERS, ESteamPacket.UPDATE_RELIABLE_BUFFER, vector, normalized, speed, force, delay); }
public static Vector3 GetAirdropPos(AirdropType type) { LocationType locType; int max = cf.AirdropNodeWeight + cf.NamedLocationsWeight + cf.RandomLocationWeight; int weight = Rand.Next(0, max); if (weight < cf.AirdropNodeWeight) { locType = LocationType.Normal; } weight -= cf.AirdropNodeWeight; if (weight < cf.NamedLocationsWeight) { locType = LocationType.Node; } locType = LocationType.Random; Vector3 locPos = Vector3.zero; string locName; switch (locType) { case LocationType.Normal: { Node node = LevelNodes.nodes.Where(n => n.type == ENodeType.AIRDROP).OrderBy(n => Rand.Next()) .First(); locPos = node.point; locName = null; break; } case LocationType.Node: { Node node = LevelNodes.nodes.Where(n => n.type == ENodeType.LOCATION).OrderBy(n => Rand.Next()) .First(); locPos = node.point; locName = ((LocationNode)node).name; break; } case LocationType.Random: { int maxS = Level.size / 2; int minS = -Level.size / 2; int x = Rand.Next(minS, maxS); int z = Rand.Next(minS, maxS); Vector3 vec = new Vector3(x, 2048, z); Physics.Raycast(vec, Vector3.down, out RaycastHit hit, 4096, RayMasks.GROUND); locPos = hit.point; break; } } return(locPos); }
public static List <AirdropItem> GetAirdropItems(AirdropType type) { List <AirdropItem> finItems = new List <AirdropItem>(); switch (type) { case AirdropType.Normal: { for (int i = 0; i < 8; i++) { ushort num = SpawnTableTool.resolve(1374); if (num == 0) { break; } finItems.Add(new AirdropItem() { amount = 1, durability = 100, id = num }); } break; } case AirdropType.Custom: { int max = cf.CustomItemBatches.Sum(b => b.weight); int rnd = Rand.Next(0, max); ItemBatch finalBatch = null; foreach (ItemBatch b in cf.CustomItemBatches) { if (rnd < b.weight) { finalBatch = b; break; } rnd -= b.weight; } finItems = finalBatch.items; break; } case AirdropType.Random: { int max = cf.RandomItemBatches.Sum(b => b.weight); for (int i = cf.MinRandomItems; i <= cf.MaxRandomItems; i++) { int rnd = Rand.Next(0, max); foreach (RandomItem r in cf.RandomItemBatches) { if (rnd < r.weight) { finItems.Add(new AirdropItem() { amount = r.amount, durability = r.durability, id = r.id }); break; } rnd -= r.weight; } } break; } case AirdropType.Vehicle: finItems = null; break; } return(finItems); }