Example #1
0
        /// <summary>
        /// pass in something like this: 2,2|(990,991,1022,1023)|24,24|ROTATEFAST
        /// </summary>
        /// <param name="info"></param>
        public FrameFacet(string info)
        {
            string[] pieces   = info.Split('|');
            string[] subpiece = pieces[0].Split(',');
            width    = byte.Parse(subpiece[0]);
            height   = byte.Parse(subpiece[1]);
            subpiece = Acc.script_remove_outer_parentheses(pieces[1]).Split(',');
            images   = new int[subpiece.Length];
            for (int i = 0; i < images.Length; i++)
            {
                images[i] = int.Parse(subpiece[i]);
            }
            subpiece     = pieces[2].Split(',');
            attach_point = new Point(int.Parse(subpiece[0]), int.Parse(subpiece[1]));
            if (pieces.Length == 4)
            {
                center_of_rotation = new Point(0, 0);
                rotation_type      = (FACETTRACKERS)Enum.Parse(typeof(FACETTRACKERS), pieces[3]);
            }
            else
            {
                subpiece             = pieces[3].Split(',');
                center_of_rotation   = new Point(int.Parse(subpiece[0]), int.Parse(subpiece[1]));
                center_of_rotation.X = width * 12 - center_of_rotation.X;
                center_of_rotation.Y = height * 12 - center_of_rotation.Y;

                rotation_type = (FACETTRACKERS)Enum.Parse(typeof(FACETTRACKERS), pieces[4]);
            }
        }
Example #2
0
        public void receive_chat(NetIncomingMessage p, Exilania g, Display d, World w)
        {
            byte   player_id = p.ReadByte();
            string msg       = p.ReadString();

            if (player_id < w.players.Count)
            {
                if (msg[0] == '!' && Exilania.gstate == 100)
                {
                    for (int i = 0; i < msg.Length; i++)
                    {
                        if (msg[i] == '!')
                        {
                            msg = msg.Substring(0, i) + msg.Substring(i + 1);
                            break;
                        }
                    }
                    d.fading_text.Add(new FadeText("@00" + msg, 3000, (int)w.players[player_id].avatar.world_loc.X,
                                                   (int)w.players[player_id].avatar.world_loc.Y - 60, true, TargetType.Player, player_id, w));
                }
                else
                {
                    d.add_message("@05" + w.players[player_id].avatar.name + "@00: " + msg);
                }
                Exilania.text_stream.WriteLine("@05" + w.players[player_id].avatar.name + "@00: " + msg);
            }
            else
            {
                d.add_message("@05New Player@00: " + msg);
                Exilania.text_stream.WriteLine(Acc.sanitize_text_color("@05New Player@00: " + msg));
            }
        }
Example #3
0
 public bool check_is_recipe_valid(CraftRecipe r, Actor a, World w)
 {
     for (int x = 0; x < r.input.Count; x++)
     {
         item_descriptor t = Acc.get_item_by_name(r.input[x].Key);
         if (t.item_type == ItemType.Empty || t.item_id == -1 || !a.items.has_item(t.item_type, t.item_id, r.input[x].Value))
         {
             return(false);
         }
     }
     for (int x = 0; x < r.furniture_require.Length; x++)
     {
         bool contained = false;
         for (int i = 0; i < id_nearby_furniture.Count; i++)
         {
             if (Exilania.furniture_manager.furniture[w.furniture[id_nearby_furniture[i]].furniture_id].name.ToLower() == r.furniture_require[x].ToLower())
             {
                 contained = true;
             }
         }
         if (!contained)
         {
             return(false);
         }
     }
     return(true);
 }
Example #4
0
        public bool apply_use_action(World w, Point world_loc)
        {
            if (use_action == "")
            {
                return(false);
            }

            string command = Acc.script_remove_content_of_outer_parenthesis(use_action);
            string passed  = Acc.script_remove_outer_parentheses(use_action).ToLower();

            switch (command.Trim().ToLower())
            {
            case "plant":
                if (Exilania.plant_manager.spawn_plant_in_world(w, world_loc, passed))
                {
                    if (!Exilania.game_server)
                    {
                        Exilania.network_client.send_place_plant(w, w.plants.Count - 1);
                    }
                    return(true);
                }
                break;
            }


            return(false);
        }
Example #5
0
        public void draw_night(SpriteBatch s, Display d)
        {
            int   star_radius = (int)Acc.get_distance(0, 0, Exilania.screen_size.X / 2, Exilania.screen_size.Y) + 15;
            Color draw_stars  = Color.White;

            if (percent_night < .1f)
            {
                draw_stars.A = (byte)(255f * 10f * percent_night);
                draw_stars.R = draw_stars.A;
                draw_stars.B = draw_stars.A;
                draw_stars.G = draw_stars.A;
            }
            else if (percent_night > .9f)
            {
                draw_stars.A = (byte)(255f * 10f * (1f - percent_night));
                draw_stars.R = draw_stars.A;
                draw_stars.B = draw_stars.A;
                draw_stars.G = draw_stars.A;
            }
            s.Draw(d.backgrounds, new Rectangle(Exilania.screen_size.X / 2, Exilania.screen_size.Y, star_radius * 2, star_radius * 2), star_frame, draw_stars,
                   (star_rotation * .25f) + (float)(Math.PI * 2f / 3f), new Vector2(star_frame.Width / 2, star_frame.Height / 2), SpriteEffects.None, 0);
            s.Draw(d.backgrounds, new Rectangle(Exilania.screen_size.X / 2, Exilania.screen_size.Y, star_radius * 2, star_radius * 2), star_frame, draw_stars,
                   (star_rotation * .5f) + (float)(Math.PI * 4f / 3f), new Vector2(star_frame.Width / 2, star_frame.Height / 2), SpriteEffects.None, 0);
            s.Draw(d.backgrounds, new Rectangle(Exilania.screen_size.X / 2, Exilania.screen_size.Y, star_radius * 2, star_radius * 2), star_frame, draw_stars,
                   star_rotation, new Vector2(star_frame.Width / 2, star_frame.Height / 2), SpriteEffects.None, 0);

            int mag = 4;

            s.Draw(d.backgrounds, new Rectangle(screen_loc.X - (16 * mag), screen_loc.Y - (16 * mag), mag * 32, mag * 32), phase_images[13], draw_stars);
            s.Draw(d.backgrounds, new Rectangle(screen_loc.X - (16 * mag), screen_loc.Y - (16 * mag), mag * 32, mag * 32), phase_images[cur_day_num % 14], Color.White);
        }
Example #6
0
        public List <int> get_power_furniture_in_range(int my_furniture_id, Point loc, int range, World w)
        {
            List <int> my_ret = new List <int>();
            Point      center = new Point(loc.X, loc.Y);

            loc.X /= 24 * block_size_cell;
            if (loc.X >= cells.GetLength(0))
            {
                loc.X -= cells.GetLength(0);
            }
            else if (loc.X < 0)
            {
                loc.X += cells.GetLength(0);
            }
            loc.Y /= 24 * block_size_cell;
            Point loc_use = new Point();

            for (int x = loc.X - 1; x <= loc.X + 1; x++)
            {
                for (int y = loc.Y - 1; y <= loc.Y + 1; y++)
                {
                    loc_use = new Point(x, y);
                    if (loc_use.X >= cells.GetLength(0))
                    {
                        loc_use.X -= cells.GetLength(0);
                    }
                    else if (loc_use.X < 0)
                    {
                        loc_use.X += cells.GetLength(0);
                    }
                    if (loc_use.Y > -1 && loc_use.Y < cells.GetLength(1))
                    {
                        for (int i = 0; i < cells[loc_use.X, loc_use.Y].furniture_ids.Count; i++)
                        {
                            if (cells[loc_use.X, loc_use.Y].furniture_ids[i] != my_furniture_id &&
                                w.furniture[cells[loc_use.X, loc_use.Y].furniture_ids[i]].share_power != 255 &&
                                (w.furniture[my_furniture_id].share_power == 255 || w.furniture[cells[loc_use.X, loc_use.Y].furniture_ids[i]].share_power > w.furniture[my_furniture_id].share_power) &&
                                !my_ret.Contains(cells[loc_use.X, loc_use.Y].furniture_ids[i]) &&
                                !w.furniture[cells[loc_use.X, loc_use.Y].furniture_ids[i]].flags[(int)FFLAGS.EMPTY])
                            {
                                my_ret.Add(cells[loc_use.X, loc_use.Y].furniture_ids[i]);
                            }
                        }
                    }
                }
            }

            for (int x = 0; x < my_ret.Count; x++)
            {
                if (Acc.get_distance(center, w.furniture[my_ret[x]].get_rect().Center) > range)
                {
                    my_ret.RemoveAt(x);
                    x--;
                }
            }
            return(my_ret);
        }
