Beispiel #1
0
        public override void SetWheel(WheelBase wheel)
        {
            base.SetWheel(wheel);
            CreateWheel(wheel.LeafSlots);

            InitializeUI();
        }
Beispiel #2
0
        override protected void CreateWheel()
        {
            wheel = Wheel.Create(name: "Wheel of Fate");

            WheelBase weapons = Wheel.Create(name: "Weapons");

            weapons.AddSlot(Wheel.Create(1, "Sword"));
            weapons.AddSubslot("Sword", Wheel.Create(1, "Epic Sword"));
            weapons.AddSubslot("Sword", Wheel.Create(5, "Rare Sword"));
            weapons.AddSubslot("Sword", Wheel.Create(15, "Common Sword"));

            weapons.AddSlot(Wheel.Create(1, "Halberd"));
            weapons.AddSubslot("Halberd", Wheel.Create(1, "Epic Halberd"));
            weapons.AddSubslot("Halberd", Wheel.Create(5, "Rare Halberd"));
            weapons.AddSubslot("Halberd", Wheel.Create(15, "Common Halberd"));

            weapons.AddSlot(Wheel.Create(1, "Bow"));
            weapons.AddSubslot("Bow", Wheel.Create(1, "Epic Bow"));
            weapons.AddSubslot("Bow", Wheel.Create(5, "Rare Bow"));
            weapons.AddSubslot("Bow", Wheel.Create(15, "Common Bow"));

            weapons.AddSlot(Wheel.Create(1, "Mace"));
            weapons.AddSubslot("Mace", Wheel.Create(1, "Epic Mace"));
            weapons.AddSubslot("Mace", Wheel.Create(5, "Rare Mace"));
            weapons.AddSubslot("Mace", Wheel.Create(15, "Common Mace"));

            WheelBase armors = Wheel.Create(name: "Armors");

            armors.AddSlot(Wheel.Create(2, "Leggings"));
            armors.AddSlot(Wheel.Create(4, "Chestplate"));
            armors.AddSlot(Wheel.Create(1, "Shield"));
            armors.AddSlot(Wheel.Create(10, "Boots"));

            WheelBase powerups = Wheel.Create(name: "Powerups");

            powerups.AddSlot(Wheel.Create(1, "Increased HP"));
            powerups.AddSubslot(0, Wheel.Create(1, "HP +100"));
            powerups.AddSubslot(0, Wheel.Create(9, "HP +25"));
            powerups.AddSubslot(0, Wheel.Create(40, "HP +10"));
            powerups.AddSlot(Wheel.Create(1, "Increased ATK"));
            powerups.AddSubslot(1, Wheel.Create(1, "ATK +1000"));
            powerups.AddSubslot(1, Wheel.Create(9, "ATK +400"));
            powerups.AddSubslot(1, Wheel.Create(40, "ATK +100"));
            powerups.AddSlot(Wheel.Create(1, "Increased DEX"));
            powerups.AddSubslot(2, Wheel.Create(1, "DEX +20"));
            powerups.AddSubslot(2, Wheel.Create(9, "DEX +6"));
            powerups.AddSubslot(2, Wheel.Create(40, "DEX +2"));

            wheel.AddSlot(weapons);
            wheel.AddSlot(armors);
            wheel.AddSlot(powerups);

            foreach (WheelRenderer renderer in wheelRenderers)
            {
                if (renderer)
                {
                    renderer.SetWheel(wheel);
                }
            }
        }
Beispiel #3
0
            /// <summary>Creates a new power wheel</summary>
            /// <param name="wheel">The actual wheel it wraps</param>
            /// <param name="wb">The wheel base, to which the power wheel will be added</param>
            /// <param name="tform">Coordinates transformer, should be one that makes the Z axis parallel the wheel direction and Y axis the up axis</param>
            public PowerWheel(IMyMotorSuspension wheel, WheelBase wb, CoordinatesTransformer tform)
            {
                this.wheelBase   = wb;
                this.CubeSize    = wheel.CubeGrid.GridSizeEnum;
                this.Position    = tform.Pos(wheel.GetPosition());
                this.IsRight     = RIGHT.Dot(tform.Dir(wheel.WorldMatrix.Up)) > 0;
                this.reverseY    = UP.Dot(tform.Dir(wheel.WorldMatrix.Backward)) > 0;
                this.transformer = tform;
                this.wheel       = wheel;

                wheel.Height = 10;
                this.maxY    = wheel.Height;
                wheel.Height = -10;
                this.minY    = wheel.Height;
                if (this.reverseY)
                {
                    float tmp = this.minY;
                    this.minY = -this.maxY;
                    this.maxY = -tmp;
                }
                this.WheelSize = (wheel.Top.Max - wheel.Top.Min).X + 1;
                this.Mass      = this.CubeSize == MyCubeSize.Small
          ? this.WheelSize == 1 ? 105 : (this.WheelSize == 3 ? 205 : 310)
          : this.WheelSize == 1 ? 420 : (this.WheelSize == 3 ? 590 : 760);
                // real center of rotation of the wheel
                this.Position += tform.Dir(wheel.WorldMatrix.Up) * wheel.CubeGrid.GridSize;
                this.wheelBase.AddWheel(this);
            }
