示例#1
0
 // Start is called before the first frame update
 void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
示例#2
0
        public static double[] Test(int totalSize)
        {
            ScoreManager2 <int> manager = new ScoreManager2 <int>();
            Random random = new Random();

            manager.Threshold = 10;
            for (int i = 0; i < totalSize; i++)
            {
                manager.Add(i, random.NextDouble());
            }
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            timer.Start();
            manager.Threshold = 0.5;
            manager.Purge();
            timer.Stop();
            double purgeTime = timer.ElapsedMilliseconds;

            manager           = new ScoreManager2 <int>();
            manager.Threshold = 10;
            for (int i = 0; i < totalSize; i++)
            {
                manager.Add(i, random.NextDouble());
            }
            timer.Reset();
            timer.Start();
            manager.Threshold = 0.5;
            manager.Revalidate();
            timer.Stop();
            double revalTime = timer.ElapsedMilliseconds;

            return(new double[] { purgeTime, revalTime });
        }
示例#3
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
示例#4
0
 // Start is called before the first frame update
 void Start()
 {
     ObjectManager = GameObject.Find("ObjectManager");
     TextManager   = GameObject.Find("TextManager");
     goal_script   = ObjectManager.GetComponent <GoalManager2>();
     score_script  = TextManager.GetComponent <ScoreManager2>();
     count_script  = TextManager.GetComponent <CountManager2>();
 }
示例#5
0
 private void Update()
 {
     if (Input.GetMouseButtonDown(1))
     {
         ScoreManager2.GetInstance().AddScore(-2);
         Debug.Log(ScoreManager2.GetInstance().GetScore());
     }
 }
示例#6
0
 // Start is called before the first frame update
 void Start()
 {
     text2.text = "x" + Coin.contador2.ToString();
     if (instance2 == null)
     {
         instance2 = this;
     }
 }
示例#7
0
 void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
     score     = PlayerPrefs.GetInt("score");
     text.text = "X" + score.ToString();
 }
    void Start()
    {
        snake3BodyPosition = new List <Vector2Int>();
        snake2BodyPosition = new List <Vector2Int>();
        sceneManager       = FindObjectOfType <SceneManager>();
        scoreManager2      = FindObjectOfType <ScoreManager2>();

        snake3Dead = false;
        snake2Dead = false;
        SpawnFood();
    }
        public void GetBayesFactorTest()
        {
            ScoreManager2 <string> sm = new ScoreManager2 <string>();

            sm.Add("first", -3);
            sm.Add("second", 0);
            sm.Add("third", -1);
            double bayesFactor = sm.GetBayesFactor();

            Assert.AreEqual(0.34901221676818633, bayesFactor, 1E-6);
        }
示例#10
0
        public void PurgeTest()
        {
            ScoreManager2 <string> sm = new ScoreManager2 <string>();

            sm.Threshold = 0.99;
            bool added = sm.Add("zero", 0);

            added = sm.Add("one-half", 0.5);
            added = sm.Add("one", 1);
            Assert.AreEqual(sm.Count, 3);
            sm.Purge();
            Assert.AreEqual(sm.Count, 2);
        }
    private void Awake()
    {
        snake2Dead        = false;
        snake3Dead        = false;
        gridMoveTimerMax  = 0.08f;
        gridPosition      = new Vector2Int(19, 20);
        gridMoveTimer     = gridMoveTimerMax;
        gridMoveDirection = new Vector2Int(-1, 0);

        snakeMovePositionList = new List <Vector2Int>();
        snakeBodySize         = 1;
        snakeBodyPartList     = new List <GameObject>();
        scoreManager          = FindObjectOfType <ScoreManager2>();
        gameHandler           = FindObjectOfType <GameHandler2>();
    }
示例#12
0
        public void ItemByNameTest()
        {
            ScoreManager2 <int> sm = new ScoreManager2 <int>(useNames: true);

            sm.Threshold = 10;
            sm.Add(0, -3);
            sm.Add(2, 0);
            sm.Add(1, -1);
            Assert.AreEqual(sm.Count, 3);
            int item = sm.ItemByName("0");

            Assert.AreEqual(item, 0);
            item = sm.ItemByName("2");
            Assert.AreEqual(item, 2);
        }
