// Update is called once per frame void Update() { if (!Time_Count.game_pause) { if (tree.Count == 0) { Destroy(this); } List <LightningNode> temp = new List <LightningNode>(); foreach (LightningNode n in tree) { if (n.rootNode) { n.rootNode = false; var tags1 = GameObject.FindGameObjectsWithTag("Player"); var tags2 = GameObject.FindGameObjectsWithTag("Enemy"); foreach (GameObject g in tags1) { Vector3 t = g.transform.position - n.transform.position; float distance = Mathf.Sqrt(Mathf.Pow(t.x, 2) + Mathf.Pow(t.y, 2)); if (distance <= 200) { //Player.stats.change_shield((-1) * Player.stats.get_shield() + 10); ///Player p= g.GetComponent<Player>(); } } int count = 0; foreach (GameObject g in tags2) { Vector3 t = g.transform.position - n.transform.position; float distance = Mathf.Sqrt(Mathf.Pow(t.x, 2) + Mathf.Pow(t.y, 2)); if (distance <= 200) { LightningNode x = new LightningNode(); x.enemy = g; count++; temp.Add(x); } if (count == 2) { break; } } } } foreach (LightningNode x in temp) { tree.Add(x); } } }
// Update is called once per frame void Update () { if (!Time_Count.game_pause) { if (tree.Count == 0) { Destroy(this); } List<LightningNode> temp = new List<LightningNode>(); foreach (LightningNode n in tree) { if (n.rootNode) { n.rootNode = false; var tags1 = GameObject.FindGameObjectsWithTag("Player"); var tags2 = GameObject.FindGameObjectsWithTag("Enemy"); foreach (GameObject g in tags1) { Vector3 t = g.transform.position - n.transform.position; float distance = Mathf.Sqrt(Mathf.Pow(t.x, 2) + Mathf.Pow(t.y, 2)); if (distance <= 200) { //Player.stats.change_shield((-1) * Player.stats.get_shield() + 10); ///Player p= g.GetComponent<Player>(); } } int count = 0; foreach (GameObject g in tags2) { Vector3 t = g.transform.position - n.transform.position; float distance = Mathf.Sqrt(Mathf.Pow(t.x, 2) + Mathf.Pow(t.y, 2)); if (distance <= 200) { LightningNode x = new LightningNode(); x.enemy = g; count++; temp.Add(x); } if (count == 2) { break; } } } } foreach (LightningNode x in temp) { tree.Add(x); } } }
static void Main(string[] args) { string localPrivateKey = "<node private key>"; ECKeyPair localLightningKey = new ECKeyPair(localPrivateKey, true); string walletSeed = "<wallet private key>"; ECKeyPair walletKey = new ECKeyPair(walletSeed, true); LightningNode node = new LightningNode(localLightningKey, walletKey, NetworkParameters.BitcoinTestnet); node.ConfigureServices(services => { services.AddSingleton <IBlockchainClientService, BitcoindClientService>(); services.AddLogging(logging => logging.SetMinimumLevel(LogLevel.Debug) .AddConsole(options => options.IncludeScopes = false) .AddDebug() .AddFilter("Microsoft.EntityFrameworkCore", LogLevel.Warning)); services.AddDbContext <NetworkPersistenceContext>(options => options.UseSqlite("Data Source=network.db")); services.AddDbContext <LocalPersistenceContext>(options => options.UseSqlite("Data Source=local.db")); }); node.Initialize(); // Peer Service: var peerService = node.Services.GetService <IPeerService>(); // Channel Service: var channels = node.Services.GetService <IChannelService>(); // Channel Establishment Service: var channelEstablishmentService = node.Services.GetService <IChannelEstablishmentService>(); // Channel State Service: var channelStateService = node.Services.GetService <IChannelStateService>(); // Channel Close Service var closeService = node.Services.GetService <IChannelCloseService>(); channelEstablishmentService.FailureProvider.Subscribe(peerAndPendingChannel => { // Failed to open a channel }); channelEstablishmentService.SuccessProvider.Subscribe(peerAndPendingChannel => { // Opened a channel }); channelStateService.ChannelActiveStateChangedProvider .Where(c => c.Active) .Subscribe(channel => { // Channel is active }); NodeAddress nodeAddress = NodeAddress.Parse("<pubkey@ip:port>"); // Connect to node: IPeer peer = peerService.AddPeer(nodeAddress, persist: false, reconnect: true); // Open a channel with 25000 satoshis capacity channelEstablishmentService.OpenChannel(peer, 25000); System.Console.ReadKey(); }
public void addNode(LightningNode n) { tree.Add(n); }