Beispiel #4
0
        public void AddSlot_NewSubslotOnMaxedOutWheelRoot_ShouldWorkFine()
        {
            WheelBase parentWheel = CreateDummyWheelWithDepth((int)Wheel.DEPTH_MAX);
            WheelBase childWheel  = Wheel.Create();

            Assert.IsTrue(parentWheel.AddSlot(childWheel));
        }
Beispiel #5
0
        protected C86Entry CreateEntry(Vector2Int pos, WheelBase slot)
        {
            C86Entry entry = Instantiate(entryPF);

            entry.Initialize(unitContainer, pos.x, pos.y, entryRatio.x, entryRatio.y, sequenceDuration / 2f, entryFadeDelay);
            entry.SetContent(slot.name);

            return(entry);
        }
Beispiel #6
0
        protected override UnitRenderer MakeUnit(int order, WheelBase slot)
        {
            Vector2Int pos   = FindEntryPosition();
            C86Entry   entry = CreateEntry(pos, slot);

            SaveEntry(pos, entry);

            return(entry);
        }
Beispiel #7
0
        public override async Task <long> SubmitAddChangeRequestAsync(VehicleToWheelBase entity, string requestedBy,
                                                                      List <ChangeRequestItemStaging> changeRequestItemStagings = null, CommentsStagingModel comment = null,
                                                                      List <AttachmentsModel> attachmentsStagingModels          = null, string changeContent = null)
        {
            // validation
            if (entity.VehicleId.Equals(default(int)) ||
                entity.WheelBaseId.Equals(default(int)))
            {
                throw new ArgumentException(nameof(entity));
            }

            changeRequestItemStagings = changeRequestItemStagings ?? new List <ChangeRequestItemStaging>();

            StringBuilder validationErrorMessage = new StringBuilder();

            await this.ValidateVehicleToWheelBaseHasNoChangeReqeuest(entity);

            await this.ValidateVehicleToWheelBaseLookUpHasNoChangeRequest(entity);

            changeRequestItemStagings.Add(new ChangeRequestItemStaging()
            {
                ChangeType      = ChangeType.Add,
                EntityId        = entity.Id.ToString(),
                CreatedDateTime = DateTime.UtcNow,
                Entity          = typeof(VehicleToWheelBase).Name,
                Payload         = base.Serializer.Serialize(entity)
            });

            var vehicleRepositoryService         = base.Repositories.GetRepositoryService <Vehicle>() as IVcdbSqlServerEfRepositoryService <Vehicle>;
            var wheelBaseConfigRepositoryService = base.Repositories.GetRepositoryService <WheelBase>() as IVcdbSqlServerEfRepositoryService <WheelBase>;

            Vehicle   vehicle   = null;
            WheelBase wheelBase = null;

            if (vehicleRepositoryService != null && wheelBaseConfigRepositoryService != null)
            {
                var vehicles = await vehicleRepositoryService.GetAsync(m => m.Id == entity.VehicleId && m.DeleteDate == null, 1);

                if (vehicles != null && vehicles.Any())
                {
                    vehicle = vehicles.First();
                }

                var wheelBases = await wheelBaseConfigRepositoryService.GetAsync(m => m.Id == entity.WheelBaseId && m.DeleteDate == null, 1);

                if (wheelBases != null && wheelBases.Any())
                {
                    wheelBase = wheelBases.First();
                }
            }

            changeContent =
                $"{vehicle?.BaseVehicle.YearId} / {vehicle?.BaseVehicle.Make.Name} / {vehicle?.BaseVehicle.Model.Name} / {vehicle?.SubModel.Name} / {vehicle?.Region.Name} => \n{wheelBase?.Base} / {wheelBase?.WheelBaseMetric}";

            return(await base.SubmitAddChangeRequestAsync(entity, requestedBy, changeRequestItemStagings, comment, attachmentsStagingModels, changeContent));
        }