Example #7
0
        public void update_choose_name(Input input, Exilania e)
        {
            if (input.key_input.Length > 30)
            {
                input.key_input = input.key_input.Substring(0, 30);
            }
            chosen_world_name = input.key_input.Trim();
            if (input.mouse_cur_spot.X < Exilania.screen_size.X / 2 - 200 || input.mouse_cur_spot.X > Exilania.screen_size.X / 2 + 100)
            {
                cur_hover = -1;
                return;
            }
            if (input.mouse_now.Y < Exilania.screen_size.Y * (.30f))
            {
                cur_hover = -1;
            }
            else if (input.mouse_now.Y > Exilania.screen_size.Y - 100)
            {
                cur_hover = -2;
            }
            else
            {
                float loc = (float)input.mouse_now.Y / (float)Exilania.screen_size.Y;
                loc      -= .285f;
                cur_hover = (int)(loc * 100f) / 5;
            }
            if (input.left_clicked && input.mouse_now.X > -1 && input.mouse_now.Y > -1 &&
                input.mouse_now.X <= Exilania.screen_size.X && input.mouse_now.Y <= Exilania.screen_size.Y && e.IsActive)
            {
                input.left_clicked = false;
                switch (cur_hover)
                {
                case -2:     //you have chosen to create the world... continue?
                    if (Acc.sanitize_text_color(input.key_input.Trim()).Length >= 5 && cur_option > -1)
                    {
                        chosen_world_name     = input.key_input.Trim();
                        input.key_input       = "";
                        world_template        = cur_option;
                        making                = new World(chosen_world_name, Exilania.seed_id, (int)(System.DateTime.Now.Ticks / 1000));
                        cur_info_text         = "Initializing.";
                        Exilania.gstate       = 92;
                        creation_state        = -1;
                        creation_fine_control = 0;
                        Exilania.disable_chat = false;
                    }
                    break;

                default:     //learn more about a world type.
                    if (cur_hover > -1)
                    {
                        cur_option = cur_hover;
                    }
                    break;
                }
            }
        }
Example #8
0
        public void draw_text_with_outline(SpriteBatch s, SpriteFont sf, string text, int x_start, int y_start, int max_width, AccColors c_use)
        {
            string sanitized = "@" + ((int)c_use).ToString().PadLeft(2, '0') + Acc.sanitize_text_color(text);

            for (int i = 0; i < World.xes.Length; i++)
            {
                draw_text(s, small_font, sanitized, x_start + (World.xes[i] * 2), y_start + (World.yes[i] * 2), max_width);
            }
            draw_text(s, small_font, text, x_start, y_start, max_width);
        }
Example #9
0
 public PlantPiece(string vals)
 {
     string[] halves = vals.Split('|');
     halves[0] = halves[0].Trim();
     halves[1] = halves[1].Trim();
     string[] pair = halves[0].Split('=');
     name = pair[0];
     pair = pair[1].Split(',');
     if (pair[0].Contains('-'))
     { //variable width
         string[] temp = pair[0].Split('-');
         width_min = int.Parse(temp[0]);
         width_max = int.Parse(temp[1]);
         if (width_max < width_min)
         {
             int t2 = width_min;
             width_min = width_max;
             width_max = t2;
         }
     }
     else
     { //non variable width
         width_max = int.Parse(pair[0]);
         width_min = width_max;
     }
     if (pair[1].Contains('-'))
     { //variable height
         string[] temp = pair[1].Split('-');
         height_min = int.Parse(temp[0]);
         height_max = int.Parse(temp[1]);
         if (height_max < height_min)
         {
             int t2 = height_min;
             height_min = height_max;
             height_max = t2;
         }
     }
     else
     { //non variable height
         height_max = int.Parse(pair[1]);
         height_min = height_max;
     }
     //interpret half 1 now!, the images.
     if (Acc.script_remove_content_of_outer_parenthesis(halves[1]).ToLower() == "rand")
     {
         random_images = true;
     }
     halves[1] = Acc.script_remove_outer_parentheses(halves[1]);
     halves    = halves[1].Split(',');
     images    = new int[halves.Length];
     for (int x = 0; x < halves.Length; x++)
     {
         images[x] = int.Parse(halves[x]);
     }
 }
Example #10
0
        public void draw_choosing_menu(SpriteBatch s, Display d)
        {
            string add_beginning = "@00";

            s.Draw(d.planet_bkd, new Rectangle((Exilania.screen_size.X / 2) - (1920 / 2), (Exilania.screen_size.Y / 2) - (1080 / 2), 1920, 1080), new Rectangle(0, 0, 1920, 1080), Color.White);
            Vector2 size_text = d.font.MeasureString("World Creation Menu");

            d.draw_text(s, d.font, "@05World Creation Menu", Exilania.screen_size.X / 2 - (int)size_text.X / 2, 10, Exilania.screen_size.X);
            s.Draw(d.Exilania_title, new Rectangle(Exilania.screen_size.X - 400, (int)((float)Exilania.screen_size.Y - 100), 392, 87), new Rectangle(0, 0, 392, 87), Color.White);

            for (int x = 0; x < diff_worlds.Count; x++)
            {
                if (x == cur_option)
                {
                    add_beginning = "@05";
                }
                else if (x == cur_hover)
                {
                    add_beginning = "@08";
                }
                else
                {
                    add_beginning = "@00";
                }
                d.draw_text(s, d.middle_font, add_beginning + diff_worlds[x].ToString(), Exilania.screen_size.X / 2 - 166, (int)((float)Exilania.screen_size.Y * (.30f + ((float)x * .05f))), Exilania.screen_size.X / 2);
            }

            string fix_text = "";

            if (Acc.sanitize_text_color(chosen_world_name).Length >= 5 && cur_option > -1)
            {
                add_beginning = "@05";
            }
            else
            {
                if (Acc.sanitize_text_color(chosen_world_name).Length < 5)
                {
                    fix_text += "Type a name for this world. It must have at least 5 characters.";
                }
                if (cur_option < 0)
                {
                    fix_text += " You must choose a template.";
                }
                add_beginning = "@08";
            }
            if (fix_text != "")
            {
                Vector2 meas = d.middle_font.MeasureString(fix_text);
                d.draw_text(s, d.middle_font, "@00" + fix_text,
                            Exilania.screen_size.X / 2 - (int)(meas.X / 2), (int)((float)Exilania.screen_size.Y - 150), Exilania.screen_size.X);
            }
            d.draw_text(s, d.middle_font, add_beginning + "[ Click to Generate World ]", Exilania.screen_size.X / 2 - 166, (int)((float)Exilania.screen_size.Y - 60), Exilania.screen_size.X / 2);
            d.draw_text(s, d.middle_font, "@00World Name: " + chosen_world_name, Exilania.screen_size.X / 2 - 166, (int)((float)Exilania.screen_size.Y - 200), Exilania.screen_size.X / 2);
        }
Example #11
0
 public void take_item_requirements(CraftRecipe r, Actor a, World w)
 {
     for (int x = 0; x < r.input.Count; x++)
     {
         item_descriptor t = Acc.get_item_by_name(r.input[x].Key);
         if (t.item_type != ItemType.Empty && t.item_id != -1)
         {
             a.items.use_item(a, t.item_type, t.item_id, r.input[x].Value);
         }
     }
 }
Example #12
0
        public List <int> get_players_in_range(Point loc, int range, World w)
        {
            List <int> my_ret = new List <int>();
            Point      center = new Point(loc.X, loc.Y);

            loc.X /= 24 * block_size_cell;
            if (loc.X >= cells.GetLength(0))
            {
                loc.X -= cells.GetLength(0);
            }
            else if (loc.X < 0)
            {
                loc.X += cells.GetLength(0);
            }
            loc.Y /= 24 * block_size_cell;
            Point loc_use = new Point();

            for (int x = loc.X - 1; x <= loc.X + 1; x++)
            {
                for (int y = loc.Y - 1; y <= loc.Y + 1; y++)
                {
                    loc_use = new Point(x, y);
                    if (loc_use.X >= cells.GetLength(0))
                    {
                        loc_use.X -= cells.GetLength(0);
                    }
                    else if (loc_use.X < 0)
                    {
                        loc_use.X += cells.GetLength(0);
                    }
                    if (loc_use.Y > -1 && loc_use.Y < cells.GetLength(1))
                    {
                        for (int i = 0; i < cells[loc_use.X, loc_use.Y].player_ids.Count; i++)
                        {
                            if (!my_ret.Contains(cells[loc_use.X, loc_use.Y].player_ids[i]))
                            {
                                my_ret.Add(cells[loc_use.X, loc_use.Y].player_ids[i]);
                            }
                        }
                    }
                }
            }

            for (int x = 0; x < my_ret.Count; x++)
            {
                if (w.players[my_ret[x]].is_player_empty || Acc.get_distance(w.players[my_ret[x]].avatar.world_loc, center) > range)
                {
                    my_ret.RemoveAt(x);
                    x--;
                }
            }
            return(my_ret);
        }
