Exemplo n.º 1
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));
 }
Exemplo n.º 2
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");
    }
Exemplo n.º 3
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);
    }
Exemplo n.º 4
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();
        }
    }
Exemplo n.º 5
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);
    }
Exemplo n.º 6
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;
        }
    }
Exemplo n.º 7
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();
    }
Exemplo n.º 8
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);
    }