Beispiel #8
0
        public void AddSlot_AddMoreThanMaxDepth_ShouldThrowException()
        {
            int depth1 = UnityEngine.Random.Range(0, (int)Wheel.DEPTH_MAX);
            int depth2 = 1 + (int)Wheel.DEPTH_MAX - depth1;

            WheelBase parentWheel = CreateDummyWheelWithDepth(depth1, getLeaf: true);
            WheelBase childWheel  = CreateDummyWheelWithDepth(depth2);

            Assert.Throws <Exceptions.MaxDepthReachedException>(() => parentWheel.AddSlot(childWheel));
        }
Beispiel #9
0
        public void AddSubslot_AddToSameTree_ShouldThrowException()
        {
            WheelBase wheel     = Wheel.Create();
            WheelBase subwheel1 = Wheel.Create();
            WheelBase subwheel2 = Wheel.Create();

            wheel.AddSlot(subwheel1);
            subwheel1.AddSlot(subwheel2);

            Assert.Throws <Exceptions.SameWheelException>(() => subwheel1.AddSubslot(0, wheel));
        }
Beispiel #10
0
        public void Depth_CalculatesCorrectly()
        {
            int[] inputDepths  = new int[Wheel.DEPTH_MAX];
            int[] outputDepths = new int[Wheel.DEPTH_MAX];

            for (int i = 0; i < Wheel.DEPTH_MAX; i++)
            {
                inputDepths[i] = i;
                WheelBase wheel = CreateDummyWheelWithDepth(inputDepths[i]);
                outputDepths[i] = wheel.Depth;
            }

            CollectionAssert.AreEqual(inputDepths, outputDepths);
        }
    // Use this for initialization
    void Start()
    {
        //Creating your Vechicle (Load section)
        //Download model data  (or model)
        //Build Model,parts,paint...
        //Download engine,wheelbase data...
        //DownloadData();
        //Build Wheelbase
        MyWheelBase = new WheelBase();
        MyWheelBase.AdjustSuspension();

        //
        GearRatio = new float[] { -3.382f, 3.321f, 1.902f, 1.308f, 1f, 0.759f };
    }
Beispiel #12
0
        public void RootDistance_CalculatesCorrectly()
        {
            int[] randomDepths = new int[Wheel.DEPTH_MAX];
            int[] outputDepths = new int[Wheel.DEPTH_MAX];

            for (int i = 0; i < Wheel.DEPTH_MAX; i++)
            {
                randomDepths[i] = i;
                WheelBase wheel = CreateDummyWheelWithDepth(randomDepths[i], getLeaf: true);
                outputDepths[i] = wheel.RootDistance;
            }

            CollectionAssert.AreEqual(randomDepths, outputDepths);
        }
        public async Task <IHttpActionResult> Post(int id, WheelBaseInputModel model)
        {
            WheelBase wheelBaselength = new WheelBase()
            {
                Id = model.Id, Base = model.Base, WheelBaseMetric = model.WheelBaseMetric
            };
            CommentsStagingModel comment = new CommentsStagingModel()
            {
                Comment = model.Comment
            };
            var attachments     = SetUpAttachmentsModels(model.Attachments);
            var changeRequestId = await _wheelBaseApplicationService.DeleteAsync(wheelBaselength, id, CurrentUser.Email, comment, attachments);

            return(Ok(changeRequestId));
        }
        private Expression <Func <VehicleToWheelBaseDocument, bool> > AddWheelBaseMetricFilter(
            Expression <Func <VehicleToWheelBaseDocument, bool> > filterEx)
        {
            if (WheelBase == null || !WheelBase.Any())
            {
                return(filterEx);
            }

            Expression <Func <VehicleToWheelBaseDocument, bool> > wheelBaseFilterEx = null;

            foreach (var wheelBase in WheelBase)
            {
                wheelBaseFilterEx = wheelBaseFilterEx.OrElse(x => x.WheelBaseName == wheelBase);
            }

            return(filterEx.AndAlso(wheelBaseFilterEx));
        }
        public async Task <IHttpActionResult> Put(int id, WheelBaseInputModel wheelBaseInputModel)
        {
            WheelBase wheelBase = new WheelBase()
            {
                Id                      = wheelBaseInputModel.Id,
                Base                    = wheelBaseInputModel.Base,
                WheelBaseMetric         = wheelBaseInputModel.WheelBaseMetric,
                VehicleToWheelBaseCount = wheelBaseInputModel.VehicleToWheelBaseCount,
            };
            CommentsStagingModel comment = new CommentsStagingModel()
            {
                Comment = wheelBaseInputModel.Comment
            };
            var attachments     = SetUpAttachmentsModels(wheelBaseInputModel.Attachments);
            var changeRequestId = await _wheelBaseApplicationService.UpdateAsync(wheelBase, wheelBase.Id, CurrentUser.Email, comment, attachments);

            return(Ok(changeRequestId));
        }
