diff --git a/Assets/Scipts/IPGrabber.cs b/Assets/Scipts/IPGrabber.cs new file mode 100644 index 0000000..de03b0d --- /dev/null +++ b/Assets/Scipts/IPGrabber.cs @@ -0,0 +1,55 @@ +using System.Net; +using System.Net.NetworkInformation; +using System.Net.Sockets; + +public class IPGrabber{ + + public static string GetIP(ADDRESSFAM Addfam) + { + //Return null if ADDRESSFAM is Ipv6 but Os does not support it + if (Addfam == ADDRESSFAM.IPv6 && !Socket.OSSupportsIPv6) + { + return null; + } + + string output = ""; + + foreach (NetworkInterface item in NetworkInterface.GetAllNetworkInterfaces()) + { +#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN + NetworkInterfaceType _type1 = NetworkInterfaceType.Wireless80211; + NetworkInterfaceType _type2 = NetworkInterfaceType.Ethernet; + + if ((item.NetworkInterfaceType == _type1 || item.NetworkInterfaceType == _type2) && item.OperationalStatus == OperationalStatus.Up) +#endif + { + foreach (UnicastIPAddressInformation ip in item.GetIPProperties().UnicastAddresses) + { + //IPv4 + if (Addfam == ADDRESSFAM.IPv4) + { + if (ip.Address.AddressFamily == AddressFamily.InterNetwork) + { + output = ip.Address.ToString(); + } + } + + //IPv6 + else if (Addfam == ADDRESSFAM.IPv6) + { + if (ip.Address.AddressFamily == AddressFamily.InterNetworkV6) + { + output = ip.Address.ToString(); + } + } + } + } + } + return output; + } +} + +public enum ADDRESSFAM +{ + IPv4, IPv6 +} \ No newline at end of file diff --git a/Assets/Scipts/IPGrabber.cs.meta b/Assets/Scipts/IPGrabber.cs.meta new file mode 100644 index 0000000..5e800b8 --- /dev/null +++ b/Assets/Scipts/IPGrabber.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7e05bab93a1df3449a51fe90e3551589 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scipts/Map.cs b/Assets/Scipts/Map.cs index 4236797..9394682 100644 --- a/Assets/Scipts/Map.cs +++ b/Assets/Scipts/Map.cs @@ -14,7 +14,7 @@ public class Map : MonoBehaviour public int TileSize = 100; public Vector2 MapDimensions; - public List VeggieLocations; + public List Veggies; //Minimum and maximum values for the map public float minX; public float maxX;