コード例 #1
0
    public TypingPrompt GenerateMeshes(string characters)
    {
        Transform newGroup = (Transform)Instantiate(typingGroupPrefab);
        Vector3 newPos = Vector3.zero;
        TypingPrompt lastPrompt = null;
        float increment = 0.0f;

        for (int i = 0; i < characters.Length; i++)
        {
            newPos = new Vector3(increment,0f,0f);
            TypingPrompt newPrompt = (TypingPrompt)Instantiate(typingPromptPrefab,newPos,Quaternion.identity);
            newPrompt.text = characters[i].ToString();
            newPrompt.order = i;
            newPrompt.gameObject.name = "" + newPrompt.order + newPrompt.text;
            newPrompt.transform.parent = newGroup;
            if (lastPrompt != null)
            {
                lastPrompt.nextTarget = newPrompt;
            } else {
                _firstTarget = newPrompt;
            }

            lastPrompt = newPrompt;
            increment += spacing;
        }

        return _firstTarget;
    }
コード例 #2
0
ファイル: Player.cs プロジェクト: AndreiMarks/spooky-typing
    // Use this for initialization
    void Start()
    {
        _game = GameObject.Find("GameManager").GetComponent<GameManager>();

        gameObject.name = (myself) ? "PlayerMe" : "PlayerOpponent";
        if (!myself)
        {
            _opponentsPrompt = _game.GenerateOpponentsText();
            _opponentsText = _opponentsPrompt.transform.parent;
            _game.SetOtherPlayer(this);
        }
        _ready = true;
    }
コード例 #3
0
ファイル: Player.cs プロジェクト: AndreiMarks/spooky-typing
 private void UpdatePrompt()
 {
     if (_opponentsPrompt.order < progress)
     {
         iTween.FadeTo(_opponentsPrompt.gameObject,0f,.5f);
         _opponentsPrompt = _opponentsPrompt.nextTarget;
     }
 }
コード例 #4
0
 public void SetTarget(TypingPrompt currentTarget)
 {
     _currentTarget = currentTarget;
 }
コード例 #5
0
    // Update is called once per frame
    void Update()
    {
        if (_gameOver) return;
        if (_isWaiting)
        {
            WaitForBonusPress();
            return;
        }

        if (_shouldTime)
        {
            _wpmTimer += Time.deltaTime;
        }

        if (Input.anyKeyDown)
        {
            _totalKeyPresses++;
            lastKeyPress.text = Input.inputString;
            if (Input.inputString == _currentTarget.text)
            {
                _correctKeyPresses++;
                _currentBonus++;
                _currentTarget.Correct();
                if (_currentTarget.nextTarget != null)
                {
                    _currentTarget = _currentTarget.nextTarget;
                } else {
                    if (Network.isServer)
                    {
                        Network.Instantiate(serverWinsPrefab,serverWinsPrefab.transform.position,Quaternion.identity,0);
                    } else {
                        Network.Instantiate(clientWinsPrefab, clientWinsPrefab.transform.position,Quaternion.identity,0);
                    }
                    _gameOver = true;

                }

                audio.Correct();
                audio.Undistort();

                multi.AddPoint();
            } else {
                if (!Input.GetKeyDown(KeyCode.Return) && !Input.GetKeyDown(KeyCode.RightShift) && !Input.GetKeyDown(KeyCode.LeftShift))
                {
                    _currentBonus -= 5;
                    if (_currentBonus < 0) _currentBonus = 0;
                    _currentTarget.Incorrect();
                    audio.Incorrect();
                    audio.Distort();
                    visual.Distort();

                    multi.Incorrect();
                }
            }

        }
    }