Exemple #1
0
 //Поймать указанную точку
 public void CatchPoint(PointBehaviour point)
 {
     Debug.Log($"RhytmManager.CatchPoint({point.isRedPoint}: Point caught");
     point.DeactivatePoint();
     AddToCombo();
     gameManager.AddScore(point.isRedPoint);
 }
        private void Update()
        {
            if (inputController.Pause)
            {
                SetEnabled(false);
                levelBehaviour.pauseBehaviour.TogglePause();
            }

            if (isEnabled == false)
            {
                return;
            }

            if (inputController.Interact)
            {
                PointBehaviour nearestPoint = proximityController.NearestPoint;
                if (nearestPoint != null)
                {
                    bool success = nearestPoint.OnInteract(this);
                    if (ignoreNextInteractionResult)
                    {
                        ignoreNextInteractionResult = false;
                        return;
                    }

                    if (success)
                    {
                        OnSuccessfulInteraction.Invoke();
                    }
                    else
                    {
                        OnFailedInteraction.Invoke();
                    }
                }
                else
                {
                    if (ignoreNextInteractionResult)
                    {
                        ignoreNextInteractionResult = false;
                        return;
                    }

                    OnFailedInteraction.Invoke();
                }
            }

            Vector3 projectedPosition = transform.position + (inputController.HorizontalMove * Vector3.right * Time.deltaTime * playerSettings.baseMetersPerSecond);

            projectedPosition.x = Mathf.Clamp(projectedPosition.x, levelBehaviour.Boundaries.minX, levelBehaviour.Boundaries.maxX);
            transform.Translate(projectedPosition - transform.position);

            soundEffectController.SetMovement(inputController.HorizontalMove);
            animationController.SetMovement(inputController.HorizontalMove);
            animationController.SetStackSize(itemStack.Count);
            animationController.UpdateAnimatorValues();
        }
Exemple #3
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.CompareTag(interactionPointTag))
     {
         if (NearestPoint != null && collision.gameObject == NearestPoint.gameObject)
         {
             levelBehaviour.ObjectHighlight.SetActive(false);
             NearestPoint = null;
         }
     }
 }
Exemple #4
0
 public void ChangePointColor(PointBehaviour target)
 {
     if (Mute)
     {
         target.ChangePointColor(Color.gray);
     }
     else
     {
         target.ChangePointColor(target.PointColor);
     }
 }
Exemple #5
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag(interactionPointTag))
     {
         PointBehaviour behaviour = collision.gameObject.GetComponent <PointBehaviour>();
         if (behaviour != null)
         {
             NearestPoint = behaviour;
             levelBehaviour.ObjectHighlight.SetActive(true);
             levelBehaviour.ObjectHighlight.transform.SetPositionAndRotation(behaviour.transform.position, behaviour.transform.rotation);
         }
     }
 }
    public void GeneratePoint()
    {
        int            line    = UnityEngine.Random.Range(0, 2);
        GameObject     newgo   = Instantiate(pointPrefab);
        PointBehaviour newgoPb = newgo.GetComponent <PointBehaviour>();

        newgo.transform.position      = spawnPosition;
        newgoPb.line                  = line;
        newgoPb.rhythmManager         = this.rhythmManager;
        newgoPb.gameManager           = this.gameManager;
        newgoPb.spriteRenderer.sprite = pointSprite;
        newgoPb.SetRed(line >= 1);
        StartCoroutine(WaitToGenerateNewPoint());
    }
    /// <summary>
    /// Instantiate new point
    /// </summary>
    public void InstantiatePoint(bool isIncorrectDetection = false, bool isFromCursor = false)
    {
        GameObject newPoint = Instantiate(pointPrefab);

        PointBehaviour newPointBehaviour = newPoint.GetComponent <PointBehaviour>();

        newPointBehaviour.pointColor = Color.HSVToRGB(UnityEngine.Random.value, 0.85f, 0.75f);
        newPointBehaviour.manager    = this;
        newPointBehaviour.UpdatePointColor(mute ? Color.gray : newPointBehaviour.pointColor);
        newPoint.transform.parent        = transform;
        newPoint.transform.localPosition = GetNewPointPosition();
        newPointBehaviour.speed          = speed;
        newPointBehaviour.id             = _highestId;
        newPointBehaviour.size           = new Vector3(UnityEngine.Random.Range(minPointSize.x, maxPointSize.x),
                                                       UnityEngine.Random.Range(minPointSize.y, maxPointSize.y),
                                                       UnityEngine.Random.Range(minPointSize.z, maxPointSize.z));
        newPointBehaviour.animateSize            = animateSize;
        newPointBehaviour.sizeVariationSpeed     = sizeVariationSpeed;
        newPointBehaviour.movementNoiseAmplitude = movementNoiseAmplitude;
        newPointBehaviour.movementNoiseFrequency = movementNoiseFrequency;
        newPointBehaviour.rotationNoiseAmplitude = rotationNoiseAmplitude;
        newPointBehaviour.rotationNoiseFrequency = rotationNoiseFrequency;
        newPointBehaviour.isIncorrectDetection   = isIncorrectDetection;
        newPointBehaviour.isFlickering           = false;

        if (isIncorrectDetection)
        {
            _incorrectInstantiatedPoints.Add(_highestId, newPoint);
            UpdateOIDs();
            SendAugmentaMessage(AugmentaMessageType.AugmentaObjectEnter, _incorrectInstantiatedPoints[_highestId]);
        }
        else
        {
            instantiatedPoints.Add(_highestId, newPoint);
            UpdateOIDs();
            SendAugmentaMessage(AugmentaMessageType.AugmentaObjectEnter, instantiatedPoints[_highestId]);
        }

        if (isFromCursor)
        {
            _cursorPoint = newPoint;
            OnMouseDrag();
            _desiredPointsCount++;
        }

        _highestId++;
        _pointsCount++;
    }