コード例 #1
0
        public void Start()
        {
            player = LevelHandler.GetPlayer();

            arrivingPosition = new Vector3(transform.position.x, transform.position.y, 0);

            startingSection = GetComponent <PorterPipeSection>();
        }
コード例 #2
0
 public void SetNextSection(bool forward, PorterPipeSection p)
 {
     if (forward)
     {
         nextSection = p;
     }
     else
     {
         previousSection = p;
     }
 }
コード例 #3
0
        private bool ShouldContinue(PorterPipeSection currentSection, string target)
        {
            if (currentSection.isEntrance)
            {
                if (currentSection.GetComponent <PorterPipeEntrance>().portName == target)
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #4
0
        private IEnumerator TransitionThroughTube(byte target)
        {
            string targetName = portNameConnections[target];


            bool currentMovingDirectionIsForward = StartingMovingDirectionIsForward;
            PorterPipeSection currentSection     = startingSection;
            PorterPipeSection nextSection;

            player.GetComponent <PlayerDeactivationHandler>().Dectivate();
            mixer.SetFloat("MasterLowPass", 0);
            mixer.SetFloat("MasterPitch", 0.5f);
            mixer.SetFloat("MasterEcho", 0);

            while (ShouldContinue(currentSection, targetName))
            {
                nextSection = currentSection.GetNextSection(currentMovingDirectionIsForward);

                if (nextSection.IsBlocked())
                {
                    currentMovingDirectionIsForward = !currentMovingDirectionIsForward;
                    nextSection = currentSection.GetNextSection(currentMovingDirectionIsForward);
                }


                float t = 0;
                while (t < 1)
                {
                    player.transform.position = Vector3.Lerp(currentSection.transform.position, nextSection.transform.position, t);
                    yield return(null);

                    t += Time.deltaTime * speed;
                }

                currentSection = nextSection;
            }

            player.transform.position = currentSection.GetComponent <PorterPipeEntrance>().arrivingPosition;
            player.GetComponent <PlayerDeactivationHandler>().Activate();
            mixer.ClearFloat("MasterLowPass");
            mixer.ClearFloat("MasterPitch");
            mixer.ClearFloat("MasterEcho");
        }