This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public WaitForFixedUpdate Wait = new WaitForFixedUpdate(); | |
public IEnumerator PhysicsCoroutine() | |
{ | |
while (true) | |
{ | |
yield return Wait; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
using System.Collections; | |
using System.Diagnostics; | |
public class NetworkBuilder | |
{ | |
[MenuItem("Networking/Build and Run Server %#x")] | |
public static void BuildAndRunServer() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NetworkingManager : MonoBehaviour | |
{ | |
public static NetworkingManager Instance; | |
public bool IsServer; | |
public string IpAddress = "127.0.0.1"; | |
public int Port = 8888; | |
public Transform PlayerRootPrefab; | |
public List<NetworkPlayerRecord> Players = new List<NetworkPlayerRecord>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using System; | |
public abstract class NetworkBehaviour<T> : MonoBehaviour where T : INetworkPacket, new() | |
{ | |
public T Packet = new T(); | |
public T LastPacket = new T(); | |
public NetworkingManager Manager; | |
public bool IsEchoEnabled = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class APIExamples : MonoBehaviour | |
{ | |
public int randomColorCount = 5; | |
public Color[] RandomBrightColors; | |
public Color[] RandomPastelColors; | |
public Color[] RandomDarkColors; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
using UnityEngine; | |
using UnityColor32 = UnityEngine.Color32; | |
[Serializable] | |
[StructLayout(LayoutKind.Explicit)] // Tell .net that we know exactly where we want these values | |
public struct Color32 | |
{ | |
[FieldOffset(0)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Degub | |
{ | |
public static void Log(object message) | |
{ | |
Debug.Log(message); | |
} | |
public static void Log(object message, Object context) | |
{ | |
Debug.Log(message, context); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Random random; <- put this in one of your class files (Usually Xna has a Game class? probably that one | |
random = new Random(); <-- In the same file put this somewhere. Xna games tend to have a LoadContent or a Initialize method? that would be a good place. This creates and instance of the Random class. Random is an object that has lots of methods for giving you differnt types of random numbers, like the name suggests! :) | |
var item = myList[random.Next(myList.count)]; <- WHen you want to get the random item. the Next method on Random makes it generate the next random number. Passing in the length/count of the items in your list makes it generate a number thats between 0 and that number. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In PlayerScript: | |
// Sprite direction | |
if (xInput > 0) { | |
transform.rotation = Quaternion.Euler (0, 0, 0); | |
} else if (xInput < 0) { | |
transform.rotation = Quaternion.Euler (0, 180, 0); | |
} | |
// Aiming |