コード例 #1
0
    void Update()
    {
        var forwardA = cam.transform.rotation * Vector3.forward;
        var forwardB = transform.rotation * Vector3.forward;

        var angleA = Mathf.Atan2(forwardA.x, forwardA.z) * Mathf.Rad2Deg;
        var angleB = Mathf.Atan2(forwardB.x, forwardB.z) * Mathf.Rad2Deg;

        var angleDiff = Mathf.DeltaAngle(angleA, angleB);

        imageAngle = angleDiff;
        //rotationText.text = "Rotation : " + Mathf.Floor(imageAngle).ToString();

        if (imageAngle >= (-45f) && imageAngle <= 45f)
        {
            imageOrientation = TowerModes.Orientation.SOUTH;
        }
        else if (imageAngle > 45f && imageAngle <= 135f)
        {
            imageOrientation = TowerModes.Orientation.EAST;
        }
        else if (imageAngle < (-45f) && imageAngle >= (-135f))
        {
            imageOrientation = TowerModes.Orientation.WEST;
        }
        else if (imageAngle < (-135f) || imageAngle > 135f)
        {
            imageOrientation = TowerModes.Orientation.NORTH;
        }
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        towerOrientation = transform.parent.GetComponent <OrientationTracker>().imageOrientation;
        worldOrientation = GameMaster.boardOrientationTracker.imageOrientation;

        adaptPropertiesToWorld();

        for (int i = 0; i < Boards.boards.Length; i++)
        {
            if (targets[i] != null && properties.bulletPrefabs[(i + shift) % 4] != null)
            {
                /* lines[i].GetComponent<LineRenderer>().SetPosition(1, targets[i].position); */

                if (fireCountdown[i] <= 0f)
                {
                    Shoot(targets[i], properties.bulletPrefabs[(i + shift) % 4], i);
                    fireCountdown[i] = 1f / properties.fireRates[(i + shift) % 4];
                }

                fireCountdown[i] -= Time.deltaTime;
            }
            else
            {
                /* lines[i].GetComponent<LineRenderer>().SetPosition(1, firePoint.position); */
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (tracked && model1 != null && model2 != null && model3 != null && model4 != null)
        {
            orientation = transform.GetComponent <OrientationTracker>().imageOrientation;

            switch (orientation)
            {
            case TowerModes.Orientation.SOUTH:
                hide(model2Renderer);
                hide(model3Renderer);
                hide(model4Renderer);
                show(model1Renderer);
                break;

            case TowerModes.Orientation.EAST:
                hide(model1Renderer);
                hide(model3Renderer);
                hide(model4Renderer);
                show(model2Renderer);
                break;

            case TowerModes.Orientation.WEST:
                hide(model1Renderer);
                hide(model2Renderer);
                hide(model4Renderer);
                show(model3Renderer);
                break;

            case TowerModes.Orientation.NORTH:
                hide(model1Renderer);
                hide(model2Renderer);
                hide(model3Renderer);
                show(model4Renderer);
                break;

            default:
                break;
            }
        }
    }