Esempio n. 1
0
        public override void update()
        {
            Src_Rect     = new Rectangle(8 + (Team - 1) * 24, Flash_Frame * 16, 16, 16);
            Dot_Src_Rect = new Rectangle((Team - 1) * 24, 8 + Flash_Frame * 16, 8, 8);
            if (Length < Total_Length)
            {
                Length += Movement_Speed;
            }
            else
            {
                Length = Total_Length;
            }
            for (int i = 0; i < Points.Length; i++)
            {
                Points[i] = point_along_route((Length * i) / Points.Length, Waypoints);
            }
            loc = point_along_route(Length, Waypoints);
            float arrow_angle = angle_along_route(Length + Movement_Speed * 4, Waypoints);

            if (angle != arrow_angle)
            {
                if (Math.Abs(arrow_angle - angle) > MathHelper.Pi)
                {
                    if (angle < 0)
                    {
                        angle += MathHelper.TwoPi;
                    }
                    else if (angle > 0)
                    {
                        angle -= MathHelper.TwoPi;
                    }
                }
                angle = (float)Additional_Math.double_closer(angle, arrow_angle, ARROW_TURN_SPEED);
            }
        }
Esempio n. 2
0
 protected void update_move()
 {
     if (moving_full)
     {
         if ((Move_To != Loc.X) || Bob < 0)
         {
             int move_to = Move_To; // Why //Yeti
             Loc.X   = Additional_Math.int_closer((int)Loc.X, move_to, (int)MathHelper.Clamp((int)Math.Round(Math.Abs(Loc.X - move_to)) / Config.FACE_SPRITE_MOVEMENT_BOB_TIME, 1, 8));
             Move_To = move_to;     // why
             if ((Bob < 0) && (Math.Abs((int)Loc.X - Move_To) < Config.FACE_SPRITE_MOVEMENT_BOB_TIME))
             {
                 Bob = Config.FACE_SPRITE_MOVEMENT_BOB_TIME;
             }
         }
         if (Bob == Config.FACE_SPRITE_MOVEMENT_BOB_TIME)
         {
             Loc.Y += 1;
         }
         if (Bob == 0)
         {
             Loc.Y -= 1;
         }
         Bob--;
     }
 }
Esempio n. 3
0
        public static List <Vector2> bresenham(int x0, int y0, int x1, int y1)
        {
            List <Vector2> result = new List <Vector2>();

            if (y0 == y1)
            {
                if (x0 > x1)
                {
                    Additional_Math.swap(ref x0, ref x1);
                }
                for (int x = x0; x < x1; x++)
                {
                    result.Add(new Vector2(x, y0));
                }
                result.Add(new Vector2(x1, y1));
            }
            else if (x0 == x1)
            {
                if (y0 > y1)
                {
                    Additional_Math.swap(ref y0, ref y1);
                }
                for (int y = y0; y < y1; y++)
                {
                    result.Add(new Vector2(x0, y));
                }
                result.Add(new Vector2(x1, y1));
            }
            else
            {
                bool steep = Math.Abs(y1 - y0) > Math.Abs(x1 - x0);
                if (steep)
                {
                    Additional_Math.swap(ref x0, ref y0);
                    Additional_Math.swap(ref x1, ref y1);
                }
                if (x0 > x1)
                {
                    Additional_Math.swap(ref x0, ref x1);
                    Additional_Math.swap(ref y0, ref y1);
                }
                int delta_x = x1 - x0;
                int delta_y = (int)Math.Abs(y1 - y0);
                int error   = delta_x / 2;
                int ystep   = y0 < y1 ? 1 : -1;
                int y       = y0;
                for (int x = x0; x <= x1; x++)
                {
                    result.Add(steep ? new Vector2(y, x) : new Vector2(x, y));
                    error -= delta_y;
                    if (error < 0)
                    {
                        y     += ystep;
                        error += delta_x;
                    }
                }
            }
            return(result);
        }
Esempio n. 4
0
 protected void update_stats()
 {
     for (int i = 0; i < Stats.Count; i++)
     {
         if (Stats[i] != stat(i))
         {
             if (Stats[i] == null || stat(i) == null)
             {
                 Stats[i] = null;
             }
             else
             {
                 Stats[i] = Additional_Math.int_closer((int)Stats[i], (int)stat(i), 1);
             }
         }
     }
 }
Esempio n. 5
0
        public void set_loc(Vector2 new_loc)
        {
            Locs.Clear();
            Locs.Add((loc * Ratio[0] + new_loc * Ratio[1]) / (Ratio[0] + Ratio[1]));
            for (; ;)
            {
                // X
                if (Math.Abs(Locs[Locs.Count - 1].X - new_loc.X) <= Min_Distance_X)
                {
                    Locs[Locs.Count - 1] = new Vector2(new_loc.X, Locs[Locs.Count - 1].Y);
                }
                else if (Math.Abs(Locs[Locs.Count - 1].X - new_loc.X) <= Override_Distance_X)
                {
                    Locs[Locs.Count - 1] = new Vector2(
                        (float)Additional_Math.double_closer(Locs[Locs.Count - 1].X, new_loc.X, Min_Distance_X), Locs[Locs.Count - 1].Y);
                }
                // Y
                if (Math.Abs(Locs[Locs.Count - 1].Y - new_loc.Y) <= Min_Distance_Y)
                {
                    Locs[Locs.Count - 1] = new Vector2(Locs[Locs.Count - 1].X, new_loc.Y);
                }
                else if (Math.Abs(Locs[Locs.Count - 1].Y - new_loc.Y) <= Override_Distance_Y)
                {
                    Locs[Locs.Count - 1] = new Vector2(
                        Locs[Locs.Count - 1].X, (float)Additional_Math.double_closer(Locs[Locs.Count - 1].Y, new_loc.Y, Min_Distance_Y));
                }

                if (Locs[Locs.Count - 1].X == new_loc.X && Locs[Locs.Count - 1].Y == new_loc.Y)
                {
                    break;
                }

                Locs.Add((new Vector2(Locs[Locs.Count - 1].X, Locs[Locs.Count - 1].Y) * Ratio[0] +
                          new_loc * Ratio[1]) / (Ratio[0] + Ratio[1]));
            }
        }
Esempio n. 6
0
        public static List <Vector2> bresenham_supercover(int x0, int y0, int x1, int y1)
        {
            Vector2        base_loc = new Vector2(x0, y0);
            List <Vector2> result   = new List <Vector2>();

            if (y0 == y1)
            {
                if (x0 > x1)
                {
                    Additional_Math.swap(ref x0, ref x1);
                }
                for (int x = x0; x < x1; x++)
                {
                    result.Add(new Vector2(x, y0));
                }
                result.Add(new Vector2(x1, y1));
            }
            else if (x0 == x1)
            {
                if (y0 > y1)
                {
                    Additional_Math.swap(ref y0, ref y1);
                }
                for (int y = y0; y < y1; y++)
                {
                    result.Add(new Vector2(x0, y));
                }
                result.Add(new Vector2(x1, y1));
            }
            else
            {
                bool steep = Math.Abs(y1 - y0) > Math.Abs(x1 - x0);
                if (steep)
                {
                    Additional_Math.swap(ref x0, ref y0);
                    Additional_Math.swap(ref x1, ref y1);
                }
                if (x0 > x1)
                {
                    Additional_Math.swap(ref x0, ref x1);
                    Additional_Math.swap(ref y0, ref y1);
                }
                int delta_x = (x1 - x0), delta_x2 = delta_x * 2;
                int delta_y = (int)Math.Abs(y1 - y0), delta_y2 = delta_y * 2;
                int error      = delta_x;
                int error_prev = error;
                int ystep      = y0 < y1 ? 1 : -1;
                int y          = y0;
                result.Add(steep ? new Vector2(y, x0) : new Vector2(x0, y));
                for (int x = x0 + 1; x <= x1; x++)
                {
                    error += delta_y2;
                    if (error > delta_x2)
                    {
                        y     += ystep;
                        error -= delta_x2;
                        if (error + error_prev < delta_x2)
                        {
                            result.Add(steep ? new Vector2(y - ystep, x) : new Vector2(x, y - ystep));
                        }
                        else if (error + error_prev > delta_x2)
                        {
                            result.Add(steep ? new Vector2(y, x - 1) : new Vector2(x - 1, y));
                        }
                        else
                        {
                            result.Add(steep ? new Vector2(y, x - 1) : new Vector2(x - 1, y));
                            result.Add(steep ? new Vector2(y - ystep, x) : new Vector2(x, y - ystep));
                        }
                    }
                    result.Add(steep ? new Vector2(y, x) : new Vector2(x, y));
                    error_prev = error;
                }
                //result.Add(steep ? new Vector2(y, x1) : new Vector2(x1, y));
            }
            if (result[0] != base_loc)
            {
                result.Reverse();
            }
            return(result);
        }
