public void swapWith(InventoryPowerupIcon secondIcon, Hero hero, bool? equipOrUnequipThis) { Powerup secondPowerup = secondIcon.Powerup; Powerup firstPowerup = this.Powerup; if (equipOrUnequipThis != null) { if (equipOrUnequipThis.Value) // equipping { if (secondPowerup != null) hero.RemovePowerup(secondPowerup.GenericName, false); if (firstPowerup != null) firstPowerup = hero.AddPowerup(firstPowerup.GetType(), false); } else // uneqipping { if (firstPowerup != null) hero.RemovePowerup(firstPowerup.GenericName, false); if (secondPowerup != null) secondPowerup = hero.AddPowerup(secondPowerup.GetType(), false); } } this.SetPowerup(secondPowerup); secondIcon.SetPowerup(firstPowerup); }
private static void displaySwapWarning(string warningString, InventoryPowerupIcon warnedIcon1 = null, InventoryPowerupIcon warnedIcon2 = null) { warning = warningString; warningFlashTime = 0; if (warning != "" && warnedIcon1 != null && warnedIcon2 != null) { warnedIcons = new Point[] { new Point(warnedIcon1.rowIndex, warnedIcon1.iconIndex), new Point(warnedIcon2.rowIndex, warnedIcon2.iconIndex) }; } else { warnedIcons = null; } }
private static void flashAcquiredPowerup(InventoryPowerupIcon icon) { if (icon != null) { acquiredIcons.Add(new AcquiredIcon{ pos = new Point(icon.rowIndex, icon.iconIndex), time = 0 }); } }
public static void Initialize() { arrowTex = TextureManager.Get("arrow"); healthBorderTex = TextureManager.Get("healthborder"); healthFillingTex = TextureManager.Get("healthfilling"); powerupLists = new PowerupList[RetroGame.NUM_PLAYERS]; for (int i = 0; i < powerupLists.Length; i++) { powerupLists[i].actives = new Powerup[MAX_ACTIVE_POWERUPS]; powerupLists[i].passives = new Powerup[MAX_PASSIVE_POWERUPS]; } /*inventory icons*/ //equipped for (int i = 0; i < RetroGame.NUM_PLAYERS; i++) { storageGrid[i] = new InventoryPowerupIcon[MAX_ACTIVE_POWERUPS + MAX_PASSIVE_POWERUPS]; for (int j = 0; j < MAX_ACTIVE_POWERUPS; j++) { Powerup powerup = powerupLists[i].actives[j]; storageGrid[i][j] = new InventoryPowerupIcon(i, j, true, powerup, (InputAction)Enum.Parse(typeof(InputAction), "Action" + (j + 1))); } for (int j = MAX_ACTIVE_POWERUPS; j < MAX_ACTIVE_POWERUPS + MAX_PASSIVE_POWERUPS; j++) { Powerup powerup = powerupLists[i].passives[j - MAX_ACTIVE_POWERUPS]; storageGrid[i][j] = new InventoryPowerupIcon(i, j, false, powerup, null); } } //storage for (int i = RetroGame.MAX_PLAYERS; i < RetroGame.MAX_PLAYERS + STORAGE_ACTIVE_ROWS + STORAGE_PASSIVE_ROWS; i++) { if (i < RetroGame.MAX_PLAYERS + STORAGE_ACTIVE_ROWS) // active { storageGrid[i] = new InventoryPowerupIcon[STORAGE_ACTIVE_POWERUPS_PER_ROW]; for (int j = 0; j < STORAGE_ACTIVE_POWERUPS_PER_ROW; j++) { storageGrid[i][j] = new InventoryPowerupIcon(i, j, true, null, null); } } else //passive { storageGrid[i] = new InventoryPowerupIcon[STORAGE_PASSIVE_POWERUPS_PER_ROW]; for (int j = 0; j < STORAGE_PASSIVE_POWERUPS_PER_ROW; j++) { storageGrid[i][j] = new InventoryPowerupIcon(i, j, false, null, null); } } } }