// Start is called before the first frame update
 void Start()
 {
     S        = this;
     level    = 0;
     levelMax = castles.Length;
     StartLevel();
 }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        if (!aimingMode)
        {
            return;
        }
        Vector3 mousePos2D = Input.mousePosition;

        mousePos2D.z = -Camera.main.transform.position.z;
        Vector3 mousePos3D = Camera.main.ScreenToWorldPoint(mousePos2D);

        Vector3 mouseDelta = mousePos3D - launchPos;

        float maxMagnitude = this.GetComponent <SphereCollider>().radius;

        if (mouseDelta.magnitude > maxMagnitude)
        {
            mouseDelta.Normalize();
            mouseDelta *= maxMagnitude;
        }

        Vector3 projPos = launchPos + mouseDelta;

        projectile.transform.position = projPos;

        if (Input.GetMouseButtonUp(0))
        {
            aimingMode = false;
            projectileRigidbody.isKinematic = false;
            projectileRigidbody.velocity    = -mouseDelta * velocityMult;
            FollowCam.POI = projectile;
            projectile    = null;
            Mission_Demo.ShotFired();
            ProjectileLine.S.poi = projectile;
        }
    }