Esempio n. 1
0
    // Update is called once per frame
    void Update()


    {
        if (Input.GetKeyDown(KeyCode.Q))
        {
            testTimer.tick();
            print(testTimer.timeleft);
        }
        if (Input.GetKeyDown(KeyCode.W))
        {
            testTimer.AddTime(500);
        }

        if (Input.GetKeyDown(KeyCode.A))
        {
            bool      isCriticalHit = Random.Range(0, 100) < 30;
            Transform newPopUp      = Instantiate(PopUpGO);



            co_routine = delyayedAction(newPopUp.gameObject.GetComponent <DamagePopUp>(), "Hit", isCriticalHit, 4);
            StartCoroutine(co_routine);
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        //arrowkey control for tenkeyless
        Vector3 direction = Vector3.zero;

        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            direction = new Vector3(0, 0, 1);
        }
        if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            direction = new Vector3(0, 0, -1);
        }
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            direction = new Vector3(-1, 0, 0);
        }
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            direction = new Vector3(1, 0, 0);
        }

//classic numpad control
        if (Input.GetKeyDown(KeyCode.Keypad8))
        {
            direction = new Vector3(0, 0, 1);
        }
        if (Input.GetKeyDown(KeyCode.Keypad2))
        {
            direction = new Vector3(0, 0, -1);
        }
        if (Input.GetKeyDown(KeyCode.Keypad4))
        {
            direction = new Vector3(-1, 0, 0);
        }
        if (Input.GetKeyDown(KeyCode.Keypad6))
        {
            direction = new Vector3(1, 0, 0);
        }
        if (Input.GetKeyDown(KeyCode.Keypad7))
        {
            direction = new Vector3(-1, 0, 1);
        }
        if (Input.GetKeyDown(KeyCode.Keypad9))
        {
            direction = new Vector3(1, 0, 1);
        }
        if (Input.GetKeyDown(KeyCode.Keypad1))
        {
            direction = new Vector3(-1, 0, -1);
        }
        if (Input.GetKeyDown(KeyCode.Keypad3))
        {
            direction = new Vector3(1, 0, -1);
        }

        if (direction.magnitude > 0)

        {
            food.tick();
            if (food.isNearlyOver)
            {
                print("You are getting Hungry");
            }
            if (food.isOver)
            {
                print("You faint from hunger");
            }
            if (food.overUpperLimit)
            {
                print("You feel bloated, movement slowed");
            }

            Vector3 newPosition = transform.position + direction;
            if (theManager.CanMoveTo(newPosition))
            {
                transform.position += direction;

                transform.rotation = Quaternion.LookRotation(direction);
            }
        }
    }