static void Postfix() { players.ForEach((ServerRoundPlayer serverRoundPlayer) => { Vector3 position = serverRoundPlayer.PlayerTransform.position; List <int> ids = new List <int>(); for (int i = 0; i < maxBot; i++) { ids.Add(Framework.addCarbonPlayer("test01")); } ids.ForEach((id) => { position.z += 1; Framework.CarbonPlayer player = Framework.getCarbonPlayer(id); player.spawn(serverRoundPlayer.PlayerStartData.Faction, PlayerClass.ArmyLineInfantry); posCache.Add(id, position); }); if (playerToBot.ContainsKey(serverRoundPlayer.NetworkPlayerID)) { playerToBot.Remove(serverRoundPlayer.NetworkPlayerID); } playerToBot.Add(serverRoundPlayer.NetworkPlayerID, ids); }); players.Clear(); }
private static void spawnTarget(FactionCountry faction, Vector3 position, Vector3 forward, int distance, int num) { if (!posList.ContainsKey(faction)) { posList.Add(faction, new Queue <Vector3>()); } Vector3 center = position + forward.normalized * distance; Vector3 forward_hoz = Quaternion.Euler(0, 90, 0) * forward.normalized; for (int i = 0; i < num; i++) { Vector3 item; if (i % 2 == 0) { item = center + ((i / 2) + 1) * forward_hoz.normalized; } else { item = center - (i / 2) * forward_hoz.normalized; } item.y = vectorAngle(new Vector2(position.x, position.y), new Vector2(item.x, item.y)); posList[faction].Enqueue(item); } posList.ToDfList().ForEach((KeyValuePair <FactionCountry, Queue <Vector3> > pair) => { pair.Value.ToDfList().ForEach((Vector3 pos) => { int id = Framework.addCarbonPlayer("靶标机器人"); botList.Add(id); Framework.CarbonPlayer player = Framework.getCarbonPlayer(id); player.spawn(pair.Key, PlayerClass.ArmyLineInfantry); }); }); }