コード例 #1
0
    private void Update()
    {
        if (buttonClicked)
        {
            buttonHoldTime += Time.deltaTime;

            if (buttonHoldTime > buttonHoldMoveTime)
            {
                controller.MoveCursor(controller.MoveVector);
                buttonHoldTime = buttonHoldMoveTime - buttonHoldMoveInterval;
            }
        }
    }
コード例 #2
0
    private IEnumerator MoveToTargetArray(int row, int col, float interval)
    {
        // move Y axis first
        Vector2Int moveVector = new Vector2Int(col, row) - controller.CurrentPosition;

        moveVector.y = Mathf.Clamp(moveVector.y, -1, 1);
        moveVector.x = Mathf.Clamp(moveVector.x, -1, 1);

        if (!(moveVector.y == 0))
        {
            moveVector.x = 0;
        }

        if (moveVector.magnitude > 0)
        {
            controller.MoveCursor(moveVector);
            yield return(new WaitForSeconds(interval));

            StartCoroutine(MoveToTargetArray(row, col, moveInterval));
        }
        else
        {
            // Finish move, call for next action
            operating = false;
        }

        yield return(null);
    }
コード例 #3
0
    public void OnDrag(PointerEventData eventData)
    {
        if (!active)
        {
            return;
        }

        var delta = (eventData).delta * (600.0f / Screen.height);

        if (MainTouchPressed && eventData.pointerId == MainTouchId)
        {
            CursorController.MoveCursor(delta * 2);
        }

        if (AsistTouchPressed && eventData.pointerId == AsistTouchId)
        {
            CursorController.NudgeCursor(delta);
        }
    }
コード例 #4
0
ファイル: GameLoop.cs プロジェクト: carraka/ludumdare42
    private void Start()
    {
        cursor       = GetComponentInChildren <CursorController>();
        db           = GameObject.Find("DataBucket").GetComponent <DataBucket>();
        document     = GetComponentInChildren <Document>();
        textBox      = document.GetComponent <Text>();
        clock        = GameObject.Find("Clock").GetComponent <Text>();
        spaceCounter = GameObject.Find("SpaceCounter").GetComponent <Text>();

        BGM = GameObject.Find("BGM").GetComponent <AudioSource>();
        SFX = GameObject.Find("SFX").GetComponent <AudioSource>();

        error = (AudioClip)Resources.Load("SFX/error", typeof(AudioClip));

        //Fetch the Raycaster from the GameObject (the Canvas)
        m_Raycaster = GameObject.Find("BGCanvas").GetComponent <GraphicRaycaster>();
        //Fetch the Event System from the Scene
        m_EventSystem = GameObject.Find("EventSystem").GetComponent <EventSystem>();

        document.SetUpDocument(db.level);

        GUIStyle style = new GUIStyle();

        style.font     = textBox.font;
        style.fontSize = textBox.fontSize;

        Vector2 fontSize = style.CalcSize(new GUIContent("1\n2\n3\n4\n5\n6\n7\n8\n9\n0"));

        fontWidth  = fontSize.x;
        fontHeight = fontSize.y / 10;

        cursor.SetSize(textBox.fontSize, fontWidth, fontHeight);
        cursorLocation = Vector2Int.zero;
        cursor.MoveCursor(cursorLocation);

        RectTransform monitorRect  = GetComponent <RectTransform>();
        RectTransform documentRect = GameObject.Find("Document").GetComponent <RectTransform>();

        screenDocumentLeft = Camera.main.pixelWidth * monitorRect.anchorMin.x +
                             (Camera.main.pixelWidth * (monitorRect.anchorMax.x - monitorRect.anchorMin.x)) * documentRect.anchorMin.x;

        screenDocumentTop = Camera.main.pixelWidth * 0.75f * monitorRect.anchorMax.y -
                            (Camera.main.pixelWidth * 0.75f * (monitorRect.anchorMax.y - monitorRect.anchorMin.y)) * (1 - documentRect.anchorMax.y) -
                            (Camera.main.pixelWidth * 0.75f - Camera.main.pixelHeight) / 2;

        if (db.levelData.data[db.level].difficulty == Difficulty.easy)
        {
            cursor.GetComponent <Image>().enabled                    = false;
            cursor.GetComponentInChildren <Text>().enabled           = false;
            GameObject.Find("Postit").GetComponent <Image>().enabled = false;
            GameObject.Find("memo").GetComponent <Image>().enabled   = false;
        }

        AudioClip music = null;

        switch (Random.Range(0, 3))
        {
        case 0:
            music = (AudioClip)Resources.Load("Music/game theme 1 fixed-ld42", typeof(AudioClip));
            break;

        case 1:
            music = (AudioClip)Resources.Load("Music/game music 2 loop-ld42", typeof(AudioClip));
            break;

        default:
            music = (AudioClip)Resources.Load("Music/game_music_3", typeof(AudioClip));
            break;
        }

        BGM.clip = music;
        BGM.Play();
        BGM.loop = true;

        playingLevel = false;

        StartCoroutine(LoadLevel());
    }