Example #13
0
        public void draw_fade_text(SpriteBatch s, Vector2 top_left)
        {
            Vector2 size_string;
            int     left, top;
            byte    use;

            for (int x = 0; x < fading_text.Count; x++)
            {
                size_string = small_font.MeasureString(Acc.sanitize_text_color(fading_text[x].text));
                if (size_string.X >= Exilania.screen_size.X || size_string.Y >= Exilania.screen_size.Y)
                {
                    fading_text.RemoveAt(x);
                    x--;
                }
                else
                {
                    if (fading_text[x].world_loc)
                    {
                        left = fading_text[x].loc.X - (int)(size_string.X / 2) - (int)top_left.X;
                        top  = fading_text[x].loc.Y - (int)(size_string.Y / 2) - (int)top_left.Y;
                    }
                    else
                    {
                        left = fading_text[x].loc.X - (int)(size_string.X / 2);
                        top  = fading_text[x].loc.Y - (int)(size_string.Y / 2);
                    }
                    if (fading_text[x].time_left <0 && fading_text[x].time_left> -255)
                    {
                        use = (byte)((255 + fading_text[x].time_left) / 2);
                        //use.A = Convert.ToByte(255 + fading_text[x].time_left);
                    }
                    else
                    {
                        use = 255;
                    }
                    if (fading_text[x].time_left > -256)
                    {
                        string sanitized = "@31" + Acc.sanitize_text_color(fading_text[x].text);
                        for (int i = 0; i < World.xes.Length; i++)
                        {
                            draw_text(s, small_font, sanitized, left + (World.xes[i] * 2), top + (World.yes[i] * 2), (int)size_string.X, use);
                        }
                        draw_text(s, small_font, fading_text[x].text, left, top, (int)size_string.X, use);
                    }
                    if (fading_text[x].time_left <= -255)
                    {
                        fading_text.RemoveAt(x);
                        x--;
                    }
                }
            }
        }
Example #14
0
 public FrameFurniture(string read_in)
 {
     string[] split      = read_in.Split('|');
     string[] size_split = split[0].Split(',');
     split  = Acc.get_inner_parenthesis(split[1]).Split(',');
     width  = byte.Parse(size_split[0]);
     height = byte.Parse(size_split[1]);
     images = new int[split.Length];
     for (int x = 0; x < images.Length; x++)
     {
         images[x] = int.Parse(split[x]);
     }
 }
Example #15
0
        public List <int> get_plants_in_range(Point loc, World w, int range, bool hit_nonbreakablebelow, bool facing_right)
        {
            List <int> hit_plants = new List <int>();
            int        srange     = (int)Math.Ceiling((double)range / 24);

            int min_x = srange;
            int max_x = srange;

            if (facing_right)
            {
                min_x = 1;
            }
            else
            {
                max_x = 0;
            }
            for (int x = (loc.X / 24) - min_x; x < (loc.X / 24) + max_x + 1; x++)
            {
                for (int y = (loc.Y / 24) - srange; y < (loc.Y / 24) + srange; y++)
                {
                    w.areas_checked.Add(new Point(x, y));
                    if (y > -1 && y < w.map.GetLength(1) && w.map[w.wraparound_x(x), y].plant_index != -1 &&
                        (Acc.get_distance(new Point(loc.X, loc.Y), new Point(x * 24, y * 24)) <= range ||
                         Acc.get_distance(new Point(loc.X, loc.Y), new Point(x * 24 + 24, y * 24)) <= range ||
                         Acc.get_distance(new Point(loc.X, loc.Y), new Point(x * 24 + 24, y * 24 + 24)) <= range ||
                         Acc.get_distance(new Point(loc.X, loc.Y), new Point(x * 24, y * 24 + 24)) <= range))
                    {
                        //we have a plant!
                        int plant_id = w.map[w.wraparound_x(x), y].plant_index;
                        if (!hit_plants.Contains(plant_id) && (hit_nonbreakablebelow == true || Exilania.plant_manager.plants[w.plants[plant_id].plant_index].break_below))
                        {
                            hit_plants.Add(plant_id);
                        }
                    }
                }
            }
            return(hit_plants);
        }
Example #16
0
        /// <summary>
        /// used to draw the furniture item in question in a non-normal orientation... uses the center of the image as the origin of rotation
        /// </summary>
        /// <param name="s"></param>
        /// <param name="top_left"></param>
        public void draw_rotated_facet(SpriteBatch s, World w)
        {
            Point size_drawing = new Point(Exilania.furniture_manager.furniture[furniture_template_id].facets[facet_template_id].width,
                                           Exilania.furniture_manager.furniture[furniture_template_id].facets[facet_template_id].height);

            int[]     imgs = Exilania.furniture_manager.furniture[furniture_template_id].facets[facet_template_id].images;
            Rectangle t    = w.furniture[w.map[world_furniture_loc.X, world_furniture_loc.Y].furniture_index].get_rect();

            t.X -= (int)w.top_left.X;
            t.Y -= (int)w.top_left.Y;


            //the line between the center of the parent and the center of the block depends upon base distance and upon current rotation:
            Vector2 cur_loc_delta = new Vector2();
            double  dist;
            double  this_angle = 0;
            int     x_offset   = 12;
            int     y_offset   = 12;
            Point   color_use  = new Point();

            for (int x = 0; x < size_drawing.X; x++)
            {
                for (int y = 0; y < size_drawing.Y; y++)
                {
                    x_offset        = ((t.Width / 24) - size_drawing.X) * 12 + 12 + center_of_rotation.X;
                    y_offset        = ((t.Height / 24) - size_drawing.Y) * 12 + 12 + center_of_rotation.Y;
                    dist            = Acc.get_distance(new Point(t.Width / 2, t.Height / 2), new Point(x * 24 + x_offset, y * 24 + y_offset));
                    this_angle      = Math.Atan2((y * 24) + y_offset - (t.Height / 2), (x * 24) + x_offset - (t.Width / 2)) + rotation;
                    cur_loc_delta.X = (float)(Math.Cos(this_angle) * dist);
                    cur_loc_delta.Y = (float)(Math.Sin(this_angle) * dist);
                    color_use       = new Point(w.wraparound_x(((int)w.top_left.X + t.X + (int)cur_loc_delta.X + 12) / 24),
                                                ((int)w.top_left.Y + t.Y + (int)cur_loc_delta.Y + 12) / 24);
                    Exilania.display.draw_rotated_image(s, t, new Vector2(offset_facet.X, offset_facet.Y), cur_loc_delta, rotation,
                                                        w.map[color_use.X, color_use.Y].light_level, imgs[y * size_drawing.X + x], false);
                }
            }
        }