示例#13
0
        public void ContainsItemNamedTest()
        {
            ScoreManager2 <string> sm = new ScoreManager2 <string>(useNames: true);

            sm.Threshold = 10;
            sm.Add("first", -3);
            sm.Add("second", 0);
            sm.Add("third", -1);
            Assert.AreEqual(sm.Count, 3);
            bool contains = sm.ContainsItemNamed("second");

            Assert.IsTrue(contains);
            contains = sm.ContainsItemNamed("fourth");
            Assert.IsFalse(contains);
        }
示例#14
0
        public void ExponentiateAndNormalizeTest()
        {
            ScoreManager2 <string> sm = new ScoreManager2 <string>();

            sm.Add("first", -3);
            sm.Add("second", -2);
            sm.Add("third", -1);
            sm.ExponentiateAndNormalize();
            double sum = 0;

            foreach (ScoredObject <string> so in sm)
            {
                sum += so.Score;
            }
            Assert.AreEqual(sum, 1, 1E-6);
        }
示例#15
0
        public void AddTest1()
        {
            ScoreManager2 <string> sm = new ScoreManager2 <string>(useNames: true);

            sm.Threshold = 1;
            bool added = sm.Add(new ScoredObject <string>()
            {
                Item = "one", Score = 1
            });

            Assert.IsTrue(added);
            Assert.AreEqual(sm.Count, 1);
            Assert.AreEqual(sm.TopScore, 1);
            added = sm.Add(new ScoredObject <string>()
            {
                Item = "one-half", Score = 0.5
            });
            Assert.IsTrue(added);
            Assert.AreEqual(sm.Count, 2);
            added = sm.Add(new ScoredObject <string>()
            {
                Item = "minus-one", Score = -1
            });
            Assert.IsFalse(added);
            Assert.AreEqual(sm.Count, 2);
            added = sm.Add(new ScoredObject <string>()
            {
                Item = "two", Score = 2
            });
            Assert.IsTrue(added);
            Assert.AreEqual(sm.Count, 3);
            Assert.AreEqual(sm.TopScore, 2);
            Assert.AreEqual(sm.TopItem, "two");
            added = sm.Add(new ScoredObject <string>()
            {
                Item = "one", Score = 3
            });
            Assert.IsFalse(added);
        }
示例#16
0
        public void SortTest()
        {
            ScoreManager2 <string> sm = new ScoreManager2 <string>();

            sm.Threshold = 10;
            List <int> ordered = new List <int>()
            {
                0, -1, -3
            };

            sm.Add("first", -3);
            sm.Add("second", 0);
            sm.Add("third", -1);
            sm.Sort();
            int i = 0;

            foreach (ScoredObject <string> so in sm)
            {
                Assert.AreEqual(ordered[i], so.Score);
                i++;
            }
        }
示例#17
0
        public void AddTest()
        {
            ScoreManager2 <string> sm = new ScoreManager2 <string>(useNames: true);

            sm.Threshold = 1;
            bool added = sm.Add("one", 1);

            Assert.IsTrue(added);
            Assert.AreEqual(sm.Count, 1);
            Assert.AreEqual(sm.TopScore, 1);
            added = sm.Add("one-half", 0.5);
            Assert.IsTrue(added);
            Assert.AreEqual(sm.Count, 2);
            added = sm.Add("minus one", -1);
            Assert.IsFalse(added);
            Assert.AreEqual(sm.Count, 2);
            added = sm.Add("two", 2);
            Assert.IsTrue(added);
            Assert.AreEqual(sm.Count, 3);
            Assert.AreEqual(sm.TopScore, 2);
            Assert.AreEqual(sm.TopItem, "two");
            added = sm.Add("one", 3);
            Assert.IsFalse(added);
        }
示例#18
0
        public void ScoreManager2Test()
        {
            ScoreManager2 <string> sm = new ScoreManager2 <string>();

            Assert.IsInstanceOfType(sm, typeof(ScoreManager2 <string>));
        }
示例#19
0
 private void Start()
 {
     scoreManager2 = GameObject.Find("Score2").GetComponent <ScoreManager2>();
 }
