コード例 #1
0
        public void SOVarTests()
        {
            const int localStartingVal = 7;
            const int refStartingVal   = 10;
            //create a DataTypeVar
            IntVar intv = new IntVar(localStartingVal);

            //test get and set work without SO backing
            Assert.AreEqual(localStartingVal, intv.Value);
            intv.Value += 1;
            Assert.AreEqual(localStartingVal + 1, intv.Value);
            intv.Value -= 1;
            Assert.AreEqual(localStartingVal, intv.Value);
            //create SO backing
            var intSOBack = IntSO.CreateInstance <IntSO>();

            intSOBack.Value       = refStartingVal;
            intv.SOReferenceValue = intSOBack;
            //test starting value get and set work with backing
            Assert.AreEqual(refStartingVal, intv.Value);
            intv.Value += 1;
            Assert.AreEqual(refStartingVal + 1, intv.Value);
            //removing backing and destroy
            intv.SOReferenceValue = null;
            UnityEngine.Object.DestroyImmediate(intSOBack);
            //test local value remains
            Assert.AreEqual(localStartingVal, intv.Value);
        }
コード例 #2
0
ファイル: IntSO.cs プロジェクト: KhaledYusuf196/Asteroids
 public void SetValue(IntSO integer)
 {
     value = integer.value;
 }
コード例 #3
0
 public void IncrementScore(IntSO HitScoreValue)
 {
     score += HitScoreValue.value;
     HighestScore.value = Mathf.Max(score, HighestScore.value);
     UIUpdateEvent.Fire();
 }