Example #17
0
        public string modify_settings(string new_setting, World w)
        {
            string returner = "@07";

            string[] items = new_setting.Split(':');
            if (items.Length > 2)
            {
                for (int i = 2; i < items.Length; i++)
                {
                    items[1] += ":" + items[i];
                }
            }
            if (items.Length > 1 && items[1].Length > 0)
            {
                switch (items[0])
                {
                case "mastervolume":
                    if (items[1].Contains('.'))
                    {
                        Exilania.sounds.master_volume = float.Parse(items[1]);
                    }
                    else
                    {
                        Exilania.sounds.master_volume = ((float)int.Parse(items[1])) / 100f;
                    }
                    if (Exilania.sounds.master_volume < 0f)
                    {
                        Exilania.sounds.master_volume = 0f;
                    }
                    if (Exilania.sounds.master_volume > 1f)
                    {
                        Exilania.sounds.master_volume = 1f;
                    }
                    returner += "@07Master Volume set to " + (Exilania.sounds.master_volume * 100) + ".";
                    break;

                case "give":
                    if (w != null && Exilania.game_my_user_id < w.players.Count && w.players.Count > 0)
                    {
                        string[]        info     = items[1].Split(':');
                        ushort          quantity = 10;
                        item_descriptor cur_item = Acc.get_item_by_name(info[0]);
                        if (info.Length >= 2)
                        {
                            try
                            {
                                quantity = ushort.Parse(info[1]);
                            }
                            catch
                            {
                                quantity = 10;
                            }
                        }
                        if (cur_item.item_id > -1)
                        {
                            switch (cur_item.item_type)
                            {
                            case ItemType.Block:
                                w.players[Exilania.game_my_user_id].avatar.items.pickup_block((sbyte)cur_item.item_id, quantity);
                                returner += info[0] + " qauntity " + quantity + " given.";
                                break;

                            case ItemType.Material:
                                w.players[Exilania.game_my_user_id].avatar.items.pickup_material((sbyte)cur_item.item_id, quantity);
                                returner += info[0] + " qauntity " + quantity + " given.";
                                break;

                            case ItemType.Furniture:
                                w.players[Exilania.game_my_user_id].avatar.items.pickup_furniture((sbyte)cur_item.item_id, quantity);
                                returner += info[0] + " qauntity " + quantity + " given.";
                                break;

                            default:
                                returner += "@08Feature not added, yet.";
                                break;
                            }
                        }
                        else
                        {
                            returner += "@08What is a '" + info[0] + "'?";
                        }
                    }
                    else
                    {
                        returner += "@08Start a game first.";
                    }
                    break;

                case "eval":
                    int val_get = Acc.resolve_die_roll(items[1], 0, 0);
                    returner += items[1] + "= " + val_get;
                    break;

                case "time":
                    if (w != null)
                    {
                        try
                        {
                            if (Exilania.game_server)
                            {
                                items = items[1].Split(':');
                                int minutes = 0;
                                int hours   = 0;
                                if (items.Length > 1)
                                {
                                    minutes = int.Parse(items[1]);
                                    if (minutes < 10)
                                    {
                                        minutes *= 10;
                                    }
                                    minutes %= 60;
                                }
                                hours = int.Parse(items[0]) % 24;
                                int cur_day = (int)(w.world_time / w.day_length);
                                cur_day++;
                                w.world_time  = (float)cur_day * w.day_length;
                                w.world_time += ((float)hours - 6) / 24f * w.day_length;
                                Exilania.display.add_message("@00Hour Debug: " + ((float)hours) / 24f);
                                w.world_time += ((float)minutes) / 1440f * w.day_length;
                                returner     += "Time set to " + hours.ToString().PadLeft(2, '0') + ":" + minutes.ToString().PadLeft(2, '0') + ".";
                            }
                            else
                            {
                                returner += "@06Admin access only.";
                            }
                        }
                        catch
                        {
                            returner += "@06Unsupported time format please use HH:MM (24H Clock)";
                        }
                    }
                    else
                    {
                        returner += "@06FOR USE ONLY IN-GAME.";
                    }
                    break;

                case "liquiddebugging":
                    try
                    {
                        liquid_debugging = bool.Parse(items[1]);
                        returner        += "Liquid Debugging set to " + liquid_debugging.ToString() + ".";
                    }
                    catch
                    {
                        liquid_debugging = false;
                        returner        += "@06Improper Formatting. Liquid Debugging set to false.@07";
                    }
                    break;

                case "highdefwindowheight":
                    try
                    {
                        highdef_window_size.Y = int.Parse(items[1]);
                        returner += "HighDef Window Height set to " + highdef_window_size.Y.ToString() + ".";
                    }
                    catch
                    {
                        highdef_window_size.Y = 1000;
                        returner += "@06Improper Formatting. HighDef Window Height set to 1000.@07";
                    }
                    break;

                case "highdefwindowwidth":
                    try
                    {
                        highdef_window_size.X = int.Parse(items[1]);
                        returner += "HighDef Window Width set to " + highdef_window_size.X.ToString() + ".";
                    }
                    catch
                    {
                        highdef_window_size.X = 2600;
                        returner += "@06Improper Formatting. HighDef Window Width set to 2600.@07";
                    }
                    break;

                case "msecshowchat":
                    try
                    {
                        msec_show_chat = int.Parse(items[1]);
                        returner      += "Msec show chat now set to " + msec_show_chat.ToString() + "ms.";
                        Display.show_received_chat_time = (float)msec_show_chat / 1000f;
                    }
                    catch
                    {
                        msec_show_chat = 5000;
                        Display.show_received_chat_time = (float)msec_show_chat / 1000f;
                        returner += "@06Improper Formatting. Msec show chat set to 5000.@07";
                    }
                    break;

                case "showchatbackground":
                    try
                    {
                        show_chat_background = bool.Parse(items[1]);
                        returner            += "Show Chat Background now set to " + show_chat_background.ToString() + ".";
                    }
                    catch
                    {
                        show_chat_background = true;
                        returner            += "@06Improper Formatting. Show Chat Background set to true.@07";
                    }
                    break;

                case "max_users":
                    try
                    {
                        int temp = int.Parse(items[1]);
                        if (temp > 255)
                        {
                            temp = 255;
                        }
                        max_users = (byte)temp;
                        returner += "Max Users now set to " + max_users.ToString() + ".";
                    }
                    catch
                    {
                        max_users = 32;
                        returner += "@06Improper Formatting. Max Users now set to 32.@07";
                    }
                    break;

                case "forcenewcharacter":
                    try
                    {
                        force_new_character = Boolean.Parse(items[1]);
                        returner           += "Force New Character now set to " + force_new_character.ToString() + ".";
                    }
                    catch
                    {
                        force_new_character = false; returner += "@06Improper Formatting. Force New Character now set to False.@07";
                    }
                    break;

                case "allowstrobe":
                    try
                    {
                        allow_strobe = Boolean.Parse(items[1]);
                        returner    += "Strobing Text now set to " + allow_strobe.ToString() + ".";
                    }
                    catch
                    {
                        allow_strobe = false; returner += "@06Improper Formatting. Strobing Text now set to False.@07";
                    }
                    break;

                case "use_seed":
                    use_seed  = Boolean.Parse(items[1]);
                    returner += "use seed now set to " + use_seed.ToString() + ". Rand reset.";
                    if (use_seed)
                    {
                        Exilania.rand = new Lidgren.Network.NetRandom(seed_id);
                    }
                    else
                    {
                        Exilania.rand = new Lidgren.Network.NetRandom((int)System.DateTime.Now.Ticks);
                    }
                    break;

                case "seed_id":
                    try { seed_id = Int32.Parse(items[1]); }
                    catch { seed_id = 10; returner += "@06Improper Formatting. @07"; }
                    returner += "random seed now set to " + seed_id.ToString() + ",";
                    if (use_seed)
                    {
                        Exilania.rand = new Lidgren.Network.NetRandom(seed_id);
                        returner     += " Rand reset.";
                    }
                    break;

                case "debugging":
                    try
                    {
                        debugging = Boolean.Parse(items[1]);
                    }
                    catch
                    {
                        returner += "@06Improper Formatting. @07";
                        debugging = false;
                    }
                    Exilania.draw_debug = debugging;
                    returner           += "Debug changed to " + debugging.ToString() + ".";
                    break;

                case "levelupheal":
                    levelupheal = Int32.Parse(items[1]);
                    returner   += "Levelupheal changed to " + levelupheal.ToString() + ".";
                    break;

                case "serveripaddress":
                    server_ip = items[1];
                    returner += "serveripaddress changed to " + server_ip + ".";
                    break;

                case "serverport":
                    try
                    {
                        server_port = UInt16.Parse(items[1]);
                    }
                    catch
                    {
                        server_port = 50231;
                    }
                    returner += "serverport changed to " + server_port.ToString() + ".";
                    break;

                case "clientport":
                    try
                    {
                        client_port = UInt16.Parse(items[1]);
                    }
                    catch
                    {
                        client_port = 50232;
                    }
                    returner += "clientport changed to " + client_port.ToString() + ".";
                    break;

                case "help":
                    returner += "@05Use commands found in the Exilania.ini text file to commit changes.";
                    break;

                case "usecustomdimensions":
                    try
                    {
                        use_custom_dimensions = Boolean.Parse(items[1]);
                        returner += " usecustomdimensions changed to " + use_custom_dimensions.ToString() + ".";
                    }
                    catch
                    {
                        returner += "@06Improper Formatting! @07";
                        use_custom_dimensions = false;
                    }
                    break;

                case "customwidth":
                    try
                    {
                        custom_width = Int32.Parse(items[1]);
                        returner    += "customwidth set to " + custom_width.ToString() + ".";
                    }
                    catch
                    {
                        custom_width = 1920;
                        returner    += "@06Improper Formatting! @07";
                    }
                    break;

                case "customheight":
                    try
                    {
                        custom_height = Int32.Parse(items[1]);
                        returner     += "customheight set to " + custom_height.ToString() + ".";
                    }
                    catch
                    {
                        custom_height = 1080;
                        returner     += "@06Improper Formatting! @07";
                    }
                    break;

                case "usehardwarelighting":
                    try
                    {
                        use_hardware_lighting = Boolean.Parse(items[1]);
                        returner += "Use Hardware lighting set to " + use_hardware_lighting.ToString() + ".";
                    }
                    catch
                    {
                        use_hardware_lighting = false;
                        returner += "@06Improper Formatting; Use Hardware Lighting set to false.";
                    }
                    break;

                case "worldloadname":
                    try
                    {
                        world_load_name = items[1];
                        returner       += "World to load changed to " + world_load_name + ".";
                    }
                    catch
                    {
                        world_load_name = "Default World 1";
                        returner       += "@06Improper Formatting; World to Load now 'Default World 1'.";
                    }
                    break;

                case "showping":
                    try
                    {
                        show_ping = bool.Parse(items[1]);
                        returner += "Show Ping changed to " + show_ping + ".";
                    }
                    catch
                    {
                        show_ping = true;
                        returner  = "@06Improper Formatting; Show Ping set to true.";
                    }
                    break;

                default:
                    returner += "@05unrecognized command. @06'/" + new_setting + "'@05.";
                    break;
                }
            }
            else
            {
                returner += "@05Missing command parameters for command @06'" + items[0] + "'@05.";
            }
            return(returner);
        }