Esempio n. 7
0
        protected override void update_phase_0()
        {
            if (Combat_Scene_Fade_In || Preparations_Fade_In)
            {
                bool cont = false;
                while (!cont)
                {
                    cont = true;
                    int alpha;
                    if (Preparations_Fade_In)
                    {
                        switch (Timer)
                        {
                        case 0:
                            promotion_fade_in_initialize();
                            Skip_Fill.tint = new Color(0, 0, 0, 1f);
                            Timer++;
                            break;

                        case 34:
                            Skip_Fill            = null;
                            Preparations_Fade_In = false;
                            if (WaitingOnPromotionChoice)
                            {
                                Timer = 0;
                            }
                            else
                            {
                                Timer = 36;
                            }
                            break;

                        default:
                            if (Timer > 18)
                            {
                                alpha          = (34 - Timer) * 16;
                                Skip_Fill.tint = new Color(0, 0, 0, alpha);
                            }
                            Timer++;
                            break;
                        }
                    }
                    else
                    {
                        switch (Timer)
                        {
                        case 0:
                            promotion_fade_in_initialize();
                            Skip_Fill.tint = new Color(1f, 1f, 1f, 1f);
                            Timer++;
                            break;

                        case 40:
                            Skip_Fill            = null;
                            Combat_Scene_Fade_In = false;
                            if (WaitingOnPromotionChoice)
                            {
                                Timer = 0;
                            }
                            else
                            {
                                Timer = 36;
                            }
                            break;

                        default:
                            if (Timer > 8)
                            {
                                alpha          = (40 - Timer) * 8;
                                Skip_Fill.tint = new Color(alpha, alpha, alpha, alpha);
                            }
                            Timer++;
                            break;
                        }
                    }
                }
            }
            else if (WaitingOnPromotionChoice)
            {
                if (!Music_Started)
                {
                    play_battle_theme();
                    Music_Started = true;
                }

                bool cont = true;
                if (!Global.game_temp.PromotionChoiceMenuCall && !Global.game_temp.menuing)
                {
                    cont = false;
                }
                while (!cont)
                {
                    cont = true;
                    switch (Timer)
                    {
                    case 8:
                        Pan_Vector.X = Additional_Math.int_closer(
                            (int)Pan_Vector.X, 0, 16);
                        if (HUD == null && Pan_Vector.X >= this.OffscreenOffset / 2)
                        {
                            setup_hud();
                        }

                        if (HUD != null && Pan_Vector.X == 0)
                        {
                            Timer++;
                        }
                        break;

                    case 9:
                        WaitingOnPromotionChoice = false;
                        Timer = 36;
                        break;

                    default:
                        Timer++;
                        break;
                    }
                }
            }
            else
            {
                if (!Global.game_temp.PromotionChoiceMenuCall && !Global.game_temp.menuing)
                {
                    base.update_phase_0();
                }
            }
        }
Esempio n. 8
0
 private void refresh_edges()
 {
     Edges = new HashSet <Rectangle>(Additional_Math.get_edges(Tiles));
 }
Esempio n. 9
0
        private void update_input(float max_speed)
        {
            if (Active)
            {
                if (Global.Input.pressed(Inputs.Up))
                {
                    if (Scroll_Speed > 0)
                    {
                        Scroll_Speed = 0;
                    }
                    if (Scroll_Speed > -max_speed)
                    {
                        Scroll_Speed--;
                    }
                    return;
                }
                else if (Global.Input.pressed(Inputs.Down))
                {
                    if (Scroll_Speed < 0)
                    {
                        Scroll_Speed = 0;
                    }
                    if (Scroll_Speed < max_speed)
                    {
                        Scroll_Speed++;
                    }
                    return;
                }
                else if (Global.Input.mouseScroll < 0)
                {
                    Scroll_Speed += max_speed / 5;
                    ScrollWheel   = true;
                    return;
                }
                else if (Global.Input.mouseScroll > 0)
                {
                    Scroll_Speed += -max_speed / 5;
                    ScrollWheel   = true;
                    return;
                }
                else if (Input.ControlScheme == ControlSchemes.Mouse && UpArrow.MouseOver())
                {
                    Scroll_Speed = -Config.CONVO_BACKLOG_MAX_SCROLL_SPEED;
                    ScrollWheel  = false;
                    return;
                }
                else if (Input.ControlScheme == ControlSchemes.Mouse && DownArrow.MouseOver())
                {
                    Scroll_Speed = Config.CONVO_BACKLOG_MAX_SCROLL_SPEED;
                    ScrollWheel  = false;
                    return;
                }
                else if (Global.Input.gesture_triggered(TouchGestures.VerticalDrag))
                {
                    Scroll_Speed = -(int)Global.Input.verticalDragVector.Y;
                    return;
                }
            }

            if (Scroll_Speed != 0)
            {
                if (Input.ControlScheme == ControlSchemes.Buttons)
                {
                    Scroll_Speed = (float)Additional_Math.double_closer(
                        Scroll_Speed, 0, 1);
                }
                else if (Input.ControlScheme == ControlSchemes.Mouse)
                {
                    if (ScrollWheel)
                    {
                        Scroll_Speed *= (float)Math.Pow(
                            Config.CONVO_BACKLOG_TOUCH_SCROLL_FRICTION, 2f);
                    }
                    else
                    {
                        Scroll_Speed = (float)Additional_Math.double_closer(
                            Scroll_Speed, 0, 1);
                    }
                }
                else
                {
                    Scroll_Speed *= Config.CONVO_BACKLOG_TOUCH_SCROLL_FRICTION;
                }

                if (Math.Abs(Scroll_Speed) < 0.1f)
                {
                    Scroll_Speed = 0;
                    ScrollWheel  = false;
                }
            }
        }
