Ejemplo n.º 1
0
    //Function to add Actions to Array


    public void AddEvent(actions action)
    {
        checkpoint = AtomicTags.FindByTag(checkpointTag.Value).GetComponent <SavePoint>();
        if (myActions == null)
        {
            myActions = new actions[checkpoint.hasBeenActivated.Length + 1];
        }

        /*for (int i=checkpoint.numActive+1;i<checkpoint.hasBeenActivated.Length;i++)
         * {
         *      if (!checkpoint.hasBeenActivated[i])
         *      {
         *              events[i] -= action;
         *              events[i] += action;
         *              Debug.Log("Added " + action.GetMethodInfo() +" to checksave " +i);
         *      }
         * }*/


        if (checkpoint.numActive >= myActions.Length)
        {
            Debug.Log("returning empty");
            return;
        }

        Debug.Log(action.GetMethodInfo());
        myActions[checkpoint.numActive + 1] -= action;
        myActions[checkpoint.numActive + 1] += action;
    }
Ejemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     _light1GameObject   = AtomicTags.FindAllByTag(Lights.Value)[0];
     _light1             = _light1GameObject.GetComponent <Light2D>();
     _light2GameObject   = AtomicTags.FindAllByTag(Lights.Value)[1];
     _light2             = _light2GameObject.GetComponent <Light2D>();
     _bigLightGameObject = AtomicTags.FindByTag(BigLight.Value);
     _bLight             = _bigLightGameObject.GetComponent <Light2D>();
     Debug.Log("Bighlight:" + _bigLightGameObject + "   smallight1:" + _light1GameObject + "   smalllight2: " +
               _light2GameObject);
 }
Ejemplo n.º 3
0
    // Start is called before the first frame update
    void Start()
    {
        dialogFirable           = true;
        DeathDialogStatus.Value = 0;

        ChangeTurn();

        Player1 = AtomicTags.FindByTag(Player1Tag.Value);
        Player2 = AtomicTags.FindByTag(Player2Tag.Value);

        _animator = GetComponentInChildren <Animator>();
        _audio    = GetComponent <AudioSource>();
    }
Ejemplo n.º 4
0
 public void InvokeEvent()
 {
     checkpoint = AtomicTags.FindByTag(checkpointTag.Value).GetComponent <SavePoint>();
     //Debug.Log(checkpoint.numActive+1 +" checkpoints are active");
     Debug.Log("a cockroach");
     if (checkpoint.numActive >= 0)
     {
         //Debug.Log("invoke action from set " + checkpoint.numActive );
         //Debug.Log(myActions?[checkpoint.numActive]?.GetMethodInfo());
         Debug.Log("in a bunker");
         myActions?[checkpoint.numActive]?.Invoke();
     }
 }     //on death
Ejemplo n.º 5
0
 void Update()
 {
     Distance.Value = (AtomicTags.FindByTag(TagPlayer2.Value).transform.position - transform.position).magnitude;
 }
Ejemplo n.º 6
0
 private void Start()
 {
     checkpoint = AtomicTags.FindByTag(checkpointTag.Value).GetComponent <SavePoint>();
 }
Ejemplo n.º 7
0
 // Start is called before the first frame update
 void Start()
 {
     P1 = AtomicTags.FindByTag(TagP1.Value);
     P2 = AtomicTags.FindByTag(TagP2.Value);
 }
