コード例 #1
0
    void SpawnFriendSlot()
    {
        Vector3 startPos = Vector3.zero;
        float   radiusX  = GlobalSpiralMaster.GetCurrentRadius(0f, ref GlobalSpiralMaster.RadiusMapX);
        float   radiusY  = GlobalSpiralMaster.GetCurrentRadius(0f, ref GlobalSpiralMaster.RadiusMapY);

        SpiralMath.GetPositionAt(0f, ref startPos, radiusX, radiusY, GlobalSpiralMaster.ScaleZ, GlobalSpiralMaster.NoiseOn);
        startPos += GlobalSpiralMaster.transform.position;

        FriendSlot friendSlot = GlobalGameState.UIPoolManager.GetPoolableObject() as FriendSlot;

        if (friendSlot == null)
        {
            Debug.LogError("FAILED: Getting poolable friend slot object.");
            return;
        }

        // Init the slot
        if (_playerID < 0) // temp fix for TGC iPhone demo to make it circular access
        {
            _playerID = 0;
        }
        friendSlot.Activate();
        friendSlot.Init(ref startPos, 0f, PlayersJSON.Players[_playerID].NetworkMode, PlayersJSON.Players[_playerID].Name);
        _friendSlots.Add(friendSlot);
        _playerID++;
    }
コード例 #2
0
    public float GetCurrentRadius(float t, ref Vector2 radiusMap)
    {
        float normalizedLength = Mathf.InverseLerp(0f, Length, t);
        float valueCurveMapped = RadiusRemapCurve.Evaluate(normalizedLength);

        return(SpiralMath.Remap(valueCurveMapped, 1f, 0f, radiusMap.x, radiusMap.y));
    }
コード例 #3
0
 private void UpdateOpacityOnMovement()
 {
     if (t <= OpacityInTRange.y)
     {
         float k = SpiralMath.Remap(t, OpacityInTRange.x, OpacityInTRange.y, 0f, 1f);
         SetOpacityForSlot(k);
     }
     else if (t >= OpacityOutTRange.x)
     {
         float k = SpiralMath.Remap(t, OpacityOutTRange.y, OpacityOutTRange.x, 0f, 1f);
         SetOpacityForSlot(k);
     }
     else
     {
         float k = 1f;
         SetOpacityForSlot(k);
     }
 }
コード例 #4
0
    private Vector3 GetTargetPosition()
    {
        if (CurrentSlotMode == SocialDataType.SlotMode.Selected)
        {
            float radiusX = GlobalSpiralMaster.GetCurrentRadius(GlobalFriendListManager.SelectedTValue, ref GlobalSpiralMaster.RadiusMapX);
            float radiusY = GlobalSpiralMaster.GetCurrentRadius(GlobalFriendListManager.SelectedTValue, ref GlobalSpiralMaster.RadiusMapY);

            SpiralMath.GetPositionAt(GlobalFriendListManager.SelectedTValue, ref _positionOnCurve, radiusX, radiusY, GlobalSpiralMaster.ScaleZ, GlobalSpiralMaster.NoiseOn);
            return(_positionOnCurve + GlobalSpiralMaster.transform.position);
        }
        else
        {
            float radiusX = GlobalSpiralMaster.GetCurrentRadius(t, ref GlobalSpiralMaster.RadiusMapX);
            float radiusY = GlobalSpiralMaster.GetCurrentRadius(t, ref GlobalSpiralMaster.RadiusMapY);

            SpiralMath.GetPositionAt(t, ref _positionOnCurve, radiusX, radiusY, GlobalSpiralMaster.ScaleZ, GlobalSpiralMaster.NoiseOn);
            return(_positionOnCurve + GlobalSpiralMaster.transform.position);
        }
    }
コード例 #5
0
    void CreateSpiral()
    {
        Positions.Clear();
        float accumulatedLength = 0f;

        while (accumulatedLength < Length)
        {
            Vector3 pos = new Vector3();

            float radiusX = GetCurrentRadius(accumulatedLength, ref RadiusMapX);
            float radiusY = GetCurrentRadius(accumulatedLength, ref RadiusMapY);

            SpiralMath.GetPositionAt(accumulatedLength, ref pos, radiusX, radiusY, ScaleZ, NoiseOn);

            Positions.Add(pos + gameObject.transform.position);

            accumulatedLength += SegmentLength;
        }
    }
コード例 #6
0
    // Update is called once per frame
    void Update()
    {
        if (Application.isPlaying) // in editor debug purposes
        {
            _actualLength += GlobalGestureCircle.DragMotion * 1.6f;

            _actualLength = Mathf.Max(0f, _actualLength);

            _targetLength = Mathf.Clamp(_actualLength, LengthRange.x, LengthRange.y);

            float clampedLength = Mathf.Clamp(_actualLength, LengthRange.x, LengthRange.y);

            Length = Mathf.SmoothDamp(clampedLength, _targetLength, ref _lengthGrowSpeed, 0.1f);
        }
        Length = Mathf.Clamp(Length, LengthRange.x, LengthRange.y);

        GameScreen.color = Color.white * SpiralMath.Remap(Length, 2f, 0f, 0.5f, 1f);

        CreateSpiral();
    }
コード例 #7
0
    void GetDragMotion()
    {
        if (_motionPositions.Count < 3)
        {
            return;
        }

        Vector2[] motionPositions = _motionPositions.ToArray();
        Vector2   t1 = motionPositions[0] - _markerPosition;
        Vector2   t2 = motionPositions[1] - _markerPosition;
        Vector2   t3 = motionPositions[2] - _markerPosition;

        float a1 = SpiralMath.GetAngleAtan2(t1, t2);
        float a2 = SpiralMath.GetAngleAtan2(t2, t3);

        // make sure no matter how fast circular gesture happens, limit the speed
        float targetDragMotion = Mathf.Clamp((a1 + a2) * 0.5f, ClampDragMotion.x, ClampDragMotion.y);

        // any of the direction of motion velocity is applied, they all have to blend together
        DragMotion = Mathf.SmoothDamp(DragMotion, targetDragMotion, ref _velocityDelta, 0.5f);
    }