public void EquiparUpgrade(IUpgrade upgrade) { if (PodeEquiparNovosUpgrades) { Upgrades.Add(upgrade); } }
/// <summary> /// start update /// </summary> /// <param name="directoryName">directory name of server</param> /// <param name="upgrade">how to update</param> /// <param name="success"></param> /// <param name="failed"></param> /// <param name="cancel"></param> public static void ShowUpdate(string directoryName, IUpgrade upgrade, string startApp = null, Action success = null, Action failed = null, Action cancel = null) { var view = new UpdateWindowView(); var viewModel = new UpdateWindowViewModel(directoryName, upgrade, startApp, success, failed, cancel); view.DataContext = viewModel; view.Show(); }
// Use this for initialization private void Start() { this.unlocked = false; // f**k compiler warnings :D if (this.unlocked) { } this.upgraded = false; this.upgradeName = this.GetComponentInChildren<Text>(); this.unlockButton = this.GetComponent<Button>(); this.unlockButton.image.sprite = this.regularImg; this.upgrade = this.upgradeObj.GetComponent<IUpgrade>(); this.upgradeName.text = this.upgrade.Name; foreach (Skill s in this.requiredSkills) { s.unlockSkill = this; //_RequiredUnlocks += 1; } if (this.requiredSkills.Length != 0) { this.unlockButton.image.sprite = this.lockedImg; this.unlockButton.interactable = false; } }
public UpgradeSlot(IUpgradeType upgradeType, IUpgrade upgrade, IReadOnlyList <IXWingSpecification <IUpgrade> > restrictions, int costReduction = 0, bool isMutable = true) { UpgradeType = upgradeType ?? throw new ArgumentNullException(nameof(upgradeType)); this.upgrade = upgrade ?? throw new ArgumentNullException(nameof(upgrade)); CostReduction = costReduction; RestrictionList = restrictions; IsMutable = isMutable; }
public bool SetUpgrade(IUpgrade upgrade) { if (!upgrade.UpgradeType.Equals(UpgradeType)) { return(false); } this.Upgrade = upgrade; return(true); }
public void AddUpgrade(IUpgrade upgrade) { // Transfer the thing physically so it doesn't get destroyed by the pickup going away. upgrade.GetGameObject().transform.parent = beltObject; upgrades.Add(upgrade); PopulateUI(); // TEMP: Add the upgrade to the current gun //upgrade.GetGameObject().transform.parent = GetComponent<GunManagement>().GetCurrentGun().transform; //upgrade.SetGun(GetComponent<GunManagement>().GetCurrentGun().GetComponent<Pistol>()); //upgrade.Equip(); }
/// <summary> /// Equip the 0th upgrade to the selected gun. /// </summary> /// <param name="gunType"></param> public void EquipTopUpgrade(int gunType) { IUpgrade upgrade = upgrades[0]; // Get the gun object and parent the upgrade to it. This actually doesn't really serve a point... but it may later upgrade.GetGameObject().transform.parent = GunManagement.instance.guns[(GunManagement.Guns)gunType].transform; upgrade.SetGun(GunManagement.instance.guns[(GunManagement.Guns)gunType].GetComponent <Pistol>()); upgrade.Equip(); // Remove the upgrade from our list upgrades.RemoveAt(0); PopulateUI(); }
public void BuyUgrade(IUpgrade itemToUpdate) { BigNumber updateCost = itemToUpdate.Price; if (CanPay(updateCost) == false) { throw new InvalidExpressionException("Player profile dont't have enouth money to pay! Can't make transaction."); } _moneySystem.SubstructMoney(updateCost); itemToUpdate.LvlUp(); }
/// <summary> /// Removes the given <paramref name="upgrade"/> /// from the upgrade slots. /// </summary> /// <param name="upgrade">Upgrade to remove.</param> public bool RemoveUpgrade(IUpgrade upgrade) { if (TryGetSlotIDOfUpgrade(upgrade, out int slotID)) { _upgradeSlots[slotID] = null; return(true); } else { return(false); } }
/// <summary> /// Installs the given <paramref name="upgrade"/> /// into a free upgrade slot. /// </summary> /// <param name="upgrade">Upgrade to install.</param> public bool InstallUpgrade(IUpgrade upgrade) { if (_parent.IsUpgradeCompatible(upgrade) && TryGetFirstFreeUpgradeSlotID(out int slotID)) { _upgradeSlots[slotID] = upgrade; return(true); } else { return(true); } }
/// <summary> /// Tries to get the slot ID of the given <paramref name="upgrade"/> /// in the <see cref="UpgradeSlots"/>. /// </summary> /// <param name="upgrade">Upgrade to get slot ID for.</param> /// <param name="slotID">Slot ID of the given <paramref name="upgrade"/>.</param> /// <returns>True if the upgrade was found, false if not.</returns> private bool TryGetSlotIDOfUpgrade(IUpgrade upgrade, out int slotID) { slotID = -1; for (int i = 0; i < _upgradeSlots.Length; i++) { if (UpgradeSlots[i] == upgrade) { slotID = i; return(true); } } return(false); }
public UpdateWindowViewModel(string directoryName, IUpgrade upgrade, string startApp = "", Action success = null, Action failed = null, Action cancel = null ) { this.directoryName = directoryName; this.upgrade = upgrade; this.startApp = startApp; this.success = success; this.failed = failed; this.cancel = cancel; UpdateCollection = new UpdateFileCollection(new List<EsuUpgradeInfo>()); updateCommand = new DelegateCommand(Update, () => true); closeCommand = new DelegateCommand(Close, () => true); cancelCommand = new DelegateCommand(Cancel, () => true); scheduler = TaskScheduler.Current; }
/// <summary> /// Initializes a new instance of the <see cref="UpgradeViewModel{T, T}"/> class. /// </summary> /// <param name="hero">The Hero model</param> /// <param name="upgrade">The Upgrade model</param> public UpgradeViewModel(IHero hero, IUpgrade upgrade) { if (hero == null) { throw new ArgumentNullException("hero"); } if (upgrade == null) { throw new ArgumentNullException("upgrade"); } _hero = hero; _upgrade = upgrade; _hero.PropertyChanged += this.OnHeroModelPropertyChanged; }
public static IUpgrade Get_Upgrade(Upgrade_Type type, string ID) { if (!ALL.ContainsKey(type)) { return(null); } //return ALL[type].FirstOrDefault(o => (String.Compare(o.ID, ID) == 0)); IUpgrade up = null; if (!ALL[type].TryGetValue(ID, out up)) { return(null); } return(up); }
private void UpgradeSelector_UpgradeSelected(IUpgrade e) { var upgrade = e; var upgradeViewModels = ViewModel.PilotViewModel.Upgrades .Where(upgradeViewModel => upgradeViewModel.UpgradeSlot.UpgradeType.Equals(upgrade.UpgradeType) && upgradeViewModel.UpgradeSlot.IsMutable && upgradeViewModel.UpgradeSlot.IsNullUpgrade); foreach (var upgradeViewModel in upgradeViewModels) { if (upgradeViewModel.UpgradeSlot.SetUpgrade(upgrade)) { break; } } }
/// <summary> /// Only for test /// </summary> /// <param name="db"></param> /// <param name="dbLock"></param> /// <param name="upgrades"></param> /// <param name="initializer"></param> /// <param name="settings"></param> /// <param name="tracker"></param> /// <param name="logFactory"></param> public MongoMigrator( IMongoDatabase db, IMigrationChain upgrades, IUpgrade initializer, IUpgradeSettings settings, IDbLock dbLock, IMigrationTracker tracker, ILoggerFactory logFactory) { _log = logFactory.CreateLogger <MongoMigrator>(); _logFactory = logFactory; _db = db; _upgrades = upgrades; _initializer = initializer; _settings = settings; _dbLock = dbLock; _tracker = tracker; _isTransactionsAvailable = _db.Client.Cluster.Description.Type > ClusterType.Standalone; }
internal static void Register(IUpgrade upgrade) { if (!ALL.ContainsKey(upgrade.Type)) { ALL.Add(upgrade.Type, new Dictionary <string, IUpgrade>()); } var dict = ALL[upgrade.Type]; if (dict.ContainsKey(upgrade.ID)) { SLog.Warn("[Upgrades] Blocked Attempt to register duplicate {0} upgrade instance for \"{1}\"", upgrade.Type, upgrade.ID); return; } //var old = ALL[upgrade.Type].FirstOrDefault(o => String.Compare(o.ID, upgrade.ID) == 0); //if (old != null) ALL[upgrade.Type].Remove(old); SLog.Debug("[Upgrades] Registered: {0}", upgrade.ID); ALL[upgrade.Type].Add(upgrade.ID, upgrade); }
protected virtual async Task Apply(IUpgrade upgrade) { _log.LogDebug("Upgrade to {0}", upgrade.UpgradeTo); using (var session = await _db.Client.StartSessionAsync()) { if (_isTransactionsAvailable) { session.StartTransaction(); } try { await upgrade.Apply(session, _db, _logFactory.CreateLogger(upgrade.GetType())); await _tracker.TrackSuccessUpgrade(session, upgrade.UpgradeTo); if (_isTransactionsAvailable) { await session.CommitTransactionAsync(); } } catch (Exception ex) { if (_isTransactionsAvailable) { _log.LogError("Upgrade to {0} failed, rollback the transaction...", upgrade.UpgradeTo); await session.AbortTransactionAsync(); } else { _log.LogCritical("Upgrade to {0} failed & transactions are not supported. DB may be inconsistent.", upgrade.UpgradeTo); } throw new MigrationException($"Upgrade to ver {upgrade.UpgradeTo} failed.", ex); } } MigrationState = await _tracker.GetState(); _log.LogDebug("Upgrade success, current version is {0}", upgrade.UpgradeTo); }
public void SetUpgrade(IUpgrade upgrade) { Slot.Upgrade = upgrade; }
private void Start() { upgrade = GetComponentInChildren <IUpgrade>(); }
public UpgradeViewModel(IUpgrade upgrade, IReadOnlyList <string> errorList) { this.upgrade = upgrade; this.ErrorsList = errorList; }
/// <summary> /// Checks if the given <paramref name="upgrade"/> is compatible /// with the object. /// </summary> /// <param name="obj">Calling object.</param> /// <param name="upgrade">Upgrade to check for compatibility.</param> /// <returns>True if upgrade is compatible, false if not.</returns> public static bool IsUpgradeCompatible(this IUpgradeable obj, IUpgrade upgrade) { return(upgrade.ValidObjects.Contains(obj.GetType())); }
public IUpgradeSlot CreatePrefilled(IUpgrade upgrade, int costReduction = 0) { return(new UpgradeSlot(upgrade.UpgradeType, upgrade, new List <IXWingSpecification <IUpgrade> >(), costReduction)); }
public InitDecorator(IUpgrade target, Version upgradeTo) { _target = target; UpgradeTo = upgradeTo; }
public static IServiceCollection AddMigrations(this IServiceCollection services, IUpgrade initializer) { return(services.AddMigrations(s => UpgradeSettings.Default, s => s.GetRequiredService <IMongoDatabase>(), s => initializer, s => null)); }
public Car(float speed) { Speed = new SpeedUpgrade(speed); }
public bool Equals(IUpgrade other) { return(Name == other.Name && UpgradeType.Equals(other.UpgradeType) && CardText == other.CardText); }
public static bool HasUpgrade(IUpgrade upgrade) { return(HasUpgrade(upgrade.ID)); }
/// <summary> /// Adds a another upgrade as a prerequisite for this one. /// The player will have to obtain the other upgrade before this one is available. /// </summary> /// <param name="upgrade"></param> public void Requires(IUpgrade upgrade) { prereqs.Add(upgrade); }