Exemplo n.º 1
0
        public void ClearAllTest()
        {
            Vector3[] ga  = TagCache.GetVector3sByTag("Test");
            Vector3   toA = testObjectA.transform.position;
            Vector3   toB = testObjectB.transform.position;
            Vector3   toC = testObjectC.transform.position;

            Assert.AreEqual(2, ga.Length);
            Assert.AreEqual(true, ga.Contains(toA));
            Assert.AreEqual(true, ga.Contains(toB));
            Assert.AreEqual(false, ga.Contains(toC));
            Assert.AreEqual(testObjectC.transform.position, TagCache.GetVector3sByTag("Dummy")[0]);

            testObjectA.transform.position = new Vector3(10, 123, 5);
            testObjectB.transform.position = new Vector3(13, 13, 1);
            testObjectC.transform.position = new Vector3(-10, 3, 0);

            TagCache.ClearAll();

            Vector3[] gaAfter = TagCache.GetVector3sByTag("Test");
            Assert.AreEqual(0, gaAfter.Length);
            Assert.AreEqual(false, gaAfter.Contains(toA));
            Assert.AreEqual(false, gaAfter.Contains(toB));
            Assert.AreEqual(false, gaAfter.Contains(testObjectA.transform.position));
            Assert.AreEqual(false, gaAfter.Contains(testObjectB.transform.position));
            Assert.AreEqual(false, gaAfter.Contains(testObjectC.transform.position));
        }
Exemplo n.º 2
0
        public static Vector3[] GetVectors(string[] Tags)
        {
            if (Tags != null)
            {
                int       oldLen  = 0;
                Vector3[] targets = null;
                foreach (string tag in Tags)
                {
                    Vector3[] tempTargets = TagCache.GetVector3sByTag(tag);

                    if (targets == null)
                    {
                        targets = new Vector3[tempTargets.Length];
                    }
                    else
                    {
                        oldLen = targets.Length;
                        Array.Resize(ref targets, targets.Length + tempTargets.Length);
                    }

                    // Copy new elements into the start of the space added by Array.Resize, or the start of the array if its empty
                    Array.Copy(tempTargets, 0, targets, oldLen, tempTargets.Length);
                }

                return(targets);
            }
            return(new Vector3[0]);
        }
Exemplo n.º 3
0
        public void GetVector3sTest()
        {
            Assert.AreEqual(2, TagCache.GetVector3sByTag("Test").Length);

            Vector3[] ga = TagCache.GetVector3sByTag("Test");
            Assert.AreEqual(true, ga.Contains(testObjectA.transform.position));
            Assert.AreEqual(true, ga.Contains(testObjectB.transform.position));
            Assert.AreEqual(false, ga.Contains(testObjectC.transform.position));

            Assert.AreEqual(testObjectC.transform.position, TagCache.GetVector3sByTag("Dummy")[0]);
        }