Esempio n. 1
0
    void unpressObject()
    {
        int x = Screen.width / 2;
        int y = Screen.height / 2;

        Ray        ray = Camera.main.ScreenPointToRay(new Vector3(x, y));
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, distance))
        {
            Pressable p = hit.collider.GetComponent <Pressable>();
            if (p != null)
            {
                anim = p.GetComponent <Animation>();
                if (p.pressed)
                {
                    if (!anim.IsPlaying("Pressed"))
                    {
                        anim.Play("Unpressed");
                        new WaitForSeconds(anim["Unpressed"].length);
                        p.pressed = false;
                    }
                }
            }
        }
    }
Esempio n. 2
0
 void press()
 {
     //if within range and pressed key, activate button
     if (Input.GetKeyDown(KeyCode.E))
     {
         RaycastHit hit;
         if (Physics.Raycast(transform.position, transform.forward, out hit, distance))
         {
             Pressable p = hit.collider.GetComponent <Pressable>();
             if (p != null)
             {
                 anim = p.GetComponent <Animation>();
                 if (!p.pressed)
                 {
                     if (!anim.IsPlaying("Unpressed"))
                     {
                         anim.Play("Pressed");
                         new WaitForSeconds(anim["Pressed"].length);
                         p.pressed = true;
                     }
                 }
             }
         }
     }
 }
Esempio n. 3
0
        private void GetNewCurrentButton()
        {
            List <Gamepad> gamepadsToTest = new List <Gamepad>();

            if (gamepadMode == GM.anyGamepad)
            {
                gamepadsToTest.Add(Hinput.anyGamepad);
            }
            if (gamepadMode == GM.individualGamepads)
            {
                gamepadsToTest = Hinput.gamepad;
            }

            if (inputMode == IM.anyInput)
            {
                gamepadsToTest.ForEach(gamepad => {
                    if (gamepad.anyInput.pressed)
                    {
                        currentButton = gamepad.anyInput;
                    }
                });
            }

            if (inputMode == IM.individualInputs)
            {
                gamepadsToTest.ForEach(gamepad => {
                    AllGamepadButtons(gamepad).ForEach(button => {
                        if (button.pressed)
                        {
                            currentButton = button;
                        }
                    });
                });
            }
        }
Esempio n. 4
0
    // Start is called before the first frame update
    void Start()
    {
        gc = GameController.Instance;

        winTimer = 0;

        audioManager = GetComponent <AudioManager>();

        moveCounter   = 0;
        animationMode = false;

        // Get all boards
        GameObject[] boardList = GameObject.FindGameObjectsWithTag("Board");
        boards         = new BoardController[boardList.Length];
        finishedStatus = new bool[boardList.Length];

        for (int i = 0; i < boardList.Length; ++i)
        {
            BoardController tmp = boardList[i].GetComponent <BoardController>();
            boards[tmp.boardNumber - 1] = tmp;
            tmp.ballIndicator.Initialize(boardList.Length, tmp.boardNumber - 1);
        }

        activateBoard(1);


        // Walls
        tWalls = new List <ToggleWall> [4];
        for (int i = 0; i < 4; ++i)
        {
            tWalls[i] = new List <ToggleWall>();
        }

        GameObject[] walls = GameObject.FindGameObjectsWithTag("ToggleWall");
        foreach (GameObject o in walls)
        {
            ToggleWall tw = o.GetComponent <ToggleWall>();
            tWalls[tw.type - 1].Add(tw);
        }


        // Buttons
        pressables = new List <Pressable>();
        GameObject[] ps = GameObject.FindGameObjectsWithTag("Button");
        foreach (GameObject p in ps)
        {
            Pressable prs = p.GetComponent <OneOffButton>();
            if (!prs)
            {
                prs = p.GetComponent <PressurePlate>();
            }
            pressables.Add(prs);
        }
    }
Esempio n. 5
0
 private void UpdateButtonHighLight(Pressable button, GameObject go, string input)
 {
     if (button.simplePress.pressed)
     {
         go.SetActive(true);
         text.text = "Hinput.gamepad[" + index + "]." + input;
     }
     else
     {
         go.SetActive(false);
     }
 }
Esempio n. 6
0
    private void OnTriggerExit(Collider other)
    {
        if (collisions.Count <= 0)
        {
            return;
        }

        Pressable pp = other.GetComponent <Pressable>();

        if (pp)
        {
            pp.depress();
        }

        collisions.Dequeue();
    }
Esempio n. 7
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Killer")
        {
            moving = false;
            dead   = true;
            audioManager.spikes.Play();
            // Play dying animation
            return;
        }

        Pressable pp = other.GetComponent <Pressable>();

        if (pp)
        {
            pp.press();
        }

        collisions.Enqueue(other);
    }