コード例 #1
0
 /// <summary>
 /// Creates a NetworkDictionary with a custom value and custom settings
 /// </summary>
 /// <param name="settings">The settings to use for the NetworkDictionary</param>
 /// <param name="value">The initial value to use for the NetworkDictionary</param>
 public NetworkDictionary(NetworkVariableSettings settings, IDictionary <TKey, TValue> value)
 {
     Settings     = settings;
     m_Dictionary = value;
 }
コード例 #2
0
 /// <summary>
 /// Creates a NetworkDictionary with the default value and custom settings
 /// </summary>
 /// <param name="settings">The settings to use for the NetworkDictionary</param>
 public NetworkDictionary(NetworkVariableSettings settings)
 {
     Settings = settings;
 }
コード例 #3
0
 /// <summary>
 /// Creates a NetworkList with a custom value and custom settings
 /// </summary>
 /// <param name="settings">The settings to use for the NetworkList</param>
 /// <param name="value">The initial value to use for the NetworkList</param>
 public NetworkList(NetworkVariableSettings settings, IList <T> value)
 {
     Settings = settings;
     m_List   = value;
 }
コード例 #4
0
 /// <summary>
 /// Creates a NetworkList with the default value and custom settings
 /// </summary>
 /// <param name="settings">The settings to use for the NetworkList</param>
 public NetworkList(NetworkVariableSettings settings)
 {
     Settings = settings;
 }