Beispiel #16
0
        protected override UnitRenderer MakeUnit(int order, WheelBase slot)
        {
            if (slicePF == null)
            {
                throw new Exceptions.MissingUnitPFException("slicePF", typeof(DiskSliceUIBase));
            }

            DiskSliceUIBase slice = Instantiate(slicePF);

            slice.Initialize(radius: radius,
                             arc: arc,
                             parent: unitContainer,
                             index: order);

            SetContent(ref slice, slot.name);
            slice.gameObject.name = $"UI Slice_{slot.name}";
            return(slice);
        }
Beispiel #17
0
        override protected void CreateWheel()
        {
            wheel = Wheel.Create(name: "Lab Upgrade");

            WheelBase telepod = Wheel.Create(name: "Telepod");

            telepod.AddSlot(Wheel.Create(5, "Safety Locks"));
            telepod.AddSlot(Wheel.Create(3, "+1 Atomic Decimator"));
            telepod.AddSlot(Wheel.Create(3, "+1 Atomic Regenerator"));
            telepod.AddSlot(Wheel.Create(1, "+1 Telepod"));

            telepod.AddSlot(Wheel.Create(10, "Cabling"));
            telepod.AddSubslot("Cabling", Wheel.Create(50, "+1 Copper Cable"));
            telepod.AddSubslot("Cabling", Wheel.Create(10, "+1 Gold Cable"));
            telepod.AddSubslot("Cabling", Wheel.Create(1, "+1 Carbon Cable"));

            telepod.AddSlot(Wheel.Create(20, "Upgrades"));
            telepod.AddSubslot("Upgrades", Wheel.Create(1, "+10% UV Blocking"));
            telepod.AddSubslot("Upgrades", Wheel.Create(1, "+10% Insulation"));
            telepod.AddSubslot("Upgrades", Wheel.Create(1, "+10% Regen Speed"));

            WheelBase computer = Wheel.Create(name: "Computer");

            computer.AddSlot(Wheel.Create(1, "Turbo CPU Add-on"));
            computer.AddSlot(Wheel.Create(5, "+64K Memory"));
            computer.AddSlot(Wheel.Create(3, "DNA Validator"));
            computer.AddSlot(Wheel.Create(10, "Insectoid DNA Filter"));
            computer.AddSlot(Wheel.Create(10, "Tissue Translator"));
            computer.AddSlot(Wheel.Create(10, "+1 Teleport Subject"));
            computer.AddSlot(Wheel.Create(10, "Voice Activation"));

            wheel.AddSlot(telepod);
            wheel.AddSlot(computer);

            foreach (WheelRenderer renderer in wheelRenderers)
            {
                if (renderer)
                {
                    renderer.SetWheel(wheel);
                }
            }
        }
Beispiel #18
0
        private WheelBase CreateDummyWheelWithDepth(int depth, bool getLeaf = false)
        {
            WheelBase wheel     = Wheel.Create();
            WheelBase lastChild = wheel;

            for (int i = 0; i < depth; i++)
            {
                WheelBase newChild = Wheel.Create();
                lastChild.AddSlot(newChild);
                lastChild = newChild;
            }

            if (getLeaf)
            {
                return(lastChild);
            }
            else
            {
                return(wheel);
            }
        }
Beispiel #19
0
        public Program()
        {
            this.Runtime.UpdateFrequency = UpdateFrequency.Update1;
            IMyTextSurface topLeft, topRight, keyboard;
            IMyCockpit     cockpit;

            this.manager = Process.CreateManager(this.Echo);
            this.initCockpit(out cockpit, out topLeft, out topRight, out keyboard);
            var ct     = new CoordinatesTransformer(cockpit, this.manager);
            var logger = new Logger(this.manager, keyboard, this.scheme.Light, this.scheme.Dark, this.Echo);

            logger.Log("Booting up...");
            this.cmd = new CommandLine("Boring machine", logger.Log, this.manager);
            var genStatus = new GeneralStatus(this, this.cmd);
            var wb        = new WheelBase();
            var wheels    = new List <IMyMotorSuspension>();

            this.GridTerminalSystem.GetBlocksOfType(wheels, w => w.CubeGrid == this.Me.CubeGrid && w.DisplayNameText.Contains("Power"));
            wheels.ForEach(w => wb.AddWheel(new PowerWheel(w, wb, ct)));
            var ic = new InventoriesController(ct, this.GridTerminalSystem, cockpit, wb.CenterOfTurnZ + 2, this.manager);

            new ScreensController(genStatus, ic, topLeft, topRight, this.scheme, cockpit.CustomData, this.manager);
        }