Example #18
0
        public void give_items(Actor a, int replicate)
        {
            bool match_found = false;

            for (int x = 0; x < replicate; x++)
            {
                foreach (var pair in Exilania.plant_manager.plants[plant_index].drops)
                {
                    if (Exilania.rand.Next(0, 101) <= pair.Value)
                    {
                        item_descriptor t = Acc.get_item_by_name(pair.Key);
                        switch (t.item_type)
                        {
                        case ItemType.Block:
                            a.items.pickup_block((sbyte)t.item_id);
                            match_found = false;
                            for (int i = 0; i < gives.Count; i++)
                            {
                                if (gives[i].type == ItemType.Block && gives[i].id == t.item_id)
                                {
                                    match_found = true;
                                    gives[i].count++;
                                    i = gives.Count;
                                }
                            }
                            if (!match_found)
                            {
                                gives.Add(new DisplayGive(1, ItemType.Block, t.item_id));
                            }
                            break;

                        case ItemType.Empty:
                            break;

                        case ItemType.Furniture:
                            a.items.pickup_furniture(t.item_id, 1);
                            match_found = false;
                            for (int i = 0; i < gives.Count; i++)
                            {
                                if (gives[i].type == ItemType.Furniture && gives[i].id == t.item_id)
                                {
                                    match_found = true;
                                    gives[i].count++;
                                    i = gives.Count;
                                }
                            }
                            if (!match_found)
                            {
                                gives.Add(new DisplayGive(1, ItemType.Furniture, t.item_id));
                            }
                            break;

                        case ItemType.ItemPiece:
                            Item temp = new Item();
                            temp.add_piece(Exilania.item_manager.item_pieces[t.item_id], t.item_id, -1, 0, 0, 0);
                            temp.construct_item(Exilania.item_manager.item_pieces[t.item_id].name);
                            a.items.pickup_item(temp);
                            match_found = false;
                            for (int i = 0; i < gives.Count; i++)
                            {
                                if (gives[i].type == ItemType.ItemPiece && gives[i].id == t.item_id)
                                {
                                    match_found = true;
                                    gives[i].count++;
                                    i = gives.Count;
                                }
                            }
                            if (!match_found)
                            {
                                gives.Add(new DisplayGive(1, ItemType.ItemPiece, t.item_id));
                            }
                            break;

                        case ItemType.Material:
                            a.items.pickup_material(t.item_id, 1);
                            match_found = false;
                            for (int i = 0; i < gives.Count; i++)
                            {
                                if (gives[i].type == ItemType.Material && gives[i].id == t.item_id)
                                {
                                    match_found = true;
                                    gives[i].count++;
                                    i = gives.Count;
                                }
                            }
                            if (!match_found)
                            {
                                gives.Add(new DisplayGive(1, ItemType.Material, t.item_id));
                            }
                            break;
                        }
                        //give item to player!
                    }
                }
            }
        }
Example #19
0
        public PlantManager()
        {
            plants = new List <PlantData>();
            if (System.IO.File.Exists(@"plants.txt"))
            {
                System.IO.StreamReader r = new System.IO.StreamReader(@"plants.txt");
                string    line           = "";
                PlantData p    = new PlantData();
                bool      cont = true;
                while (cont)
                {
                    line = r.ReadLine();
                    if (line.Length == 0 || line[0] == '#')
                    {
                        //skip this line
                    }
                    else
                    {
                        string[] items = line.Split(':');
                        switch (items[0].ToLower())
                        {
                        case "name":
                            if (p.name == "")
                            {
                                p.name     = items[1].Trim();
                                p.plant_id = 0;
                            }
                            else
                            {
                                p.plant_id = (ushort)plants.Count;
                                p.get_height_range();
                                plants.Add(p);
                                Exilania.text_stream.WriteLine("Plant Item '" + p.name + "' Loaded.");
                                p      = new PlantData();
                                p.name = items[1].Trim();
                            }
                            break;

                        case "drops":
                            string[] pieces = items[1].Trim().Split(',');
                            if (items[1].Trim() != "")
                            {
                                for (int x = 0; x < pieces.Length; x++)
                                {
                                    pieces[x] = pieces[x].Trim();
                                    string key = Acc.script_remove_content_of_outer_parenthesis(pieces[x]);
                                    byte   val = byte.Parse(Acc.script_remove_outer_parentheses(pieces[x]));
                                    p.drops.Add(key, val);
                                }
                            }
                            break;

                        case "piece":
                            p.pieces.Add(new PlantPiece(items[1]));
                            break;

                        case "anatomy":
                            p.anatomy = items[1].Trim().Split(',');
                            break;

                        case "growson":
                            items = items[1].Trim().Split(',');
                            for (int x = 0; x < items.Length; x++)
                            {
                                if (items[x].Length > 0)
                                {
                                    p.grows_on.Add(items[x].Trim().ToLower());
                                }
                            }
                            break;

                        case "behavior-cut":
                            p.behavior_cut = items[1].Trim();
                            break;

                        case "min-distance":
                            p.min_distance = Int32.Parse(items[1]);
                            break;

                        case "density":
                            p.density = Int32.Parse(items[1]);
                            break;

                        case "break-below":
                            p.break_below = bool.Parse(items[1]);
                            break;

                        case "below-block-remove":
                            p.below_block_remove = bool.Parse(items[1]);
                            break;

                        case "material":
                            p.material = items[1].Trim().ToUpper();
                            break;

                        case "auto-spawn":
                            p.auto_spawn = bool.Parse(items[1]);
                            break;

                        case "growth":
                            string[] parts = items[1].Split('|');
                            for (int i = 0; i < parts.Length; i++)
                            {
                                p.growth_possibilities.Add(new Growth(parts[i]));
                            }
                            break;

                        case "extreme-height":
                            p.max_height = int.Parse(items[1]);
                            break;

                        default:
                            Exilania.text_stream.WriteLine("UNHANDLED type " + items[0]);
                            break;
                        }
                    }
                    if (r.EndOfStream)
                    {
                        p.plant_id = (ushort)plants.Count;
                        p.get_height_range();
                        plants.Add(p);
                        Exilania.text_stream.WriteLine("Plant Item '" + p.name + "' Loaded.");
                        cont = false;
                    }
                }
                r.Close();
            }
            else
            {
                Exilania.text_stream.Write("ERROR! No plants.txt file.");
            }
        }
Example #20
0
        public ParticleManager()
        {
            particles = new List <ParticleTemplate>();
            if (System.IO.File.Exists(@"particles.txt"))
            {
                System.IO.StreamReader r = new System.IO.StreamReader(@"particles.txt");
                string           line    = "";
                ParticleTemplate p       = new ParticleTemplate();
                bool             cont    = true;
                while (cont)
                {
                    line = r.ReadLine();
                    if (line.Length == 0 || line[0] == '#')
                    {
                        //skip this line
                    }
                    else
                    {
                        string[] items = line.Split(':');
                        switch (items[0].ToLower())
                        {
                        case "name":
                            if (p.name == "")
                            {
                                p.name = items[1].Trim();
                            }
                            else
                            {
                                particles.Add(p);
                                Exilania.text_stream.WriteLine("Particle Template '" + p.name + "' Loaded.");
                                p      = new ParticleTemplate();
                                p.name = items[1].Trim();
                            }
                            break;

                        case "pic":
                            string[] vals = Acc.script_remove_outer_parentheses(items[1]).Split(',');
                            p.image = new Rectangle(int.Parse(vals[0]), int.Parse(vals[1]), int.Parse(vals[2]), int.Parse(vals[3]));
                            break;

                        case "travel":
                            switch (items[1].ToLower())
                            {
                            case "straight":
                                p.travel_path = TravelType.Straight;
                                break;

                            case "boomerang":
                                p.travel_path = TravelType.Boomerang;
                                break;

                            case "piercing":
                                p.travel_path = TravelType.Piercing;
                                break;

                            case "bouncing":
                                p.travel_path = TravelType.Bouncy;
                                break;

                            case "graceful":
                                p.travel_path = TravelType.Graceful;
                                break;

                            case "haphazard":
                                p.travel_path = TravelType.Haphazard;
                                break;
                            }
                            break;

                        case "gravity":
                            p.gravity_affected = bool.Parse(items[1]);
                            break;

                        case "speed":
                            p.speed = float.Parse(items[1]);
                            break;

                        default:
                            Exilania.text_stream.WriteLine("UNHANDLED type " + items[0]);
                            break;
                        }
                    }
                    if (r.EndOfStream)
                    {
                        particles.Add(p);
                        Exilania.text_stream.WriteLine("Particle Template '" + p.name + "' Loaded.");
                        cont = false;
                    }
                }
                r.Close();
            }
            else
            {
                Exilania.text_stream.Write("ERROR! No furniture.txt file.");
            }
        }
Example #21
0
 public bool contains_point(Point loc)
 {
     return(Acc.get_distance(loc, Center) <= r);
 }
