示例#1
0
        private void SwitchStageMapForPlayer(StageMap newStageMap, bool init = false)
        {
            if (playerPin.IsAnimating)
            {
                playerPin.StopAnimation(stopWhereItIs: false);
            }
            playerPin.currentStageMap = newStageMap;

            // Move the player too, if the stage is unlocked
            if (!init && !newStageMap.FirstPin.isLocked && MovePlayerWithStageChange)
            {
                playerPin.ForceToJourneyPosition(CurrentJourneyPosition);
            }
        }
示例#2
0
        public static int GetPosIndexFromJourneyPosition(StageMap stageMap, JourneyPosition journeyPos)
        {
            var st = journeyPos.Stage;

            if (stageMap.stageNumber > st)
            {
                return(0);
            }

            if (stageMap.stageNumber < st)
            {
                return(stageMap.MaxUnlockedPinIndex);
            }

            var pin = stageMap.PinForJourneyPosition(journeyPos);

            return(pin.pinIndex);
        }
示例#3
0
 public void MoveToJourneyPosition(JourneyPosition journeyPosition, StageMap stageMap)
 {
     MoveToPin(StageMapsManager.GetPosIndexFromJourneyPosition(stageMap, journeyPosition), stageMap.stageNumber);
 }
示例#4
0
        IEnumerator AnimateToPinCO(int targetIndex)
        {
            isAnimating = true;
            if (onMoveStart != null)
            {
                onMoveStart();
            }
            int tmpCurrentIndex = currentStageMap.CurrentPinIndex;
            //Debug.Log("ANIMATING FROM " + tmpCurrentIndex + " TO " + targetIndex);

            // Different stage: we will teleport antura
            int newStageIndex = stageMapsManager.CurrentShownStageMap.stageNumber;
            int oldStageIndex = currentStageMap.stageNumber;

            UpdatePlayerJourneyPosition(stageMapsManager.CurrentShownStageMap.mapLocations[targetIndex].JourneyPos);

            if (newStageIndex != oldStageIndex)
            {
                currentStageMap = stageMapsManager.CurrentShownStageMap;
                if (newStageIndex > oldStageIndex)
                {
                    tmpCurrentIndex = 0;
                }
                else
                {
                    tmpCurrentIndex = currentStageMap.MaxUnlockedPinIndex;
                }
                //Debug.Log("MOVING TO NEW STAGE AT INDEX " + tmpCurrentIndex + " STAGE " + currentStageMap.stageNumber);
                currentStageMap.ForceCurrentPinIndex(tmpCurrentIndex);
                ForceToJourneyPosition(currentStageMap.mapLocations[tmpCurrentIndex].JourneyPos, true);
            }


            // Antura too far: teleport him
            const int teleportDistance = 4;

            if (Mathf.Abs(targetIndex - tmpCurrentIndex) >= teleportDistance)
            {
                //Debug.Log("TELEPORTING because distance is " + Mathf.Abs(targetIndex - tmpCurrentIndex) + " from " + tmpCurrentIndex + " to " + targetIndex);
                bool isAdvancing   = targetIndex > tmpCurrentIndex;
                int  teleportIndex = targetIndex + (isAdvancing ? -teleportDistance : teleportDistance);
                teleportIndex = Mathf.Clamp(teleportIndex, 0, currentStageMap.MaxUnlockedPinIndex);
                currentStageMap.ForceCurrentPinIndex(teleportIndex);
                ForceToJourneyPosition(currentStageMap.mapLocations[teleportIndex].JourneyPos, true);
                tmpCurrentIndex = teleportIndex;
            }

            //Debug.Log("Starting movement from " + tmpCurrentIndex + " to " + targetIndex);
            do
            {
                //Debug.Log("inner target is " + targetIndex + " tmp is " + tmpCurrentIndex);
                float speed       = Mathf.Clamp(50 * Mathf.Abs(targetIndex - tmpCurrentIndex), 50, 100);
                bool  isAdvancing = targetIndex >= tmpCurrentIndex;
                if (tmpCurrentIndex != targetIndex)
                {
                    tmpCurrentIndex += isAdvancing ? 1 : -1;
                }
                LookAtPin(!isAdvancing, true);
                var nextPos = currentStageMap.mapLocations[tmpCurrentIndex].Position;
                yield return(MoveToCO(nextPos, speed));

                currentStageMap.ForceCurrentPinIndex(tmpCurrentIndex);
                ForceToJourneyPosition(currentStageMap.mapLocations[tmpCurrentIndex].JourneyPos, true);
            }while (tmpCurrentIndex != targetIndex);

            //Debug.Log("Current index is now: " + tmpCurrentIndex);

            isAnimating = false;
            if (onMoveEnd != null)
            {
                onMoveEnd();
            }
        }