Beispiel #1
0
    public bool MouseDown()
    {
        if (isFree || dragging || skyscraper != null)
        {
            return(false);
        }

        this.dragging = true;

        var pathObj = Instantiate(pathPrefab);

        pathObj.transform.parent = transform;
        this.path      = pathObj.GetComponent <ProjectedPath>();
        this.path.mass = this.mass;

        return(true);
    }
Beispiel #2
0
    public void MouseUp()
    {
        if (!dragging || skyscraper != null)
        {
            return;
        }

        mouseVelocity = MouseVelocity();

        var planetPosition = Planet.Instance.transform.position;
        var planetCoords   = (ProjectedPos() - planetPosition).normalized * 8;

        skyscraper = Instantiate(rocketPrefab);
        skyscraper.transform.position = planetPosition + planetCoords;
        skyscraper.transform.rotation = Quaternion.AngleAxis(Mathf.Rad2Deg * Mathf.Atan2(planetCoords.y, planetCoords.x) - 90, Vector3.forward);

        Destroy(this.path.gameObject);
        this.path = null;
        dragging  = false;

        timeUntilLeave = leaveDelay;
    }