Example #22
0
        public CraftManager()
        {
            recipes = new List <CraftRecipe>();
            if (System.IO.File.Exists(@"craft_recipes.txt"))
            {
                System.IO.StreamReader r = new System.IO.StreamReader(@"craft_recipes.txt");
                string      line         = "";
                CraftRecipe p            = new CraftRecipe();
                bool        cont         = true;
                while (cont)
                {
                    line = r.ReadLine().Trim();
                    if (line.Length == 0 || line[0] == '#')
                    {
                        //skip this line
                    }
                    else
                    {
                        string[] items = line.Split(':');
                        switch (items[0].ToLower())
                        {
                        case "name":
                            if (p.name == "")
                            {
                                p.name = items[1].Trim();
                            }
                            else
                            {
                                p.crafting_id = (ushort)recipes.Count;
                                recipes.Add(p);
                                Exilania.text_stream.WriteLine("Crafting Recipe '" + p.name + "' Loaded.");
                                p      = new CraftRecipe();
                                p.name = items[1].Trim();
                            }
                            break;

                        case "output":
                            items = items[1].Split(',');
                            for (int i = 0; i < items.Length; i++)
                            {
                                item_descriptor t  = Acc.get_item_by_name(Acc.script_remove_content_of_outer_parenthesis(items[i]));
                                Output_Type     pr = new Output_Type(t.item_type, t.item_id, int.Parse(Acc.script_remove_outer_parentheses(items[i])));
                                p.output.Add(pr);
                            }
                            break;

                        case "input":
                            items = items[1].Split(',');
                            for (int x = 0; x < items.Length; x++)
                            {
                                p.input.Add(new KeyValuePair <string, int>(Acc.script_remove_content_of_outer_parenthesis(items[x]), int.Parse(Acc.script_remove_outer_parentheses(items[x]))));
                            }
                            break;

                        case "complexity":
                            p.complexity = int.Parse(items[1]);
                            break;

                        case "furniture-require":
                            items = items[1].Split(',');
                            p.furniture_require = new string[items.Length];
                            for (int x = 0; x < items.Length; x++)
                            {
                                p.furniture_require[x] = items[x];
                            }
                            break;

                        default:
                            Exilania.text_stream.WriteLine("UNHANDLED type " + items[0]);
                            break;
                        }
                    }
                    if (r.EndOfStream)
                    {
                        p.crafting_id = (ushort)recipes.Count;
                        recipes.Add(p);
                        Exilania.text_stream.WriteLine("Crafting Recipe '" + p.name + "' Loaded.");
                        cont = false;
                    }
                }
                r.Close();
                for (int x = 0; x < Exilania.item_manager.item_pieces.Count; x++)
                {
                    p      = new CraftRecipe();
                    p.name = Exilania.item_manager.item_pieces[x].name;
                    p.output.Add(new Output_Type(ItemType.ItemPiece, x, 1));
                    if (Exilania.item_manager.item_pieces[x].craft_require != "")
                    {
                        p.furniture_require = Exilania.item_manager.item_pieces[x].craft_require.Split(',');
                    }
                    else
                    {
                        p.furniture_require = new string[0];
                    }
                    if (Exilania.item_manager.item_pieces[x].materials.Count > 0)
                    {
                        foreach (var mats in Exilania.item_manager.item_pieces[x].materials)
                        {
                            p.input.Add(new KeyValuePair <string, int>(mats.Key, mats.Value));
                        }
                    }
                    p.complexity  = Exilania.item_manager.item_pieces[x].complexity;
                    p.crafting_id = (ushort)recipes.Count;
                    recipes.Add(p);
                    Exilania.text_stream.WriteLine("Crafting Recipe '" + p.name + "' Loaded.");
                }
                for (int x = 0; x < Exilania.furniture_manager.furniture.Count; x++)
                {
                    p      = new CraftRecipe();
                    p.name = Exilania.furniture_manager.furniture[x].name;
                    p.output.Add(new Output_Type(ItemType.Furniture, x, 1));
                    if (Exilania.furniture_manager.furniture[x].craft_require.Length > 0)
                    {
                        p.furniture_require = Exilania.furniture_manager.furniture[x].craft_require;
                    }
                    if (Exilania.furniture_manager.furniture[x].materials.Count > 0)
                    {
                        foreach (var mats in Exilania.furniture_manager.furniture[x].materials)
                        {
                            p.input.Add(new KeyValuePair <string, int>(mats.Key, mats.Value));
                        }
                    }
                    p.complexity  = Exilania.furniture_manager.furniture[x].complexity;
                    p.crafting_id = (ushort)recipes.Count;
                    recipes.Add(p);
                    Exilania.text_stream.WriteLine("Crafting Recipe '" + p.name + "' Loaded.");
                }
            }
            else
            {
                Exilania.text_stream.Write("ERROR! No craft_recipes.txt file.");
            }
        }
Example #23
0
        public ItemManager()
        {
            item_pieces        = new List <ItemPiece>();
            custom_item_images = new Dictionary <int, Texture2D>();

            if (System.IO.File.Exists(@"item_pieces.txt"))
            {
                System.IO.StreamReader r = new System.IO.StreamReader(@"item_pieces.txt");
                string    line           = "";
                ItemPiece p    = new ItemPiece();
                bool      cont = true;
                while (cont)
                {
                    line = r.ReadLine();
                    if (line[0] == '#')
                    {
                        //skip this line
                    }
                    else
                    {
                        string[] items = line.Split(':');
                        switch (items[0])
                        {
                        case "PIECE":
                            if (p.name == "")
                            {
                                p.name = items[1];
                            }
                            else
                            {
                                item_pieces.Add(p);
                                Exilania.text_stream.WriteLine("Item Piece '" + p.name + "' Loaded.");
                                p      = new ItemPiece();
                                p.name = items[1];
                            }
                            break;

                        case "IMAGE":
                            items   = Acc.get_inner_parenthesis(items[1]).Split(',');
                            p.image = new Rectangle(Int32.Parse(items[0]), Int32.Parse(items[1]), Int32.Parse(items[2]), Int32.Parse(items[3]));
                            break;

                        case "HAND-ATTACH":
                            items = items[1].Split(',');
                            p.hand_attach_point     = new Point(Int32.Parse(items[0]), Int32.Parse(items[1]));
                            p.has_hand_attach_point = true;
                            break;

                        case "ATTACH-POINT":
                            items = Acc.get_inner_parenthesis(items[1]).Split(',');
                            p.item_attach_points.Add(new Point(Int32.Parse(items[0]), Int32.Parse(items[1])));
                            break;

                        case "CLICK":
                            p.click_action += items[1];
                            break;

                        case "DATA":
                            items = items[1].Split('=');
                            p.data.Add(items[0], items[1]);
                            break;

                        case "BREAK-BLOCK":
                            items = items[1].Split(';');
                            for (int x = 0; x < items.Length; x++)
                            {
                                if (items[x] != "")
                                {
                                    string[] mitems = items[x].Split('=');

                                    int key   = BlockData.block_enum[mitems[0]];
                                    int value = Int32.Parse(mitems[1]);
                                    if (p.break_block.ContainsKey(key))
                                    {
                                        p.break_block[key] = Math.Min(p.break_block[key], value);
                                    }
                                    else
                                    {
                                        p.break_block.Add(key, value);
                                    }
                                }
                            }
                            if (items.Length > 0)
                            {
                                p.break_block.Add(BlockData.block_enum["SINGLE"], 0);
                            }
                            break;

                        case "MATERIAL":
                            items = items[1].Split(';');
                            for (int x = 0; x < items.Length; x++)
                            {
                                if (items[x] != "")
                                {
                                    string[] mitems = items[x].Split('=');

                                    string key   = mitems[0];
                                    int    value = Int32.Parse(mitems[1]);
                                    if (p.materials.ContainsKey(key))
                                    {
                                        p.materials[key] = Math.Min(p.materials[key], value);
                                    }
                                    else
                                    {
                                        p.materials.Add(key, value);
                                    }
                                }
                            }
                            break;

                        case "CRAFT-REQUIRE":
                            if (items[1].Trim().ToLower() != "none")
                            {
                                p.craft_require = items[1].Trim().ToLower();
                            }
                            break;

                        case "COMPLEXITY":
                            p.complexity = int.Parse(items[1]);
                            break;

                        case "WORTH":
                            p.worth = int.Parse(items[1]);
                            break;

                        default:
                            Exilania.text_stream.WriteLine("UNHANDLED type " + items[0]);
                            break;
                        }
                    }
                    if (r.EndOfStream)
                    {
                        item_pieces.Add(p);
                        Exilania.text_stream.WriteLine("Item Piece '" + p.name + "' Loaded.");
                        cont = false;
                    }
                }
                r.Close();
            }
            else
            {
                Exilania.text_stream.Write("ERROR! NO ITEM PIECES DEFINING items....");
            }
        }