Beispiel #20
0
        private async Task UpdateVehicleToWheelBaseDocuments(WheelBase updatedWheelBase)
        {
            bool isEndReached = false;
            int  pageNumber   = 1;

            do
            {
                var vehicleToWheelBaseSearchResult =
                    await
                    _vehicletoWheelBaseSearchService.SearchAsync(null,
                                                                 $"wheelBaseId eq {updatedWheelBase.Id}", new SearchOptions()
                {
                    RecordCount = 1000, PageNumber = pageNumber
                });

                var existingVehicleToWheelBaseDocuments = vehicleToWheelBaseSearchResult.Documents;

                if (existingVehicleToWheelBaseDocuments != null && existingVehicleToWheelBaseDocuments.Any())
                {
                    foreach (var existingVehicleToWheelBaseDocument in existingVehicleToWheelBaseDocuments)
                    {
                        existingVehicleToWheelBaseDocument.WheelBaseChangeRequestId = -1;
                        existingVehicleToWheelBaseDocument.WheelBaseId     = updatedWheelBase.Id;
                        existingVehicleToWheelBaseDocument.WheelBaseName   = updatedWheelBase.Base;
                        existingVehicleToWheelBaseDocument.WheelBaseMetric = updatedWheelBase.WheelBaseMetric;
                    }

                    await this._vehicleToWheelBaseIndexingService.UploadDocumentsAsync(existingVehicleToWheelBaseDocuments.ToList());

                    pageNumber++;
                }
                else
                {
                    isEndReached = true;
                }
            } while (!isEndReached);
        }
Beispiel #21
0
        public void LeafSlots_ShouldOnlyContainLeafSlots()
        {
            WheelBase wheel = Wheel.Create();

            wheel.AddSlot(Wheel.Create(name: "A"));
            wheel.AddSlot(Wheel.Create(name: "B"));
            wheel.AddSlot(Wheel.Create(name: "C"));

            wheel.AddSubslot("B", Wheel.Create(name: "D"));

            WheelBase eWheel = Wheel.Create(name: "E");

            eWheel.AddSlot(Wheel.Create(name: "F"));
            eWheel.AddSlot(Wheel.Create(name: "G"));

            eWheel.AddSubslot("F", Wheel.Create(name: "H"));
            eWheel.AddSubslot("F", Wheel.Create(name: "I"));

            wheel.AddSlot(eWheel);

            string[] givenLeaves = { "A", "C", "D", "G", "H", "I" };

            CollectionAssert.AreEquivalent(wheel.LeafNames, givenLeaves);
        }
        public async Task <IHttpActionResult> Replace(int id, WheelBaseInputModel model)
        {
            WheelBase brakeConfig = new WheelBase()
            {
                Id                  = model.Id,
                Base                = model.Base,
                WheelBaseMetric     = model.WheelBaseMetric,
                VehicleToWheelBases = model.VehicleToWheelBases.Select(item => new VehicleToWheelBase
                {
                    WheelBaseId = item.WheelBaseId,
                    Id          = item.Id,
                    VehicleId   = item.VehicleId
                }).ToList(),
            };

            CommentsStagingModel comment = new CommentsStagingModel {
                Comment = model.Comment
            };
            var attachments = SetUpAttachmentsModels(model.Attachments);

            var changeRequestId = await _wheelBaseApplicationService.ReplaceAsync(brakeConfig, id, CurrentUser.Email, comment, attachments);

            return(Ok(changeRequestId));
        }
Beispiel #23
0
        public void Create_ChanceCanBe1MillonMax_ShouldCapAt1M()
        {
            WheelBase wheel = Wheel.Create(chance: 2000000);

            Assert.LessOrEqual(wheel.chance, Wheel.CHANCE_MAX);
        }
Beispiel #24
0
 public Van(string model, string make, VanType type, int price, int year, int mile, double size, WheelBase wheel, string des,
            string color, string socure, string img) : base(model, make, price, year, mile, size, des, color, socure, img)
 {
     BodyType  = type;
     Wheelbase = wheel;
 }
Beispiel #25
0
 public override void SetWheel(WheelBase wheel)
 {
     base.SetWheel(wheel);
     CreateWheel(chained ? wheel.subslots : wheel.LeafSlots);
 }
Beispiel #26
0
        public void AddSubslot_ShouldNotAcceptItselfAsSubslot_ShouldThrowException()
        {
            WheelBase wheel = Wheel.Create();

            Assert.Throws <Exceptions.SameWheelException>(() => wheel.AddSlot(wheel));
        }