コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        //RaycastHit2D hit = Physics2D.Raycast (transform.position, transform.up);
        //Debug.DrawLine (transform.position, hit.point);
        //laserHit.position = hit.point;
        if (stateMachine.getMovement() == CentralStateScript.Movement.Flight)
        {
            lineRenderer.enabled = false;
        }
        else if (stateMachine.getMovement() == CentralStateScript.Movement.Orbit)
        {
            lineRenderer.enabled = true;
        }

        if (UFO == null)
        {
            UFO = GameObject.FindGameObjectWithTag("Player").GetComponent <Rigidbody2D> ();
            if (UFO == null)
            {
                return;
            }
            playerController = UFO.GetComponent <NewPlayerController> ();
        }
        transform.position = UFO.position + playerController.BurstDirecton;
        laserHit.position  = (Vector2)transform.position + playerController.BurstDirecton / 10;
        lineRenderer.SetPosition(0, transform.position);
        lineRenderer.SetPosition(1, laserHit.position);

        /*direction.transform.position = laserHit.position;
         * Quaternion rotation = Quaternion.LookRotation(playerController.BurstDirecton.normalized);
         * rotation.x = 0f;
         * rotation.y = 0f;
         * direction.transform.rotation = rotation;*/
        //direction.transform.rotation = Quaternion.LookRotation(playerController.BurstDirecton.normalized) * _facing;
    }
コード例 #2
0
ファイル: OxygenScript.cs プロジェクト: xuechaow/GravityHop
    // Update is called once per frame
    void Update()
    {
        if (stateMachine.getMovement() == CentralStateScript.Movement.Flight)
        {
            OxygenBar.fillAmount -= 1.0f / maxOxygen * Time.deltaTime;
        }
        else if (stateMachine.getMovement() == CentralStateScript.Movement.Orbit)
        {
            OxygenBar.fillAmount += 1.0f * Time.deltaTime;
        }

        if (OxygenBar.fillAmount <= 0)
        {
            stateMachine.GameOver();
        }
    }