Ejemplo n.º 1
0
    void Start()
    {
        // set initial values
        transform.localEulerAngles = Vector3.zero;
        for (int i = 0; i < discs.Count; i++)
        {
            Disc d     = discs[i];
            Disc dGlow = discGlows[i];
            d.GetComponent <PlaceOnAngle>().radius = 0;
            d.Radius     = discContractedRadius;
            dGlow.Radius = discGlowContractedRadius;
        }


        Sequence s = DOTween.Sequence();

        // Expand (inhale)
        s.Append(transform.DORotate(new Vector3(0f, 0f, -45f), breatheInDuration));
        for (int i = 0; i < discs.Count; i++)
        {
            Disc d     = discs[i];
            Disc dGlow = discGlows[i];
            s.Join(DOTween.To(() => d.GetComponent <PlaceOnAngle>().radius, x => d.GetComponent <PlaceOnAngle>().radius = x, discOffsetRadius, breatheInDuration));
            s.Join(d.DORadius(discExpandedRadius, breatheInDuration));
            s.Join(dGlow.DORadius(discGlowExpandedRadius, breatheInDuration));
        }

        // Hold breath in
        s.AppendInterval(holdInDuration);

        // Contract (exhale)
        s.Append(transform.DORotate(new Vector3(0f, 0f, 0f), breatheOutDuration));
        for (int i = 0; i < discs.Count; i++)
        {
            Disc d     = discs[i];
            Disc dGlow = discGlows[i];
            s.Join(DOTween.To(() => d.GetComponent <PlaceOnAngle>().radius, x => d.GetComponent <PlaceOnAngle>().radius = x, 0, breatheOutDuration));
            s.Join(d.DORadius(discContractedRadius, breatheOutDuration));
            s.Join(dGlow.DORadius(discGlowContractedRadius, breatheOutDuration));
        }

        // Hold breath out(?)
        s.AppendInterval(holdOutDuration);

        s.SetEase(Ease.InOutSine);
        // At this point it should be at the same point it was at the beginning, so loop
        s.SetLoops(-1, LoopType.Restart);
    }
Ejemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     DOTween.Init(true, true);
     for (int i = 0; i < numberOfDiscs; i++)
     {
         Disc newDisk = Instantiate(discPrefab, FindObjectOfType <Canvas>().transform).GetComponent <Disc>();
         newDisk.transform.localPosition                  = towers[0].transform.localPosition + towers[0].GetTopPosition();
         newDisk.GetComponent <Image>().color             = discColors[i];
         newDisk.GetComponent <RectTransform>().sizeDelta = new Vector2(50 + (numberOfDiscs - i) * 20f, 30f);
         newDisk.Size = numberOfDiscs - i;
         towers[0].AddDisc(newDisk);
     }
     Debug.Log(towers.Length);
     SolveTower(numberOfDiscs, towers[0], towers[2], towers[1]);
     StartCoroutine("MoveAllDiscs");
 }
Ejemplo n.º 3
0
    private void TurnOver()
    {
        state = GameState.InPlay;
        currentDisc.GetComponent <Collider>().enabled = true;

        Team teamToTurnoverTo = null;

        if (lastHadDisc == null || lastHadDisc.MyTeam == aiTeam)
        {
            teamToTurnoverTo = playerTeam;
        }
        else if (lastHadDisc.MyTeam == playerTeam)
        {
            teamToTurnoverTo = aiTeam;
        }

        Player p = teamToTurnoverTo.FindClosestTeamMemberTo(currentDisc.transform.position);

        GrabDisc(p);
    }
Ejemplo n.º 4
0
    public bool ReleaseDisc(GvrControllerInputDevice controller)
    {
        float max = Max(accelMag);
        //debugText.text = "accel = " + max;

        float forceStrength = Mathf.Lerp(0, maxThrowVelocity, max / accelLimit);

        Debug.Log("controllerAccel = " + accelMag + ", velocity = " + forceStrength);

        float distanceToTarget = Vector3.Distance(targetPosition, disc.transform.position);

        Vector3 lookDirection = Vector3.Scale(Camera.main.transform.forward, new Vector3(1f, 0f, 1f)).normalized;

        Vector3 targetDirection        = (targetPosition - disc.transform.position).normalized;
        Vector3 targetDirectionInPlane = Vector3.Scale(targetDirection, new Vector3(1f, 0f, 1f)).normalized;

        float lookAngle = Vector3.Angle(targetDirectionInPlane, lookDirection);

        Vector3 forceDirection;

        float a;

        if (distanceToTarget < 20f)
        {
            a = distanceToTarget * 0.5f;
            forceDirection = lookAngle < 30f ? targetDirection : lookDirection;
            forceStrength  = Mathf.Min(forceStrength, maxThrowVelocity * velocityLimitingFactor);
        }
        else
        {
            if (distanceToTarget > 100f)
            {
                a = 20f;
            }
            else
            {
                a = 15f;
            }
            forceDirection = lookAngle < 30f ? targetDirectionInPlane : lookDirection;
        }

        forceDirection = Vector3.RotateTowards(forceDirection, Vector3.up, a * Mathf.Deg2Rad, 0f).normalized;


        if (forceStrength < minThrowVelocity)
        {
            return(false);
        }

        //Vector3 forward = direction;
        //float angle = Vector3.Angle(forceDirection, forward);
        //float radiansChanged = forwardWeight * angle * Mathf.Deg2Rad;
        //forceDirection = Vector3.RotateTowards(forceDirection, forward, radiansChanged, float.MaxValue);

        Rigidbody rb = disc.GetComponent <Rigidbody>();

        Vector3 aVel = new Vector3(0, Mathf.Sign(rotationDifference.eulerAngles.y), 0);

        disc.ReleaseThrow(forceDirection * forceStrength, ForceMode.VelocityChange, aVel * 2000f, ForceMode.Impulse);
        //disc.ReleaseThrow(forceDirection * max, ForceMode.Acceleration, aVel * 2000f, ForceMode.Impulse);

        return(true);
    }