コード例 #5
0
 /// <summary>
 /// Creates a NetworkSet with a custom value and custom settings
 /// </summary>
 /// <param name="settings">The settings to use for the NetworkSet</param>
 /// <param name="value">The initial value to use for the NetworkSet</param>
 public NetworkSet(NetworkVariableSettings settings, ISet <T> value)
 {
     Settings = settings;
     m_Set    = value;
 }
        // Start is called before the first frame update
        private void InitializeTest()
        {
            // Generic Constructor Test Coverage
            m_NetworkVariableBool       = new NetworkVariableBool();
            m_NetworkVariableByte       = new NetworkVariableByte();
            m_NetworkVariableColor      = new NetworkVariableColor();
            m_NetworkVariableColor32    = new NetworkVariableColor32();
            m_NetworkVariableDouble     = new NetworkVariableDouble();
            m_NetworkVariableFloat      = new NetworkVariableFloat();
            m_NetworkVariableInt        = new NetworkVariableInt();
            m_NetworkVariableLong       = new NetworkVariableLong();
            m_NetworkVariableSByte      = new NetworkVariableSByte();
            m_NetworkVariableQuaternion = new NetworkVariableQuaternion();
            m_NetworkVariableShort      = new NetworkVariableShort();
            m_NetworkVariableString     = new NetworkVariableString();
            m_NetworkVariableVector4    = new NetworkVariableVector4();
            m_NetworkVariableVector3    = new NetworkVariableVector3();
            m_NetworkVariableVector2    = new NetworkVariableVector2();
            m_NetworkVariableRay        = new NetworkVariableRay();
            m_NetworkVariableULong      = new NetworkVariableULong();
            m_NetworkVariableUInt       = new NetworkVariableUInt();
            m_NetworkVariableUShort     = new NetworkVariableUShort();


            // NetworkVariable Value Type Constructor Test Coverage
            m_NetworkVariableBool       = new NetworkVariableBool(true);
            m_NetworkVariableByte       = new NetworkVariableByte(0);
            m_NetworkVariableColor      = new NetworkVariableColor(new Color(1, 1, 1, 1));
            m_NetworkVariableColor32    = new NetworkVariableColor32(new Color32(1, 1, 1, 1));
            m_NetworkVariableDouble     = new NetworkVariableDouble(1.0);
            m_NetworkVariableFloat      = new NetworkVariableFloat(1.0f);
            m_NetworkVariableInt        = new NetworkVariableInt(1);
            m_NetworkVariableLong       = new NetworkVariableLong(1);
            m_NetworkVariableSByte      = new NetworkVariableSByte(0);
            m_NetworkVariableQuaternion = new NetworkVariableQuaternion(Quaternion.identity);
            m_NetworkVariableShort      = new NetworkVariableShort(256);
            m_NetworkVariableString     = new NetworkVariableString("My String Value");
            m_NetworkVariableVector4    = new NetworkVariableVector4(new Vector4(1, 1, 1, 1));
            m_NetworkVariableVector3    = new NetworkVariableVector3(new Vector3(1, 1, 1));
            m_NetworkVariableVector2    = new NetworkVariableVector2(new Vector2(1, 1));
            m_NetworkVariableRay        = new NetworkVariableRay(new Ray());
            m_NetworkVariableULong      = new NetworkVariableULong(1);
            m_NetworkVariableUInt       = new NetworkVariableUInt(1);
            m_NetworkVariableUShort     = new NetworkVariableUShort(1);


            // NetworkVariable NetworkVariableSettings Constructor Test Coverage
            var settings = new NetworkVariableSettings();

            settings.ReadPermission     = NetworkVariablePermission.ServerOnly;
            settings.WritePermission    = NetworkVariablePermission.ServerOnly;
            m_NetworkVariableBool       = new NetworkVariableBool(settings);
            m_NetworkVariableByte       = new NetworkVariableByte(settings);
            m_NetworkVariableColor      = new NetworkVariableColor(settings);
            m_NetworkVariableColor32    = new NetworkVariableColor32(settings);
            m_NetworkVariableDouble     = new NetworkVariableDouble(settings);
            m_NetworkVariableFloat      = new NetworkVariableFloat(settings);
            m_NetworkVariableInt        = new NetworkVariableInt(settings);
            m_NetworkVariableLong       = new NetworkVariableLong(settings);
            m_NetworkVariableSByte      = new NetworkVariableSByte(settings);
            m_NetworkVariableQuaternion = new NetworkVariableQuaternion(settings);
            m_NetworkVariableShort      = new NetworkVariableShort(settings);
            m_NetworkVariableString     = new NetworkVariableString(settings);
            m_NetworkVariableVector4    = new NetworkVariableVector4(settings);
            m_NetworkVariableVector3    = new NetworkVariableVector3(settings);
            m_NetworkVariableVector2    = new NetworkVariableVector2(settings);
            m_NetworkVariableRay        = new NetworkVariableRay(settings);
            m_NetworkVariableULong      = new NetworkVariableULong(settings);
            m_NetworkVariableUInt       = new NetworkVariableUInt(settings);
            m_NetworkVariableUShort     = new NetworkVariableUShort(settings);



            // NetworkVariable Value Type and NetworkVariableSettings Constructor Test Coverage
            m_NetworkVariableBool       = new NetworkVariableBool(settings, true);
            m_NetworkVariableByte       = new NetworkVariableByte(settings, 0);
            m_NetworkVariableColor      = new NetworkVariableColor(settings, new Color(1, 1, 1, 1));
            m_NetworkVariableColor32    = new NetworkVariableColor32(settings, new Color32(1, 1, 1, 1));
            m_NetworkVariableDouble     = new NetworkVariableDouble(settings, 1.0);
            m_NetworkVariableFloat      = new NetworkVariableFloat(settings, 1.0f);
            m_NetworkVariableInt        = new NetworkVariableInt(settings, 1);
            m_NetworkVariableLong       = new NetworkVariableLong(settings, 1);
            m_NetworkVariableSByte      = new NetworkVariableSByte(settings, 0);
            m_NetworkVariableQuaternion = new NetworkVariableQuaternion(settings, Quaternion.identity);
            m_NetworkVariableShort      = new NetworkVariableShort(settings, 1);
            m_NetworkVariableString     = new NetworkVariableString(settings, "My String Value");
            m_NetworkVariableVector4    = new NetworkVariableVector4(settings, new Vector4(1, 1, 1, 1));
            m_NetworkVariableVector3    = new NetworkVariableVector3(settings, new Vector3(1, 1, 1));
            m_NetworkVariableVector2    = new NetworkVariableVector2(settings, new Vector2(1, 1));
            m_NetworkVariableRay        = new NetworkVariableRay(settings, new Ray());
            m_NetworkVariableULong      = new NetworkVariableULong(settings, 1);
            m_NetworkVariableUInt       = new NetworkVariableUInt(settings, 1);
            m_NetworkVariableUShort     = new NetworkVariableUShort(settings, 1);



            // Use this nifty class: NetworkVariableHelper
            // Tracks if NetworkVariable changed invokes the OnValueChanged callback for the given instance type
            Bool_Var       = new NetworkVariableHelper <bool>(m_NetworkVariableBool);
            Byte_Var       = new NetworkVariableHelper <byte>(m_NetworkVariableByte);
            Color_Var      = new NetworkVariableHelper <Color>(m_NetworkVariableColor);
            Color32_Var    = new NetworkVariableHelper <Color32>(m_NetworkVariableColor32);
            Double_Var     = new NetworkVariableHelper <double>(m_NetworkVariableDouble);
            Float_Var      = new NetworkVariableHelper <float>(m_NetworkVariableFloat);
            Int_Var        = new NetworkVariableHelper <int>(m_NetworkVariableInt);
            Long_Var       = new NetworkVariableHelper <long>(m_NetworkVariableLong);
            Sbyte_Var      = new NetworkVariableHelper <sbyte>(m_NetworkVariableSByte);
            Quaternion_Var = new NetworkVariableHelper <Quaternion>(m_NetworkVariableQuaternion);
            Short_Var      = new NetworkVariableHelper <short>(m_NetworkVariableShort);
            String_Var     = new NetworkVariableHelper <string>(m_NetworkVariableString);
            Vector4_Var    = new NetworkVariableHelper <Vector4>(m_NetworkVariableVector4);
            Vector3_Var    = new NetworkVariableHelper <Vector3>(m_NetworkVariableVector3);
            Vector2_Var    = new NetworkVariableHelper <Vector2>(m_NetworkVariableVector2);
            Ray_Var        = new NetworkVariableHelper <Ray>(m_NetworkVariableRay);
            Ulong_Var      = new NetworkVariableHelper <ulong>(m_NetworkVariableULong);
            Uint_Var       = new NetworkVariableHelper <uint>(m_NetworkVariableUInt);
            Ushort_Var     = new NetworkVariableHelper <ushort>(m_NetworkVariableUShort);
        }