Esempio n. 10
0
        public override void update()
        {
            if (Window_Shake.Count > 0)
            {
                Window_Offset = Window_Shake.shift();
            }
            if (Data_Shake.Count > 0)
            {
                Data_Offset = Data_Shake.shift();
            }

            if (Timer < TIMER_MAX)
            {
                Timer++;
            }

            if (Hp1 != this.hp1 || (unit_2 != null && Hp2 != this.hp2))
            {
                if (Global.Input.triggered(Inputs.A) ||
                    Global.Input.mouse_triggered(MouseButtons.Left) ||
                    Global.Input.gesture_triggered(TouchGestures.Tap))
                {
                    if (Hp1 < this.hp1 || (unit_2 != null && Hp2 < this.hp2))
                    {
                        Global.game_system.play_se(System_Sounds.HP_Recovery);
                    }
                    Hp1 = this.hp1;
                    if (unit_2 != null)
                    {
                        Hp2 = this.hp2;
                    }
                }
            }

            if (Hp1_Timer == 0)
            {
                if (Hp1 < hp1)
                {
                    Global.game_system.play_se(System_Sounds.HP_Recovery);
                    Hp1_Timer = HP_GAIN_TIME;
                }
                Hp1 = Additional_Math.int_closer(Hp1, hp1, 1);
            }
            if (unit_2 != null && Hp2_Timer == 0)
            {
                if (Hp2 < hp2)
                {
                    Global.game_system.play_se(System_Sounds.HP_Recovery);
                    Hp2_Timer = HP_GAIN_TIME;
                }
                Hp2 = Additional_Math.int_closer(Hp2, hp2, 1);
            }
            if (Hp1_Timer > 0)
            {
                Hp1_Timer--;
            }
            if (Hp2_Timer > 0)
            {
                Hp2_Timer--;
            }
            Name1.update();
            HP_Counter1.text = (Hp1 > 99 ? "??" : Hp1.ToString());
            HP_Counter1.update();
            if (unit_2 != null)
            {
                Name2.update();
                HP_Counter2.text = (Hp2 > 99 ? "??" : Hp2.ToString());
                HP_Counter2.update();
            }
            // Update stats
            if (!stat_update_done())
            {
                if (Stat_Timer == 0)
                {
                    update_stats();
                    refresh_battle_stats();
                    Stat_Timer = 2;
                }
            }
            if (Stat_Timer > 0)
            {
                Stat_Timer--;
            }
            foreach (RightAdjustedText text in Stat_Imgs)
            {
                text.update();
            }
        }