Ejemplo n.º 8
0
        public IEnumerator TestingAndProfiling()
        {
            var go         = new GameObject();
            var atomicTags = go.AddComponent <AtomicTags>();

            List <string> random_tags_raw = new List <string>()
            {
                "a", "c", "e", "g", "i", "k", "m"
            };

            random_tags_raw.OrderBy((s => Random.value)).ToList();

            var fieldinfo = typeof(StringConstant).GetField("value", BindingFlags.NonPublic | BindingFlags.Instance);

            for (int i = 0; i < random_tags_raw.Count; ++i)
            {
                var stringConstant = ScriptableObject.CreateInstance <StringConstant>();
                fieldinfo.SetValue(stringConstant, random_tags_raw[i]);
                atomicTags.AddTag(stringConstant);
            }



            var newConstant = ScriptableObject.CreateInstance <StringConstant>();

            fieldinfo.SetValue(newConstant, "b");

            yield return(null);

            yield return(new WaitForFixedUpdate());

            // with the help of those ProfilerMarkers you can check GC Alloc in the Profiler Window Pretty easy
            // an alternative would be: https://docs.unity3d.com/2018.3/Documentation/ScriptReference/TestTools.Constraints.AllocatingGCMemoryConstraint.html
            // Assert.That(() => { }, Is.Not.AllocatingGCMemory()); but it does not work correctly half of the time

            Assert.That(() => { var t1 = atomicTags.Tags; }, Is.Not.AllocatingGCMemory());
            Assert.That(() => { var t1 = atomicTags.Tags[1]; }, Is.Not.AllocatingGCMemory());
            Assert.That(() => { var t1 = atomicTags.Tags[2].Value; }, Is.Not.AllocatingGCMemory());
            Assert.That(() => { atomicTags.HasTag(null); }, Is.Not.AllocatingGCMemory());

            Assert.AreSame(go, AtomicTags.FindByTag("e"));
            using (new ProfilerMarker("MySystem.FindByTag").Auto())
            {
                AtomicTags.FindByTag("e");
            }
            // THIS:
            // Assert.That(() => { var t1 = AtomicTags.FindByTag("e"); }, Is.AllocatingGCMemory());
            // says it allocates, the profiler says it does not

            using (new ProfilerMarker("MySystem.MultpleGet").Auto())
            {
                var t1  = atomicTags.Tags;
                var t10 = t1[0];
                var t11 = atomicTags.Tags[0];
                var t2  = atomicTags.Tags;
            }

            using (new ProfilerMarker("MySystem.GetGlobal").Auto())
            {
                AtomicTags.GetForGameObject(go);
            }

            Assert.AreEqual(random_tags_raw.Count, atomicTags.Tags.Count);

            for (var i = 0; i < atomicTags.Tags.Count - 1; i++)
            {
                Assert.IsTrue(String.CompareOrdinal(atomicTags.Tags[i].Value, atomicTags.Tags[i + 1].Value) < 0);
            }
            using (new ProfilerMarker("MySystem.AddCompletelyNewTag").Auto())
            {
                atomicTags.AddTag(newConstant);
            }

            Assert.AreEqual(random_tags_raw.Count + 1, atomicTags.Tags.Count);

            for (var i = 0; i < atomicTags.Tags.Count - 1; i++)
            {
                Assert.IsTrue(String.CompareOrdinal(atomicTags.Tags[i].Value, atomicTags.Tags[i + 1].Value) < 0);
            }

            using (new ProfilerMarker("MySystem.RemoveTag").Auto())
            {
                atomicTags.RemoveTag("b");
            }


            using (new ProfilerMarker("MySystem.AddTagAgain").Auto())
            {
                atomicTags.AddTag(newConstant);
            }

            Assert.IsTrue(atomicTags.HasTag("a"));
            using (new ProfilerMarker("MySystem.HasTagTrue1").Auto())
            {
                atomicTags.HasTag("a");
            }

            Assert.IsTrue(go.HasTag("a"));
            using (new ProfilerMarker("MySystem.HasTagTrue1Global").Auto())
            {
                go.HasTag("a");
            }

            Assert.IsTrue(go.HasTag("m"));
            using (new ProfilerMarker("MySystem.HasTagTrue2").Auto())
            {
                go.HasTag("m");
            }

            Assert.IsFalse(go.HasTag("z"));
            using (new ProfilerMarker("MySystem.HasTagFalse").Auto())
            {
                go.HasTag("z");
            }

            var falseList = new List <string>()
            {
                "d", "f", "h", "j", "l"
            };
            var truelist = new List <string>()
            {
                "d", "f", "h", "j", "m"
            };

            Assert.IsFalse(go.HasAnyTag(falseList));
            using (new ProfilerMarker("MySystem.HasAnyTag_allFalse").Auto())
            {
                go.HasAnyTag(falseList);
            }

            Assert.IsTrue(go.HasAnyTag(truelist));
            using (new ProfilerMarker("MySystem.HasAnyTag_lastTrue").Auto())
            {
                go.HasAnyTag(truelist);
            }



            yield return(null);
        }