Example #1
0
 public void Reset()
 {
     for (int i = 0; i < this.Commands.Count; i++)
     {
         switch (this.Commands[i])
         {
         case SceneCommand.PlayAnim:
             (this.Instructions[i] as Animation).Init();
             break;
         }
     }
     this.Frame = 0;
     ScenePlayer.CheckScenePlaying();
 }
Example #2
0
        public void RenderNext()
        {
            if (!this.Playing)
            {
                return;
            }
            for (int i = 0; i < this.StartFrames.Count; i++)
            {
                int currF = this.StartFrames[i];

                if (this.Frame == currF)
                {
                    switch (this.Commands[i])
                    {
                    case SceneCommand.PlayAnim:
                        (this.Instructions[i] as Animation).Init();
                        break;

                    case SceneCommand.Goto:
                        (this.Instructions[i] as GotoDest).Init();
                        break;
                    }
                }

                switch (this.Commands[i])
                {
                case SceneCommand.Goto:

                    if (this.Frame == currF)
                    {
                        (this.Instructions[i] as GotoDest).Perform();
                    }
                    break;

                case SceneCommand.PlayAnim:
                    if (this.Frame >= currF)
                    {
                        var anim = (this.Instructions[i] as Animation);

                        anim.RenderNext();
                    }
                    break;

                case SceneCommand.SetCamera:

                    if (this.Frame == currF)
                    {
                        var v3 = (this.Instructions[i] as Vector3[]);
                        if (v3.Length == 1)
                        {
                            if (!Single.IsNaN(v3[0].X))
                            {
                                float yaw  = Program.game.mainCamera.Yaw;
                                float then = v3[0].X;

                                float nearest = Single.MaxValue;

                                for (sbyte p = -50; p < 50; p++)
                                {
                                    float curr = v3[0].X + p * MainGame.PI * 2;
                                    float dist = Math.Abs(yaw - curr);
                                    if (dist < nearest)
                                    {
                                        then    = curr;
                                        nearest = dist;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }

                                Program.game.mainCamera.DestYaw = then;
                                //Program.game.mainCamera.Yaw = v3[0].X;
                            }
                            if (!Single.IsNaN(v3[0].Y))
                            {
                                Program.game.mainCamera.DestPitch = v3[0].Y;
                                //Program.game.mainCamera.Pitch = v3[0].Y;
                            }
                            Program.game.mainCamera.Zoom = Program.game.mainCamera.MaxZoom;
                        }

                        if (v3.Length == 2)
                        {
                            Program.game.lookAt            = v3[0];
                            Program.game.camPos            = v3[1];
                            Program.game.mainCamera.Target = null;
                        }
                    }
                    break;

                case SceneCommand.ContactCollison:

                    if (this.Frame == currF)
                    {
                        var v3 = (bool)this.Instructions[i];
                        ScenePlayer.AllowContactCollision = v3;
                    }
                    break;

                case SceneCommand.SetBGMVolume:

                    if (this.Frame >= currF)
                    {
                        var v0  = ((int[])this.Instructions[i])[0] / 100f;
                        var v1  = (float)(((int[])this.Instructions[i])[1]);
                        int ind = Audio.names.IndexOf(Audio.BGM);
                        if (ind > -1)
                        {
                            Audio.effectInstances[ind].Volume += (v0 - Audio.effectInstances[ind].Volume) / v1;
                        }
                    }
                    break;

                case SceneCommand.Gameplay:

                    if (this.Frame == currF)
                    {
                        for (int j = 0; j < this.Instructions.Count; j++)
                        {
                            var anm = (this.Instructions[j] as Animation);
                            if (anm != null)
                            {
                                anm.AllIdle();
                            }
                            var gt = (this.Instructions[j] as GotoDest);
                            if (gt != null)
                            {
                                gt.Idle();
                            }
                            Program.game.mainCamera.Target = Program.game.Player;
                        }
                    }

                    break;
                }
            }

            this.Frame++;
            ScenePlayer.CheckScenePlaying();
        }