Ejemplo n.º 1
0
        public void BinarySearch_TestStrings()
        {
            string[] array = { "abc", "abcabc", "bcd", "aaa", "dcc", "abc" };
            Array.Sort(array);

            Assert.AreEqual(Array.BinarySearch(array, "abc"), FindUtil.BinarySearch(array, "abc"));
        }
Ejemplo n.º 2
0
        public void BinarySearch_TestNotExist()
        {
            int[] array = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            Array.Sort(array);

            Assert.AreEqual(FindUtil.BinarySearch(array, 10), -1);
        }
Ejemplo n.º 3
0
        public void BinarySearch_TestDoubles()
        {
            double[] array = { 13.22, -5.88, double.MaxValue, double.MinValue, 0, 0.14, 0.000001 };
            Array.Sort(array);

            Assert.AreEqual(Array.BinarySearch(array, 0.000001), FindUtil.BinarySearch(array, 0.000001));
        }
Ejemplo n.º 4
0
 public static Transform Child(GameObject gameObject, string name)
 {
     if (gameObject == null)
     {
         Debug.LogError("Attempting to find child with name: " + name + " inside null container.");
         return(null);
     }
     return(FindUtil.Child(gameObject.transform, name));
 }
Ejemplo n.º 5
0
    void Start()
    {
        uiAnimator = FindUtil.Child <Animator>(this.transform, "Ui");
        scoreText  = FindUtil.Child <TextMeshProUGUI>(this.transform, "Score");
        Init();

        restartButton = FindUtil.Child <CustomButton>(this.transform, "RestartButton");
        restartButton.SetFocusableState(ButtonTransitionStyle.Highlight);
        restartButton.AddToGroup("buttons");
        quitButton = FindUtil.Child <CustomButton>(this.transform, "QuitButton");
        quitButton.SetFocusableState(ButtonTransitionStyle.Highlight);
        quitButton.AddToGroup("buttons");
    }
Ejemplo n.º 6
0
    // null is valid
    private TMP_Text GetText(string name)
    {
        var container = FindUtil.Child(transform, name, true);

        if (container != null)
        {
            var txt = FindUtil.Child(container, "Text", true);
            if (txt != null)
            {
                return(txt.GetComponent <TMP_Text>());
            }
        }
        return(null);
    }
Ejemplo n.º 7
0
    private void GameOver()
    {
        Camera.main.GetComponent <CameraLerp>().enabled = false;
        Camera.main.transform.position = new Vector3(
            Camera.main.transform.position.x,
            10,
            Camera.main.transform.position.z);

        uiAnimator.SetTrigger("GameOver");
        climbStarted = false;
        playerCount  = 0;

        foreach (var player in playerModelLookup.Keys)
        {
            var sound = FindUtil.Child <AudioSource>(this.transform, "Climber" + player);
            sound.Play();
        }
    }
Ejemplo n.º 8
0
    private void BeginClimb()
    {
        foreach (var player in waitingForPlayers)
        {
            FindUtil.Child(this.transform, "Climber" + player).gameObject.SetActive(false);
        }

        waitingForPlayers = new List <int>();

        foreach (var controller in playerModelLookup)
        {
            controller.Value.UnlockAndTether();
        }

        uiAnimator.SetTrigger("StartClimb");
        climbStarted = true;
        Camera.main.GetComponent <CameraLerp>().enabled = true;
        scoreText.gameObject.SetActive(true);
    }
Ejemplo n.º 9
0
    public void SetFocusableState(ButtonTransitionStyle style)
    {
        this.style = style;

        switch (style)
        {
        case ButtonTransitionStyle.Swap:
            active   = FindUtil.Child(transform, "ButtonActive").gameObject;
            inactive = FindUtil.Child(transform, "ButtonInactive").gameObject;
            break;

        case ButtonTransitionStyle.Highlight:
            highlighted = FindUtil.Child(transform, "Highlighted").gameObject;
            break;

        case ButtonTransitionStyle.Lock:
            locked = FindUtil.Child(transform, "ButtonLocked").gameObject;
            break;
        }
    }
Ejemplo n.º 10
0
    private void PositionPlayer(int player)
    {
        ++playerCount;
        playerLookup.Add(playerCount, player);

        var transform = FindUtil.Child(this.transform, "Player" + playerCount + "StartPos");
        var climber   = FindUtil.Child(this.transform, "Climber" + player);

        climber.gameObject.SetActive(true);
        climber.position = new Vector3(
            transform.position.x,
            transform.position.y,
            transform.position.z);

        playerModelLookup.Add(playerCount, FindUtil.Child <PlayerController>(climber, "DummyController"));

        //attach to previous player
        var container = FindUtil.Child(this.transform, "Player" + playerCount);

        FindUtil.Child(container, "JoinMessage").gameObject.SetActive(false);

        playerModelLookup[playerCount].LockInPlace();
    }
Ejemplo n.º 11
0
    private void Init()
    {
        scoreText.gameObject.SetActive(false);
        waitingForPlayers = new List <int> {
            1, 2, 3, 4
        };
        playerLookup      = new Dictionary <int, int>();
        playerModelLookup = new Dictionary <int, PlayerController>();
        //Reset positions & ui
        foreach (var player in waitingForPlayers)
        {
            var climber = FindUtil.Child(this.transform, "Climber" + player);
            climber.gameObject.SetActive(false);

            var container = FindUtil.Child(this.transform, "Player" + player);
            FindUtil.Child(container, "JoinMessage").gameObject.SetActive(true);
        }

        uiAnimator.SetTrigger("NewGame");
        initialised = true;
        wallManager.NewLevel();
        rockManager.GenerateRocks(30);
    }
Ejemplo n.º 12
0
 public void BinarySearch_TestWithNull()
 {
     Assert.Throws <ArgumentNullException>(() => FindUtil.BinarySearch(null, 4));
 }