Example #24
0
        /// <summary>
        /// this will take input like (color_code)01HELLO! and use it to write out colored text.
        /// </summary>
        /// <param name="s"></param>
        /// <param name="text_to_draw"></param>
        public void draw_text(SpriteBatch s, SpriteFont sf, string text_to_draw, int x_start, int y_start, int max_width, byte opacity)
        {
            string[] texts       = text_to_draw.Split(Display.color_code[0]);
            int      cur_width   = 0;
            int      cur_measure = 0;
            Color    col         = Color.White;

            col.A = opacity;
            int    cur_col  = 0;
            string combined = "";

            for (int x = 0; x < texts.Length; x++)
            {
                combined = "";
                if (texts[x].Length >= 2)
                {
                    if ((byte)texts[x][0] >= 48 && (byte)texts[x][0] <= 57 && (byte)texts[x][1] >= 48 && (byte)texts[x][1] <= 57)
                    { //we have a color code... remove it
                        cur_col  = int.Parse(texts[x].Substring(0, 2));
                        col      = Acc.int_to_col(int.Parse(texts[x].Substring(0, 2)));
                        col.A    = opacity;
                        texts[x] = texts[x].Substring(2);
                        combined = texts[x];
                    }
                    else
                    { //not a color code, display the @ symbol
                        combined = "@" + texts[x];
                    }
                }
                else if (x != 0)
                {
                    combined = "@" + texts[x];
                }
                if (combined != "")
                {
                    cur_measure = (int)sf.MeasureString(combined).X;
                    if (cur_width + cur_measure <= max_width)
                    {
                        s.DrawString(sf, combined, new Vector2(x_start + cur_width, y_start), Color.FromNonPremultiplied(col.R, col.G, col.B, opacity));
                        cur_width += cur_measure;
                    }
                    else if (cur_width < max_width) //adding the string is just too much!
                    {
                        int    over    = cur_width + cur_measure - max_width;
                        string final   = combined;
                        int    min_try = 0;
                        int    max_try = combined.Length;
                        while (min_try + 1 < max_try)
                        {
                            final       = combined.Substring(0, (min_try + max_try) / 2);
                            cur_measure = (int)sf.MeasureString(final).X;
                            over        = cur_width + cur_measure - max_width;
                            if (over > 0)
                            {
                                max_try = final.Length;
                            }
                            else
                            {
                                min_try = final.Length;
                            }
                        }
                        s.DrawString(sf, final, new Vector2(x_start + cur_width, y_start), Color.FromNonPremultiplied(col.R, col.G, col.B, opacity));
                        if (drawing_messages > -1 && combined.Length > final.Length)
                        {
                            string precombined = combined.Substring(final.Length - 1);
                            combined = "@" + cur_col.ToString().PadLeft(2, '0') + (combined.Substring(final.Length - 1).Trim());
                            while (x < texts.Length - 1)
                            {
                                x++;
                                combined    += "@" + texts[x];
                                precombined += "@" + texts[x];
                            }
                            messages.Insert(drawing_messages, combined);
                            messages[drawing_messages + 1] = messages[drawing_messages + 1].Replace(precombined, "");
                            start_show_messages            = messages.Count - 1;
                        }
                        return;
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }
Example #25
0
        public BlockManager()
        {
            blocks             = new List <BlockData>();
            custom_item_images = new Dictionary <int, Texture2D>();

            if (System.IO.File.Exists(@"blocks.txt"))
            {
                System.IO.StreamReader r = new System.IO.StreamReader(@"blocks.txt");
                string    line           = "";
                BlockData p    = new BlockData();
                bool      cont = true;
                while (cont)
                {
                    line = r.ReadLine();
                    if (line == "" || line[0] == '#')
                    {
                        //skip this line
                    }
                    else
                    {
                        string[] items = line.Split(':');
                        switch (items[0].ToLower())
                        {
                        case "block":
                            if (p.name == "")
                            {
                                p.name = items[1].Trim();
                            }
                            else
                            {
                                blocks.Add(p);
                                Exilania.text_stream.WriteLine("Block '" + p.name + "' Loaded.");
                                p      = new BlockData();
                                p.name = items[1].Trim();
                            }
                            break;

                        case "block_group":
                            p.block_group = sbyte.Parse(items[1]);
                            break;

                        case "background":
                            p.background = bool.Parse(items[1]);
                            break;

                        case "platform":
                            p.platform = bool.Parse(items[1]);
                            break;

                        case "transparent":
                            p.transparent = bool.Parse(items[1]);
                            break;

                        case "place_wall":
                            p.place_wall = bool.Parse(items[1]);
                            break;

                        case "passable":
                            p.passable = bool.Parse(items[1]);
                            break;

                        case "light_source":
                            if (!items[1].Contains("null"))
                            {
                                items          = items[1].Split(',');
                                p.light_source = new byte[] { byte.Parse(items[0]), byte.Parse(items[1]), byte.Parse(items[2]) };
                            }
                            break;

                        case "liquid_id":
                            p.liquid_id = byte.Parse(items[1]);
                            break;

                        case "block_image_use":
                            p.block_image_use = byte.Parse(items[1]);
                            break;

                        case "image_pointers":
                            items            = items[1].Split(',');
                            p.image_pointers = new int[items.Length];
                            for (int x = 0; x < items.Length; x++)
                            {
                                p.image_pointers[x] = int.Parse(items[x]);
                            }
                            break;

                        case "random_tiles":
                            p.random_tiles = Boolean.Parse(items[1]);
                            break;

                        case "background_transparent":
                            p.bkd_transparent = Boolean.Parse(items[1]);
                            break;

                        case "lighter_background":
                            p.lighter_background = Boolean.Parse(items[1]);
                            break;

                        case "map_color":
                            items           = Acc.script_remove_outer_parentheses(items[1]).Split(',');
                            p.map_represent = new Color(byte.Parse(items[0]), byte.Parse(items[1]), byte.Parse(items[2]));
                            break;

                        case "is_hangar": p.is_hangar = Boolean.Parse(items[1]);
                            break;

                        default:
                            Exilania.text_stream.WriteLine("UNHANDLED type " + items[0]);
                            break;
                        }
                    }
                    if (r.EndOfStream)
                    {
                        blocks.Add(p);
                        Exilania.text_stream.WriteLine("Block '" + p.name + "' Loaded.");
                        cont = false;
                    }
                }
                r.Close();
            }
            else
            {
                Exilania.text_stream.Write("ERROR! No blocks.txt file.");
            }
        }
Example #26
0
        /// <summary>
        /// this will take input like (color_code)01HELLO! and use it to write out colored text.
        /// </summary>
        /// <param name="s"></param>
        /// <param name="text_to_draw"></param>
        public void draw_text(SpriteBatch s, string text_to_draw, int x_start, int y_start, int max_width, bool use_small_font)
        {
            if (!text_to_draw.Contains(Display.color_code[0]) || text_to_draw[0] != Display.color_code[0])
            {
                text_to_draw = Display.color_code + "01" + text_to_draw;
            }

            string[] texts       = text_to_draw.Split(Display.color_code[0]);
            int      cur_width   = 0;
            int      cur_measure = 0;
            int      col         = 0;

            for (int x = 0; x < texts.GetLength(0); x++)
            {
                if (texts[x].Length > 2 && int.TryParse(texts[x].Substring(0, 2), out col))
                {
                    if (use_small_font)
                    {
                        cur_measure = (int)small_font.MeasureString(texts[x].Substring(2)).X;
                    }
                    else
                    {
                        cur_measure = (int)middle_font.MeasureString(texts[x].Substring(2)).X;
                    }
                    if (cur_width + cur_measure < max_width)
                    {
                        if (use_small_font)
                        {
                            s.DrawString(small_font, texts[x].Substring(2), new Vector2(x_start + cur_width, y_start), Acc.int_to_col(col));
                        }
                        else
                        {
                            s.DrawString(middle_font, texts[x].Substring(2), new Vector2(x_start + cur_width, y_start), Acc.int_to_col(col));
                        }
                        cur_width += cur_measure;
                    }
                    else if (cur_width < max_width)
                    {
                        int over = cur_width + cur_measure - max_width;
                        over /= 12;
                        //texts[x] = texts[x].Substring(0, texts[x].Length - (3 + over)) + "...";
                        if (use_small_font)
                        {
                            s.DrawString(small_font, texts[x].Substring(2), new Vector2(x_start + cur_width, y_start), Acc.int_to_col(col));
                        }
                        else
                        {
                            s.DrawString(middle_font, texts[x].Substring(2), new Vector2(x_start + cur_width, y_start), Acc.int_to_col(col));
                        }
                        cur_width += cur_measure;
                    }
                }
            }
        }
Example #27
0
        public BodyTemplate(System.IO.StreamReader r, int template_num)
        {
            body_template_id = template_num;
            BodypartTemplate temp = new BodypartTemplate();

            parts_list = new List <BodypartTemplate>();
            skins      = new List <Color>();
            string line = "";
            bool   cont = true;

            while (cont)
            {
                line = r.ReadLine();
                if (line.Trim() == "" || line[0] == '#')
                {
                    //skip this line
                }
                else
                {
                    string[] items = line.Split(':');
                    switch (items[0].ToLower())
                    {
                    case "color":
                        if (items[1].ToLower() == "none")
                        {
                            temp.no_color = true;
                        }
                        break;

                    case "skins":
                        string[] colors = items[1].Split(';');
                        for (int i = 0; i < colors.Length; i++)
                        {
                            string[] comps = colors[i].Split(',');
                            skins.Add(Color.FromNonPremultiplied(byte.Parse(comps[0]), byte.Parse(comps[1]), byte.Parse(comps[2]), 255));
                        }
                        break;

                    case "body":
                        template_name = items[1];
                        break;

                    case "size":
                        string[] tdim = Acc.script_remove_outer_parentheses(items[1]).Split(',');
                        size_body = new Rectangle(int.Parse(tdim[0]) / -2, int.Parse(tdim[1]) / -2, int.Parse(tdim[0]), int.Parse(tdim[1]));
                        break;

                    case "num-torsos":
                        num_torsos = Int32.Parse(items[1]);
                        break;

                    case "endbody":
                        parts_list.Add(temp);
                        num_parts++;
                        cont = false;
                        break;

                    case "part":
                        if (temp.name == "")
                        {     //first time... already default
                            temp.name = items[1];
                        }
                        else
                        {    //not the first time, add to stack, then default the temp and give it it's name.
                            parts_list.Add(temp);
                            num_parts++;
                            temp      = new BodypartTemplate();
                            temp.name = items[1];
                        }
                        break;

                    case "angle":
                        if (items[1].Contains("CLICKMOUSE"))
                        {
                            temp.click_active_mouse = true;
                            temp.angle_follow_mouse = true;
                            if (items[1].Length > 10)
                            {
                                items[1]          = items[1].Remove(items[1].IndexOf("CLICKMOUSE"), 10);
                                temp.angle_offset = Acc.resolve_die_roll(items[1], 0, 0);
                            }
                        }
                        else if (items[1].Contains("MOUSE"))
                        {
                            temp.angle_follow_mouse = true;
                            if (items[1].Length > 5)
                            {
                                items[1]          = items[1].Remove(items[1].IndexOf("MOUSE"), 5);
                                temp.angle_offset = Acc.resolve_die_roll(items[1], 0, 0);
                            }
                        }
                        else if (items[1].Contains("PARENT"))
                        {
                            temp.angle_follow_parent = true;
                            if (items[1].Length > 6)
                            {
                                items[1]          = items[1].Remove(items[1].IndexOf("PARENT"), 6);
                                temp.angle_offset = Acc.resolve_die_roll(items[1], 0, 0);
                            }
                        }
                        else if (items[1].Contains("WALKING"))
                        {
                            char[]   split = { '+', '-' };
                            string[] codes = items[1].Split(split);
                            temp.angle_walking_id = Int32.Parse(codes[0].Substring(codes[0].IndexOf("WALKING") + 7));
                            if (codes.Length > 1)
                            {
                                temp.angle_offset = Acc.resolve_die_roll(codes[1], 0, 0);
                            }
                        }
                        else
                        {
                            temp.angle_offset = Acc.resolve_die_roll(items[1], 0, 0);
                        }
                        break;

                    case "draw-order":
                        temp.draw_order = Int32.Parse(items[1]);
                        break;

                    case "images":
                        items = items[1].Split(';');
                        Rectangle       temp_rect = new Rectangle();
                        ChildPinPicture t         = new ChildPinPicture();
                        for (int x = 0; x < items.Length; x++)
                        {
                            if (items[x].Contains('='))
                            {     //this is setup to be a child, it has an attachment point.
                                string[] sub_inner = items[x].Split('=');
                                string[] inner     = Acc.get_inner_parenthesis(sub_inner[0]).Split(',');
                                temp_rect   = new Rectangle(Int32.Parse(inner[0]), Int32.Parse(inner[1]), Int32.Parse(inner[2]), Int32.Parse(inner[3]));
                                sub_inner   = Acc.get_inner_parenthesis(sub_inner[1]).Split(',');
                                t.image     = temp_rect;
                                t.child_loc = new Point(Int32.Parse(sub_inner[0]), Int32.Parse(sub_inner[1]));
                                temp.images.Add(t);
                            }
                            else
                            {     //this is not a child, no attachment point.
                                string[] inner = Acc.get_inner_parenthesis(items[x]).Split(',');
                                temp_rect   = new Rectangle(Int32.Parse(inner[0]), Int32.Parse(inner[1]), Int32.Parse(inner[2]), Int32.Parse(inner[3]));
                                t.image     = temp_rect;
                                t.child_loc = new Point(0, 0);
                                temp.images.Add(t);
                            }
                        }
                        break;

                    case "child":
                        items = items[1].Split(';');     //Left Arm;attach(14,5)
                        ParentBrassPin temp_child = new ParentBrassPin();
                        temp_child.child_name = items[0];
                        items = Acc.get_inner_parenthesis(items[1]).Split(',');
                        temp_child.parent_loc = new Point(Int32.Parse(items[0]), Int32.Parse(items[1]));
                        temp.children.Add(temp_child);
                        break;
                    }
                }
                if (r.EndOfStream)
                {
                    cont = false;
                }
            }
        }
Example #28
0
        /// <summary>
        /// controls the viewing of the messaging system... always visible, always able to be turned off (unless enter has been pressed and message typing is commenced)
        /// </summary>
        /// <param name="input"></param>
        public void input_message_display(Input input, Settings settings, Actor me, World w)
        {
            if (Exilania.input.current_input_type != InputConsume.Message && !Exilania.disable_chat)
            {
                if (input.enter)
                {
                    input.enter     = false;
                    show_messages   = true;
                    input.key_input = "";
                    Exilania.input.current_input_type = InputConsume.Message;
                }
                if (input.key_input.Contains('M') || input.key_input.Contains('m'))
                {
                    input.key_input = input.key_input.Replace("M", "");
                    input.key_input = input.key_input.Replace("m", "");

                    show_messages = !show_messages;
                }
                if (input.key_input.Contains('-'))
                {
                    input.key_input = input.key_input.Replace("-", "");
                    start_show_messages--;
                    if (start_show_messages < Math.Min(20, messages.Count - 1))
                    {
                        start_show_messages = Math.Min(20, messages.Count - 1);
                    }
                }
                if (input.key_input.Contains('+'))
                {
                    input.key_input = input.key_input.Replace("+", "");
                    start_show_messages++;
                    if (start_show_messages > messages.Count - 1)
                    {
                        start_show_messages = messages.Count - 1;
                    }
                }
                if (input.keys_now.Contains(Keys.PageUp) && !input.keys_previous.Contains(Keys.PageUp))
                {
                    start_show_messages -= 20;
                    if (start_show_messages < Math.Min(20, messages.Count - 1))
                    {
                        start_show_messages = Math.Min(20, messages.Count - 1);
                    }
                }
                if (input.keys_now.Contains(Keys.PageDown) && !input.keys_previous.Contains(Keys.PageDown))
                {
                    start_show_messages += 20;
                    if (start_show_messages > messages.Count - 1)
                    {
                        start_show_messages = messages.Count - 1;
                    }
                }
                if (input.keys_now.Contains(Keys.Home) && !input.keys_previous.Contains(Keys.Home))
                {
                    start_show_messages = Math.Min(20, messages.Count - 1);
                }
                if (input.keys_now.Contains(Keys.End) && !input.keys_previous.Contains(Keys.End))
                {
                    start_show_messages = messages.Count - 1;
                }
            }
            else if (!Exilania.disable_chat)
            {
                if (input.enter)
                {
                    input.enter     = false;
                    show_messages   = true;
                    input.key_input = input.key_input.Trim();
                    if (input.key_input != "")
                    {
                        if (input.key_input[0] == '/')
                        {
                            add_message(settings.modify_settings(input.key_input.Substring(1), w));
                        }
                        else
                        {
                            if (Exilania.game_client)
                            {
                                Exilania.network_client.send_chat(Exilania.game_my_user_id, input.key_input);
                            }
                            if (input.key_input[0] == '!' && me != null)
                            {
                                for (int i = 0; i < input.key_input.Length; i++)
                                {
                                    if (input.key_input[i] == '!')
                                    {
                                        input.key_input = input.key_input.Substring(0, i) + input.key_input.Substring(i + 1);
                                        break;
                                    }
                                }
                                fading_text.Add(new FadeText("@00" + input.key_input, 3000, (int)me.world_loc.X, (int)me.world_loc.Y - 60, true, TargetType.Player, Exilania.game_my_user_id, w));
                            }
                            else
                            {
                                add_message("@02You@00: " + input.key_input);
                            }
                            Exilania.text_stream.WriteLine(Acc.sanitize_text_color("@02You@00: " + input.key_input));
                        }
                    }
                    input.key_input = "";
                    Exilania.input.current_input_type = InputConsume.Normal;
                }
            }
        }