Ejemplo n.º 1
0
        public ITankBuilder SetChassis(int colorId = 0, int id = 0)
        {
            if (id < 0 || id >= CHASSIS_COUNT)
            {
                throw new IndexOutOfRangeException();
            }

            if (colorId < 0 || colorId >= COLOR_COUNT)
            {
                throw new IndexOutOfRangeException();
            }

            if (tank.FindChild <TankChassis>() != null)
            {
                throw new Exception("Tank already has a chassis");
            }

            Console.WriteLine("BUILDER TankBuilder: SetChassis()");
            string      path    = string.Format($"{spritesPath}chassis_{colorId}_{id}.png");
            TankChassis chassis = new TankChassis(Image.FromFile(path),
                                                  tank.transform.position,
                                                  new Vector2(64f, 48f));

            chassis.SetParent(tank);
            return(this);
        }
Ejemplo n.º 2
0
        public TankAccessoriesDecorator(int index, TankChassis tank)
            : base(tank)
        {
            string imageFile = string.Format($"{path}accessory_{index}.png");

            image = Image.FromFile(imageFile);
        }
        public TankSideskirtDecorator(int index, TankChassis tank)
            : base(tank)
        {
            string imageFile = string.Format($"{path}sideskirt_{index}.png");

            image = Image.FromFile(imageFile);
        }
Ejemplo n.º 4
0
 public TankDecorator(TankChassis tank)
     : base(tank.image, tank.transform.position, tank.transform.size)
 {
     this.tank      = tank;
     this.parent    = tank.parent;
     this.transform = tank.transform;
 }
        public TankCamoDecorator(int camoId, TankChassis tank)
            : base(tank)
        {
            string imageFile = string.Format($"{path}camo_{camoId}.png");

            camo = new Bitmap(Image.FromFile(imageFile), tank.image.Width, tank.image.Height);
            GenerateCamoBitmap();
        }
Ejemplo n.º 6
0
        public TankAccessoriesDecorator(int index, TankChassis tank)
            : base(tank)
        {
            System.Console.WriteLine("DECORATOR new TankAccessoriesDecorator()");
            string imageFile = string.Format($"{path}accessory_{index}.png");

            image = Image.FromFile(imageFile);
        }
Ejemplo n.º 7
0
        public TankCamoDecorator(int camoId, TankChassis tank)
            : base(tank)
        {
            System.Console.WriteLine("DECORATOR new TankCamoDecorator()");

            string imageFile = string.Format($"{path}camo_{camoId}.png");

            camo = new Bitmap(Image.FromFile(imageFile), tank.image.Width, tank.image.Height);
            GenerateCamoBitmap();
        }
Ejemplo n.º 8
0
        public static void ApplySideskirt(this Tank tank, int sideskirt)
        {
            TankChassis chassis = tank.FindChild <TankDecorator>();

            if (chassis == null)
            {
                chassis = tank.FindChild <TankChassis>();
            }
            TankSideskirtDecorator sideskirtChassis = new TankSideskirtDecorator(sideskirt, chassis);

            sideskirtChassis.SetParent(tank);
            SceneManager.Instance.CurrentScene.DestroyEntity(chassis);
            SceneManager.Instance.CurrentScene.CreateEntity(sideskirtChassis);
        }
Ejemplo n.º 9
0
        public static void ApplyAccessory(this Tank tank, int accessory)
        {
            TankChassis chassis = tank.FindChild <TankDecorator>();

            if (chassis == null)
            {
                chassis = tank.FindChild <TankChassis>();
            }
            TankAccessoriesDecorator accessoryChassis = new TankAccessoriesDecorator(accessory, chassis);

            accessoryChassis.SetParent(tank);
            SceneManager.Instance.CurrentScene.DestroyEntity(chassis);
            SceneManager.Instance.CurrentScene.CreateEntity(accessoryChassis);
        }
Ejemplo n.º 10
0
        public static void ApplyCamouflage(this Tank tank, int camo)
        {
            TankChassis chassis = tank.FindChild <TankDecorator>();

            if (chassis == null)
            {
                chassis = tank.FindChild <TankChassis>();
            }
            TankCamoDecorator camoChassis = new TankCamoDecorator(camo, chassis);

            camoChassis.SetParent(tank);
            SceneManager.Instance.CurrentScene.DestroyEntity(chassis);
            SceneManager.Instance.CurrentScene.CreateEntity(camoChassis);
        }