Beispiel #1
0
 public Shoot(ref World world, Weapon weapon, PointF location, float direction, float speed = -1) : base(ref world)
 {
     this.time_to_live = (int)(weapon.stats.range / weapon.stats.celerity);
     this.Team         = weapon.ship.team;
     this.power        = weapon.stats.power / weapon.stats.sub_ammos * weapon.ship.team.damage_multiplicator;
     this.emp_power    = weapon.stats.emp_power / weapon.stats.sub_ammos * weapon.ship.team.damage_multiplicator;
     this.special      = weapon.stats.special;
     this.type         = weapon.stats.sprite;
     this.location     = location;
     this.direction    = direction;
     if (speed == -1)
     {
         this.speed_vec = Helpers.GetNewPoint(new Point(0, 0), direction, weapon.stats.celerity);
     }
     else
     {
         this.speed_vec = Helpers.GetNewPoint(new Point(0, 0), direction, speed);
     }
     this.emissive_mode   = weapon.stats.emissive_mode;
     this.emissive_sprite = weapon.stats.emissive_sprite;
     // UpdateSector(); // useless in practice
     this.sprites = SpriteArray.GetSpriteArray(this.type, this.Team.color);
     if (sprite_y == -1)
     {
         this.sprite_y = Helpers.rand.Next(0, sprites.count_y);
     }
 }
Beispiel #2
0
 public void UpdateSpriteArray()
 {
     if (sprite_name != null)
     {
         sprite_array = SpriteArray.GetSpriteArray(sprite_name, sprite_color);
     }
 }
Beispiel #3
0
 private void SetSpriteArray()
 {
     this.sprites   = SpriteArray.GetSpriteArray(type);
     this.sprite_y %= sprites.count_y;
     if (time_to_live == -1)
     {
         time_to_live = sprites.count_x;
     }
 }
Beispiel #4
0
        public static SpriteArray GetSpriteArray(string name)
        {
            SpriteArray sprite_array = null;

            if (sprite_arrays.TryGetValue(name, out sprite_array))
            {
                return(sprite_array);
            }
            sprite_array        = new SpriteArray(name);
            sprite_arrays[name] = sprite_array;
            return(sprite_array);
        }
Beispiel #5
0
        // Cloning
        public SpriteArray Clone()
        {
            SpriteArray array = new SpriteArray();

            array.count_x         = this.count_x;
            array.count_y         = this.count_y;
            array.count_z         = this.count_z;
            array.width           = this.width;
            array.height          = this.height;
            array.color_swap_mode = this.color_swap_mode;
            foreach (Bitmap sprite in sprites)
            {
                array.sprites.Add((Bitmap)sprite.Clone());
            }
            return(array);
        }
Beispiel #6
0
        public static SpriteArray GetSpriteArray(string name, Color color)
        {
            if (color == default)
            {
                return(GetSpriteArray(name));
            }
            SpriteArray sprite_array      = null;
            string      sprite_array_name = SpriteArrayName(name, color);

            if (sprite_arrays.TryGetValue(sprite_array_name, out sprite_array))
            {
                return(sprite_array);
            }
            sprite_array = GetSpriteArray(name).Clone();
            sprite_array.ColorSprites(color);
            sprite_arrays[sprite_array_name] = sprite_array;
            return(sprite_array);
        }
Beispiel #7
0
        public void SetSprite(string sprite)
        {
            this.sprite = sprite;
            var try_bmp = SpriteArray.GetSpriteArray(this.sprite).GetSprite(0, 0);

            if (try_bmp is object)
            {
                width     = try_bmp.Width;
                level     = (int)Math.Sqrt(width) / 2;
                integrity = (int)(width * width / 12d);
                if (width >= 25)
                {
                    repair = 1;
                }
                cost.Metal = width * 2 + level * 10;
                if (width >= 20)
                {
                    cost.Crystal = 1L;
                }
            }
        }
Beispiel #8
0
 public static void UnLoad()
 {
     ShipStats.classes.Clear();
     GunStats.classes.Clear();
     SpriteArray.ClearSpriteArrays();
 }
Beispiel #9
0
        public static Bitmap GetSprite(string img_name, int x, int y, Color Scolor = default)
        {
            SpriteArray sa = SpriteArray.GetSpriteArray(img_name, Scolor);

            return(sa.GetSprite(x, y));
        }