示例#20
0
    public void OnPointerUp(PointerEventData eventData)
    {
        if (transform.childCount > 0)
        {
            Color myColor = new Color();
            ColorUtility.TryParseHtmlString("#C2C2C2FF", out myColor);
            transform.GetComponent <Image>().color  = myColor;
            transform.GetComponent <Image>().sprite = defaultBlock;

            var children = new List <GameObject>();
            foreach (Transform child in transform)
            {
                children.Add(child.gameObject);
            }
            children.ForEach(child => Destroy(child));

            GameObject[] killEmAll = GameObject.FindGameObjectsWithTag("hammer");

            for (int i = 0; i < killEmAll.Length; i++)
            {
                Destroy(killEmAll[i].gameObject);
            }
        }
        else
        {
            int count = 0;

            for (int z = 0; z < children.Count; z++)
            {
                if (children[z].name.Contains("passive"))
                {
                    count++;
                }
            }

            if (count == children.Count)
            {
                ScoreManager2.searchAndDestroy();

                GameObject[] killEmAll = GameObject.FindGameObjectsWithTag("passive");

                for (int i = 0; i < killEmAll.Length; i++)
                {
                    Destroy(killEmAll[i].gameObject);
                }

                PassedGameObject.passed.Clear();

                if (parentNext.transform.childCount > 0)
                {
                    for (int i = 0; i < nextBlockGameObjects.Count; i++)
                    {
                        if (i == 0)
                        {
                            nextBlockGameObjects[i].name = "active";
                            nextBlockGameObjects[i].tag  = "passive";
                        }
                        else
                        {
                            nextBlockGameObjects[i].name = "passive";
                            nextBlockGameObjects[i].tag  = "passive";
                        }
                        nextBlockGameObjects[i].transform.SetParent(parent.transform);
                    }
                }
                else
                {
                    int random = Random.Range(1, 5);

                    if (random == 1 || random == 4)
                    {
                        float lucky = Random.Range(0f, 1f);

                        if (lucky < 0.3f)
                        {
                            if (random == 1)
                            {
                                random += Random.Range(1, 3);
                            }
                            else
                            {
                                random -= Random.Range(1, 3);
                            }
                        }
                    }

                    if (random == 1)
                    {
                        GameObject gameObject = Instantiate(activePrefab, new Vector3(0, 4, 0), Quaternion.identity);
                        gameObject.transform.SetParent(parent.transform);
                        gameObject.GetComponent <RectTransform>().localPosition = new Vector3(0, -46, 0);

                        int randomColor = Random.Range(1, 5);

                        if (randomColor == 1)
                        {
                            gameObject.GetComponent <Image>().sprite = confetti1;
                        }
                        else if (randomColor == 2)
                        {
                            gameObject.GetComponent <Image>().sprite = confetti2;
                        }
                        else if (randomColor == 3)
                        {
                            gameObject.GetComponent <Image>().sprite = confetti3;
                        }
                        else if (randomColor == 4)
                        {
                            gameObject.GetComponent <Image>().sprite = confetti4;
                        }
                    }
                    else if (random == 2)
                    {
                        GameObject gameObject = Instantiate(activePrefab, new Vector3(-45, 4, 0),
                                                            Quaternion.identity);
                        gameObject.transform.SetParent(parent.transform);
                        gameObject.GetComponent <RectTransform>().localPosition = new Vector3(-45, -46, 0);
                        GameObject gameObject1 = Instantiate(passivePrefab, new Vector3(0, 4, 0),
                                                             Quaternion.identity);
                        gameObject1.transform.SetParent(parent.transform);
                        gameObject1.GetComponent <RectTransform>().localPosition = new Vector3(0, -46, 0);

                        int randomColor = Random.Range(1, 5);

                        if (randomColor == 1)
                        {
                            gameObject.GetComponent <Image>().sprite = confetti1;
                        }
                        else if (randomColor == 2)
                        {
                            gameObject.GetComponent <Image>().sprite = confetti2;
                        }
                        else if (randomColor == 3)
                        {
                            gameObject.GetComponent <Image>().sprite = confetti3;
                        }
                        else if (randomColor == 4)
                        {
                            gameObject.GetComponent <Image>().sprite = confetti4;
                        }

                        randomColor = Random.Range(1, 5);

                        if (randomColor == 1)
                        {
                            gameObject1.GetComponent <Image>().sprite = confetti1;
                        }
                        else if (randomColor == 2)
                        {
                            gameObject1.GetComponent <Image>().sprite = confetti2;
                        }
                        else if (randomColor == 3)
                        {
                            gameObject1.GetComponent <Image>().sprite = confetti3;
                        }
                        else if (randomColor == 4)
                        {
                            gameObject1.GetComponent <Image>().sprite = confetti4;
                        }
                    }
                    else if (random == 3)
                    {
                        GameObject gameObject = Instantiate(activePrefab, new Vector3(-45, 4, 0),
                                                            Quaternion.identity);
                        gameObject.transform.SetParent(parent.transform);
                        gameObject.GetComponent <RectTransform>().localPosition = new Vector3(-45, -46, 0);
                        GameObject gameObject1 = Instantiate(passivePrefab, new Vector3(0, 4, 0),
                                                             Quaternion.identity);
                        gameObject1.transform.SetParent(parent.transform);
                        gameObject1.GetComponent <RectTransform>().localPosition = new Vector3(0, -46, 0);
                        GameObject gameObject2 = Instantiate(passivePrefab, new Vector3(37, 4, 0),
                                                             Quaternion.identity);
                        gameObject2.transform.SetParent(parent.transform);
                        gameObject2.GetComponent <RectTransform>().localPosition = new Vector3(37, -46, 0);

                        int randomColor = Random.Range(1, 5);

                        if (randomColor == 1)
                        {
                            gameObject.GetComponent <Image>().sprite = confetti1;
                        }
                        else if (randomColor == 2)
                        {
                            gameObject.GetComponent <Image>().sprite = confetti2;
                        }
                        else if (randomColor == 3)
                        {
                            gameObject.GetComponent <Image>().sprite = confetti3;
                        }
                        else if (randomColor == 4)
                        {
                            gameObject.GetComponent <Image>().sprite = confetti4;
                        }

                        randomColor = Random.Range(1, 5);

                        if (randomColor == 1)
                        {
                            gameObject1.GetComponent <Image>().sprite = confetti1;
                        }
                        else if (randomColor == 2)
                        {
                            gameObject1.GetComponent <Image>().sprite = confetti2;
                        }
                        else if (randomColor == 3)
                        {
                            gameObject1.GetComponent <Image>().sprite = confetti3;
                        }
                        else if (randomColor == 4)
                        {
                            gameObject1.GetComponent <Image>().sprite = confetti4;
                        }

                        randomColor = Random.Range(1, 5);

                        if (randomColor == 1)
                        {
                            gameObject2.GetComponent <Image>().sprite = confetti1;
                        }
                        else if (randomColor == 2)
                        {
                            gameObject2.GetComponent <Image>().sprite = confetti2;
                        }
                        else if (randomColor == 3)
                        {
                            gameObject2.GetComponent <Image>().sprite = confetti3;
                        }
                        else if (randomColor == 4)
                        {
                            gameObject2.GetComponent <Image>().sprite = confetti4;
                        }
                    }
                    else if (random == 4)
                    {
                        GameObject gameObject = Instantiate(activePrefab, new Vector3(-45, 4, 0),
                                                            Quaternion.identity);
                        gameObject.transform.SetParent(parent.transform);
                        gameObject.GetComponent <RectTransform>().localPosition = new Vector3(-45, -46, 0);
                        GameObject gameObject1 = Instantiate(passivePrefab, new Vector3(0, 4, 0),
                                                             Quaternion.identity);
                        gameObject1.transform.SetParent(parent.transform);
                        gameObject1.GetComponent <RectTransform>().localPosition = new Vector3(0, -46, 0);
                        GameObject gameObject2 = Instantiate(passivePrefab, new Vector3(37, 4, 0),
                                                             Quaternion.identity);
                        gameObject2.transform.SetParent(parent.transform);
                        gameObject2.GetComponent <RectTransform>().localPosition = new Vector3(37, -46, 0);
                        GameObject gameObject3 = Instantiate(passivePrefab, new Vector3(74, 4, 0),
                                                             Quaternion.identity);
                        gameObject3.transform.SetParent(parent.transform);
                        gameObject3.GetComponent <RectTransform>().localPosition = new Vector3(74, -46, 0);

                        int randomColor = Random.Range(1, 5);

                        if (randomColor == 1)
                        {
                            gameObject.GetComponent <Image>().sprite = confetti1;
                        }
                        else if (randomColor == 2)
                        {
                            gameObject.GetComponent <Image>().sprite = confetti2;
                        }
                        else if (randomColor == 3)
                        {
                            gameObject.GetComponent <Image>().sprite = confetti3;
                        }
                        else if (randomColor == 4)
                        {
                            gameObject.GetComponent <Image>().sprite = confetti4;
                        }

                        randomColor = Random.Range(1, 5);

                        if (randomColor == 1)
                        {
                            gameObject1.GetComponent <Image>().sprite = confetti1;
                        }
                        else if (randomColor == 2)
                        {
                            gameObject1.GetComponent <Image>().sprite = confetti2;
                        }
                        else if (randomColor == 3)
                        {
                            gameObject1.GetComponent <Image>().sprite = confetti3;
                        }
                        else if (randomColor == 4)
                        {
                            gameObject1.GetComponent <Image>().sprite = confetti4;
                        }

                        randomColor = Random.Range(1, 5);

                        if (randomColor == 1)
                        {
                            gameObject2.GetComponent <Image>().sprite = confetti1;
                        }
                        else if (randomColor == 2)
                        {
                            gameObject2.GetComponent <Image>().sprite = confetti2;
                        }
                        else if (randomColor == 3)
                        {
                            gameObject2.GetComponent <Image>().sprite = confetti3;
                        }
                        else if (randomColor == 4)
                        {
                            gameObject2.GetComponent <Image>().sprite = confetti4;
                        }

                        randomColor = Random.Range(1, 5);

                        if (randomColor == 1)
                        {
                            gameObject3.GetComponent <Image>().sprite = confetti1;
                        }
                        else if (randomColor == 2)
                        {
                            gameObject3.GetComponent <Image>().sprite = confetti2;
                        }
                        else if (randomColor == 3)
                        {
                            gameObject3.GetComponent <Image>().sprite = confetti3;
                        }
                        else if (randomColor == 4)
                        {
                            gameObject3.GetComponent <Image>().sprite = confetti4;
                        }
                    }
                }
            }
            else
            {
                children.Clear();

                foreach (Transform child in parent.transform)
                {
                    children.Add(child.gameObject);
                }

                for (int z = 0; z < children.Count; z++)
                {
                    if (z == 0)
                    {
                        children[z].name = "active";
                        children[z].GetComponent <RectTransform>().sizeDelta         = new Vector2(48, 48);
                        children[z].GetComponent <ContentSizeFitter>().horizontalFit =
                            ContentSizeFitter.FitMode.PreferredSize;
                        children[z].GetComponent <ContentSizeFitter>().verticalFit =
                            ContentSizeFitter.FitMode.PreferredSize;
                    }
                    else
                    {
                        children[z].name = "passive";
                        children[z].GetComponent <RectTransform>().sizeDelta         = new Vector2(32, 32);
                        children[z].GetComponent <ContentSizeFitter>().horizontalFit = ContentSizeFitter.FitMode.MinSize;
                        children[z].GetComponent <ContentSizeFitter>().verticalFit   = ContentSizeFitter.FitMode.MinSize;
                    }
                }

                for (int i = 0; i < PassedGameObject.passed.Count; i++)
                {
                    Color myColor = new Color();
                    ColorUtility.TryParseHtmlString("#C2C2C2FF", out myColor);
                    PassedGameObject.passed[i].GetComponent <Image>().color  = myColor;
                    PassedGameObject.passed[i].GetComponent <Image>().sprite = defaultBlock;
                }
            }
        }
    }
示例#21
0
 private void Awake()
 {
     Debug.Log("Start Score : " + ScoreManager2.GetInstance().GetScore());
 }