コード例 #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);
        }
コード例 #2
0
        public TankAccessoriesDecorator(int index, TankChassis tank)
            : base(tank)
        {
            string imageFile = string.Format($"{path}accessory_{index}.png");

            image = Image.FromFile(imageFile);
        }
コード例 #3
0
        public TankSideskirtDecorator(int index, TankChassis tank)
            : base(tank)
        {
            string imageFile = string.Format($"{path}sideskirt_{index}.png");

            image = Image.FromFile(imageFile);
        }
コード例 #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;
 }
コード例 #5
0
        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();
        }
コード例 #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);
        }
コード例 #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();
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }