private void ApplyCurrentLevelStatsToNewMiner(GameObject newMiner) { MinerBehavior newMinerBehavior = newMiner.GetComponent <MinerBehavior> (); newMinerBehavior.carryCapacity *= currentTotalCarryCapacityMultiplier; newMinerBehavior.loadSpeedPerSecond *= currentTotalLoadSpeedMultiplier; }
private void IncreaseAllMinerStats() { foreach (GameObject miner in allMinersOnThisMine) { MinerBehavior minerBehavior = miner.GetComponent <MinerBehavior> (); minerBehavior.carryCapacity *= carryCapacityMultiplierPerLevel; minerBehavior.loadSpeedPerSecond *= loadSpeedMultiplierPerLevel; } }
public async Task Connect(NetworkInfo networkInfo) { IPAddress ipAddress = null; WireSerialization.Instance.Magic = networkInfo.Magic; NodeServerTrace.Information($"Magic is {networkInfo.Magic}"); var natManager = new NATManager(networkInfo.DefaultPort); #if DEBUG if (networkInfo.IsLANHost) { ipAddress = natManager.InternalIPAddress ?? IPAddress.Loopback; networkInfo.PeersToFind = 0; } else if (networkInfo.IsLANClient) { var ipAddressStr = (natManager.InternalIPAddress ?? IPAddress.Loopback).ToString(); networkInfo.PeersToFind = 1; if (networkInfo.Seeds.Count == 0 && !networkInfo.Seeds.Contains(ipAddressStr)) { networkInfo.Seeds.Add(ipAddressStr); } } else #endif if (!string.IsNullOrEmpty(networkInfo.ExternalIPAddress)) { ipAddress = IPAddress.Parse(networkInfo.ExternalIPAddress); } else if (networkInfo.DisableUPnP) { StatusMessageProducer.OutboundStatus = OutboundStatusEnum.Disabled; } else { StatusMessageProducer.OutboundStatus = OutboundStatusEnum.Initializing; await natManager.Init(); if (natManager.DeviceFound && natManager.Mapped.Value && natManager.ExternalIPVerified.HasValue && natManager.ExternalIPVerified.Value) { StatusMessageProducer.OutboundStatus = OutboundStatusEnum.HasValidAddress; ipAddress = natManager.ExternalIPAddress; } else { StatusMessageProducer.OutboundStatus = OutboundStatusEnum.HasInvalidAddress; } } _BroadcastHubBehavior = new BroadcastHubBehavior(); _MinerBehavior = new MinerBehavior(); _NodeConnectionParameters.TemplateBehaviors.Add(_BroadcastHubBehavior); _NodeConnectionParameters.TemplateBehaviors.Add(_MinerBehavior); _NodeConnectionParameters.TemplateBehaviors.Add(new SPVBehavior(_BlockChain, _BroadcastHubBehavior.BroadcastHub)); _NodeConnectionParameters.TemplateBehaviors.Add(new ChainBehavior(_BlockChain)); AddressManagerBehavior.GetAddrman(_NodeConnectionParameters).PeersToFind = networkInfo.PeersToFind; if (ipAddress != null) { _NodeConnectionParameters.TemplateBehaviors.Find <AddressManagerBehavior>().Mode = AddressManagerBehaviorMode.AdvertizeDiscover; //parameters.Advertize = true; _NodeConnectionParameters.AddressFrom = new System.Net.IPEndPoint(ipAddress, networkInfo.DefaultPort); } else { _NodeConnectionParameters.TemplateBehaviors.Find <AddressManagerBehavior>().Mode = AddressManagerBehaviorMode.Discover; } if (ipAddress != null) { _Server = new Server(ipAddress, networkInfo, _NodeConnectionParameters); OwnResource(_Server); if (_Server.Start()) { NodeServerTrace.Information($"Server started at {ipAddress}:{networkInfo.DefaultPort}"); StatusMessageProducer.OutboundStatus = OutboundStatusEnum.Accepting; } else { NodeServerTrace.Information($"Could not start server at {ipAddress}:{networkInfo.DefaultPort}"); } } if (networkInfo.Seeds.Count == 0) { NodeServerTrace.Information("No seeds defined"); } else { _NodesGroup = new NodesGroup(networkInfo, _NodeConnectionParameters); OwnResource(_NodesGroup); _NodesGroup.AllowSameGroup = true; //TODO _NodesGroup.MaximumNodeConnection = networkInfo.MaximumNodeConnection; #if TRACE _NodesGroup.ConnectedNodes.Added += (object sender, NodeEventArgs e) => { NodeServerTrace.Information("Peer found: " + e.Node.RemoteSocketAddress + ":" + e.Node.RemoteSocketPort); }; #endif _NodesGroup.Connect(); } }