Esempio n. 11
0
        public void update_movement()
        {
            if (is_following_unit)
            {
                update_following_unit();
                return;
            }
            bool target_window_up = ((Scene_Map)Global.scene).target_window_up && !((Scene_Map)Global.scene).manual_targeting;
            bool block_scroll     =
                Input.ControlScheme == ControlSchemes.Touch &&
                (is_movement_allowed() || Global.game_temp.menu_call ||
                 Global.game_temp.menuing);

            if (Instant_Movement || !Global.game_state.is_player_turn)
            {
                Instant_Movement = false;
                refresh_real_loc();
                if (!Global.game_system.is_interpreter_running)
                {
                    if (center(Real_Loc / UNIT_TILE_SIZE, true, forced: !block_scroll))
                    {
                        Global.game_map.scroll_speed = -1;
                    }
                }
            }
            else if (!target_window_up)
            {
                if (Global.game_state.is_menuing && !((Scene_Map)Global.scene).manual_targeting)
                {
                    refresh_real_loc();
                }
                else
                {
                    bool moved = (int)Real_Loc.X != (int)Loc.X * UNIT_TILE_SIZE ||
                                 (int)Real_Loc.Y != (int)Loc.Y * UNIT_TILE_SIZE;
                    int dist = (UNIT_TILE_SIZE / 4) * (speed_up_input() ? 2 : 1);
                    if (Global.game_temp.minimap_call)
                    {
                        dist = (UNIT_TILE_SIZE / 2);
                    }

                    Vector2 real_loc = new Vector2(Additional_Math.int_closer((int)Real_Loc.X, (int)Loc.X * UNIT_TILE_SIZE, dist),
                                                   Additional_Math.int_closer((int)Real_Loc.Y, (int)Loc.Y * UNIT_TILE_SIZE, dist));
                    if (Real_Loc != real_loc)
                    {
                        Real_Loc = real_loc;
                    }
                    center(Real_Loc / UNIT_TILE_SIZE, true, forced: !block_scroll);
                    if (moved)
                    {
                        Global.game_map.scroll_speed = dist;
                    }
                }
            }
            else
            {
                Real_Loc.X = (int)(Real_Loc.X + Loc.X * UNIT_TILE_SIZE) / 2;
                Real_Loc.Y = (int)(Real_Loc.Y + Loc.Y * UNIT_TILE_SIZE) / 2;
                center(Real_Loc / UNIT_TILE_SIZE, true, forced: !block_scroll);
            }
        }
Esempio n. 12
0
        protected override void setup()
        {
            Game_Unit battler_1 = Global.game_map.units[Battler_1_Id];

            set_variables(battler_1, Battler_2_Ids);
            List <int> attack_array = new List <int>();

            for (int i = 0; i < Battler_2_Ids.Count; i++)
            {
                Game_Unit battler_2 = Global.game_map.units[Battler_2_Ids[i]];
                Hp2 = battler_2.actor.hp;
                battler_1.store_state();
                battler_2.store_state();
                process_attacks(battler_1, battler_2, Battler_2_Ids[i]); // why was there a breakpoint here? //Test
                battler_1.restore_state();
                battler_2.restore_state();
                // Set battle end stats
                if (Data.Count == 0)
                {
                    throw new NotImplementedException("A battle with no attacks tried to occur");
                }
                Data[Data.Count - 1].Key.end_battle(Distance, Data[Data.Count - 1].Value);
                // Check if a battler has been killed
                if (battler_1.is_dead)
                {
                    Kills[i] = 1;
                    Kill     = Kills[i];
                }
                else if (battler_2.is_dead)
                {
                    Kills[i] = 2;
                    Kill     = Kills[i];
                }
                // Exp/Wexp: battler 1
                if (battler_can_gain_wexp(battler_1))
                {
                    Weapon_1_Broke = battler_1.is_weapon_broke(Weapon_1_Uses);
                }
                else
                {
                    Exp_Gain1 = 0;
                    Wexp1     = 0;
                }
                if (battler_can_gain_exp(battler_1, battler_2) && Exp_Gain1 > -1)
                {
                    Exp_Gain1 += exp_gain(battler_1, battler_2, this.weapon1, Kill == 2);
                    if (!Full_Exp1)
                    {
                        Exp_Gain1 = (int)MathHelper.Clamp(Exp_Gain1 / 2, 1, 5);
                    }
                }
                else
                {
                    Exp_Gain1 = 0;
                }

                Exp_Gain2 = 0;
                // Reset HP
                battler_1.actor.hp = Hp1;
                battler_2.actor.hp = Hp2;
                Hp2 = 0;
                // Reset skills
                battler_1.actor.reset_skills(true);
                battler_2.actor.reset_skills(true);
            }
            Func <int, int> divide_by_count = (int value) => value / Battler_2_Ids.Count;

            Wexp1     = Additional_Math.preserve_sign(Wexp1, divide_by_count);
            Exp_Gain1 = Additional_Math.preserve_sign(Exp_Gain1, divide_by_count);

            Exp_Gain1 = (Exp_Gain1 > 0 ?
                         Math.Min(Exp_Gain1, battler_1.actor.exp_gain_possible()) :
                         Math.Max(Exp_Gain1, -battler_1.actor.exp_loss_possible()));
        }