Beispiel #1
0
 public bool AnimationFinished()
 {
     if (currentframe == AnimationFrames.Count() - 1)
     {
         return(true);
     }
     return(false);
 }
Beispiel #2
0
        public static void ControlableEntityAni(int Position, int ActualEndPos, List <String> Animation, int speed = 120)//240?
        {
            speed = Convert.ToInt32(speed * Globals.GameSpeed);
            //FIX CHANGE
            //meant for player and enemy
            if (Globals.AnimationRunning == false)
            {
                if (!(Position > 6 || Position < 1))
                {
                    Globals.AnimationRunning = true;

                    //note the animtaion starts from the ground
                    //all animations are square

                    //Work out Max area animation happens so you can just render that area
                    //Max row above the surface of the ground
                    int RowFinal = Globals.GroundInGameY - 1;
                    //Starting row of animation
                    int RowInitial = RowFinal;
                    //Starting Column of animation
                    int ColumnInitial = ((Position - 1) * 5);
                    //Max Column
                    int ColumnFinal = ColumnInitial;
                    foreach (var AnimationFrames in Animation)
                    {
                        //checks for the max height of animation
                        RowInitial = Math.Min(RowInitial, Globals.GroundInGameY - AnimationFrames.Count(f => f == '%'));
                        //checks for the max width of animation
                        ColumnFinal = Math.Max(ColumnFinal, ColumnInitial + ((AnimationFrames.Length - AnimationFrames.Count(f => f == '%')) / AnimationFrames.Count(f => f == '%')));
                    }
                    //IDK why probs 0 index
                    ColumnFinal--;
                    if (ColumnFinal >= Globals.GSW)
                    {
                        ColumnFinal = Globals.GSW - 1;
                    }
                    //System.Diagnostics.Debug.WriteLine($"{RowInitial},{ColumnInitial},{RowFinal},{ColumnFinal}");

                    //set up the Location of the Animation to change the screen list
                    List <List <int> > Location = new List <List <int> >()
                    {
                    };
                    foreach (var AnimationFram in Animation)
                    {
                        List <int> FrameCoords = new List <int>()
                        {
                        };
                        //row
                        FrameCoords.Add(Globals.GroundInGameY - AnimationFram.Count(f => f == '%'));
                        //Column
                        FrameCoords.Add((Position - 1) * 5);
                        Location.Add(FrameCoords);
                    }


                    //Runs for each Frame of animation ------------add time for each animation
                    for (int Frame = 0; Frame < Animation.Count; Frame++)
                    {
                        //Layer on animation
                        ChangeScreen(Convert.ToInt32(Location[Frame][0]), Convert.ToInt32(Location[Frame][1]), Animation[Frame]);

                        //Render animation
                        RenderScreen($"{RowInitial},{ColumnInitial},{RowFinal},{ColumnFinal}");
                        //RenderScreen("all");
                        //wait to next frame
                        //System.Diagnostics.Debug.WriteLine($"Completed Frame {Frame}");
                        Thread.Sleep(speed);
                    }
                    ResetArea(Position, ActualEndPos, RowInitial, ColumnInitial, RowFinal, ColumnFinal);
                    RenderScreen($"{RowInitial},{ColumnInitial},{RowFinal},{ColumnFinal}");
                    EndAni();
                }
                else
                {
                    //catches bugs
                    MakeErrorMessage("Position should be from 1-6 on screen");
                    //maybe check for next positon on map??????????????????????
                }
            }
            else
            {
                //catches bugs
                MakeErrorMessage("Couldn't run animation as one already runnign");
            }
        }
Beispiel #3
0
 public virtual void Animate()
 {
     currentframe = (currentframe + 1) % AnimationFrames.Count();
 }