public override void removeCastingSquares(IntVec cursorPosition) { for (int i = 0; i < castSquares.Length; i++) { castSquares[i] = new IntVec(0, 0); } }
public override bool filledSquares() { bool filled = true; IntVec test = new IntVec(0, 0); for (int i = 0; i < castSquares.Length && filled; i++) { filled = !(castSquares[i].Equals(test)); } return filled || isFinished; }
public override void removeCastingSquares(IntVec cursorPosition) { for (int i = 0; i < castSquares.Length; i++) { if (castSquares[i].Equals(cursorPosition)) { Engine.Engine.Log("Removing grid square"); castSquares[i] = new IntVec(0, 0); } } }
public override void addCastingSquares(IntVec cursorPosition) { if (castSquares[0].X == 0 && castSquares[0].Y == 0) { castSquares = radiusSquares; } else { isActuallyFilled = true; } }
protected override void finishCast(int damage, Mapping.Level mapLevel, HeroClasses.Hero hero) { for (int i = 0; i < castSquares.Length; i++) { GameCharacter test = (GameCharacter)mapLevel.CharacterEntities.FindEntity(castSquares[i]); if (test != null) { Engine.Engine.AddVisualAttack(test, "Hero/sword-slash", .25f, 2.0f, .15f); Audio.playSound("Slash", .25f); test.TakeDamage(damage, hero); } castSquares[i] = new IntVec(0, 0); } }
public Cleave() { name = "Cleave"; description = "The warrior strikes two immideately \nadjacent squares."; castSquares = new IntVec[2]; for (int i = 0; i < castSquares.Length; i++) { castSquares[i] = new IntVec(0, 0); } baseDamage = 5; radius = 1; abilityCooldown = 5; abilityIndex = 0; }
public override void finishCastandDealDamage(int heroLevel, int heroDamage, Level mapLevel, HeroClasses.Hero hero) { int damage = calculateDamage(heroLevel, heroDamage); cooldown = abilityCooldown; wasJustCast = true; for (int i = 0; i < castSquares.Length; i++) { GameCharacter enemy = (GameCharacter)mapLevel.CharacterEntities.FindEntity(castSquares[i]); if (enemy != null) { drawVisualEffect(hero, enemy); enemy.TakeDamage(damage, hero); } castSquares[i] = new IntVec(0, 0); } isActuallyFilled = false; }
public override void finishCastandDealDamage(int heroLevel, int heroDamage, Level mapLevel, HeroClasses.Hero hero) { damage = calculateDamage(heroLevel, heroDamage); cooldown = abilityCooldown; wasJustCast = true; isActuallyFilled = false; for (int i = 0; i < castSquares.Length; i++) { GameCharacter test = (GameCharacter)mapLevel.CharacterEntities.FindEntity(castSquares[i]); if (test != null && !test.isFriendly) { Audio.playSound("ArrowShot"); Engine.Engine.AddVisualAttack(hero, test, "Enemies/Attacks/Arrow", 1.0f, 1.0f, 0); test.TakeDamage(damage, hero); } castSquares[i] = new IntVec(0, 0); } }
public override void addCastingSquares(IntVec cursorPosition) { IntVec mouse = new IntVec(cursorPosition.X, cursorPosition.Y); bool filled = false; for (int i = 0; i < castSquares.Length && !filled; i++) { if ((castSquares[i].X == 0 && castSquares[i].Y == 0)) { if (castSquares.Contains(mouse)) { isFinished = true; } filled = true; if (!isFinished) { castSquares[i] = mouse; } } } }
public override void addCastingSquares(IntVec cursorPosition) { IntVec mouse = new IntVec(cursorPosition.X, cursorPosition.Y); for (int i = 0; i < castSquares.Length && !isActuallyFilled; i++) { isActuallyFilled = !(castSquares[i].Equals(new IntVec(0,0))); } if (!isActuallyFilled) { for (int i = 0; i < radiusSquares.Length; i++) { if (radiusSquares[i].Equals(mouse)) { IntVec[] additions = AStar.getPossiblePositionsFrom(mapLevel, mouse, damageRadius, true); castSquares[0] = mouse; for (int j = 0; j < additions.Length; j++) { castSquares[j + 1] = additions[j]; } } } } }
public static void AddGridSelections(IntVec[] gridSpaces, DynamicTexture tex) { foreach (IntVec iv in gridSpaces){ gridSelection.Add(new GridSelection(iv, tex)); } }
public static void AddVisualAttack(IntVec origin, string attackSprite, float startScale = 1, float endScale = 1, float scaleAmount = 0.05f) { IntVec gamePositionOrigin = origin*CELLWIDTH; Vector2 originVector = Vector2.Transform(new Vector2(gamePositionOrigin.X, gamePositionOrigin.Y), worldToView); if (attackSprite != null) { vattacks.Add(new VisualAttack(originVector, attackSprite, startScale, endScale, scaleAmount)); } else { } }
public override IntVec[] viewCastRange(Level level, IntVec start) { IntVec[] test = AStar.getPossiblePositionsFrom(level, start, radius, AStar.CharacterTargeting.TARGET_FIRST, true); return test; }
public static void Draw(Sprite sprite, IntVec destination) { if (sprite.Texture != null && IsTileInView(destination) && sprite.IsVisible && sprite.Texture.texture != null) { game.spriteBatch.Draw(sprite.Texture.texture, new Rectangle(destination.X * CELLWIDTH, destination.Y * CELLWIDTH, CELLWIDTH, CELLWIDTH), new Rectangle(sprite.SourceTile.X * CELLWIDTH, sprite.SourceTile.Y * CELLWIDTH, CELLWIDTH, CELLWIDTH), sprite.Blend, sprite.Direction, new Vector2(CELLWIDTH / 2, CELLWIDTH / 2), SpriteEffects.None, 0); } }
public static void AddXP(int xp, IntVec gameGrid) { if (gameGrid != null) { hero.AddExperience(xp); IntVec worldPosition = gameGrid * CELLWIDTH; Vector2 worldVector = Vector2.Transform(new Vector2(worldPosition.X, worldPosition.Y), worldToView); for (int i = 0; i < xp; i++) { XPParticle newxp = new XPParticle( new Vector2(worldVector.X + enginerand.Next(CELLWIDTH) - CELLWIDTH / 2, worldVector.Y + enginerand.Next(CELLWIDTH) - CELLWIDTH / 2), enginerand.Next(15) + 10); xpList.Add(newxp); } } }
public abstract void removeCastingSquares(IntVec cursorPosition);
private void setLocationsToCheck(IntVec position) { }
private void dropItem(IntVec dropPosition, int slot) { if (slot < contents.Count) { Engine.Engine.currentLevel.DroppedItems.Add(contents[slot], dropPosition); } }
private bool isPositionClear(IntVec position) { bool isClear = false; if (Engine.Engine.currentLevel.isSolid(position) && Engine.Engine.currentLevel.DroppedItems.FindEntity(position) == null) { isClear = true; } return isClear; }
public static void Start(Game1 injectedGame) { game = injectedGame; hero = new HeroClasses.Warrior(); GenerateLevel(); windowSizeInTiles = new IntVec(game.Width / CELLWIDTH, game.Height / CELLWIDTH); cameraPosition = currentLevel.CharacterEntities.FindPosition(hero); modifiedCameraPosition.X = cameraPosition.X - (windowSizeInTiles.X / 2); modifiedCameraPosition.Y = cameraPosition.Y - (windowSizeInTiles.Y / 2); LogPosition = new Vector2(12, 12); // = new Vector2(game.Width - 48, game.Height - 48); InventoryPosition = new Vector2(game.Width - 5 * (CELLWIDTH), game.Height - 4 * (CELLWIDTH)); InvButtonPosition = new Vector2(game.Width - CELLWIDTH, game.Height - CELLWIDTH); abilityPosition = new Vector2(game.Width / 2, game.Height - CELLWIDTH); charSheetPosition = new Vector2(0, 60); InventorySize = new Vector2(4 * CELLWIDTH, 4 * CELLWIDTH); weaponEquipPosition = new Vector2(0, game.Height - 2 * CELLWIDTH - 20); armorEquipPosition = new Vector2(0, game.Height - CELLWIDTH); game.IsMouseVisible = true; LoadMainMenu(); saveButton = new UIButton(new Vector2(game.Width / 2 - 150, game.Height / 2), true, "UI/Save", "Save and quit"); continueButton = new UIButton(new Vector2(game.Width / 2 + 150, game.Height / 2), true, "UI/Continue", "Continue"); headSlot = new UIButton(armorEquipPosition, false, "UI/HelmOverlay", "Helm"); chestSlot = new UIButton(new Vector2(armorEquipPosition.X + CELLWIDTH, armorEquipPosition.Y), false, "UI/ChestOverlay", "Chest"); legSlot = new UIButton(new Vector2(armorEquipPosition.X + 2 * (CELLWIDTH), armorEquipPosition.Y), false, "UI/LegsOverlay", "Legs"); ringSlot1 = new UIButton(new Vector2(armorEquipPosition.X + 3 * (CELLWIDTH), armorEquipPosition.Y), false, "UI/RingOverlay", "Ring"); ringSlot2 = new UIButton(new Vector2(armorEquipPosition.X + 4 * (CELLWIDTH), armorEquipPosition.Y), false, "UI/RingOverlay", "Ring"); neckSlot = new UIButton(new Vector2(armorEquipPosition.X + 5 * (CELLWIDTH), armorEquipPosition.Y), false, "UI/NeckOverlay", "Neck"); weaponSlot1 = new UIButton(new Vector2(weaponEquipPosition.X, weaponEquipPosition.Y), false, "UI/InvSlot", "Left"); weaponSlot2 = new UIButton(new Vector2(weaponEquipPosition.X + CELLWIDTH, weaponEquipPosition.Y), false, "UI/InvSlot", "Right"); texState.AddressU = TextureAddressMode.Clamp; texState.AddressV = TextureAddressMode.Clamp; texState.AddressW = TextureAddressMode.Clamp; texState.Filter = TextureFilter.Linear; //StartGame(); }
private PositionCheck CreatePosition(IntVec position) { PositionCheck temp = new PositionCheck(); temp.position = position; temp.isChecked = false; return temp; }
public override IntVec[] viewCastRange(Level level, IntVec start) { radiusSquares = AStar.getPossiblePositionsFrom(level, start, radius, AStar.CharacterTargeting.PASS_THROUGH, true); return radiusSquares; }
public abstract IntVec[] viewCastRange(Level level, IntVec start);
public void resetSquares() { for (int i = 0; i < castSquares.Length; i++) { castSquares[i] = new IntVec(0, 0); } }
public GridSelection(IntVec iv, DynamicTexture t) { gridPos = iv; tex = t; }
private bool isPositionClear(int X, int Y) { IntVec position = new IntVec(X, Y); bool isClear = false; if (!Engine.Engine.currentLevel.isSolid(position)) { isClear = true; } return isClear; }
public abstract void addCastingSquares(IntVec cursorPosition);
public static void Update(GameTime gameTime) { MouseController.Update(); if (gameStarted) { if (heroPos == null) { heroPos = currentLevel.CharacterEntities.FindPosition(hero); } for (int i = 0; i < xpList.Count; i++) { if (xpList[i].update()) { xpList.RemoveAt(i); drawXP++; } } for (int i = 0; i < vattacks.Count; i++) { if (vattacks[i].update()) { vattacks.RemoveAt(i); } } for (int i = 0; i < splashes.Count(); i++) { if (splashes[i].update()) { splashes.RemoveAt(i); } } if (!GameCommands()) { currentLevel.testUpdate(); //Game turns //hero.TakeTurn(currentLevel); if (charIndex >= currentLevel.CharacterEntities.Entities().Count<GameCharacter>()) { charIndex = 0; } while (currentLevel.CharacterEntities.Entities().ElementAt<GameCharacter>(charIndex) != hero) { if (hero != null) { heroPos = currentLevel.CharacterEntities.FindPosition(hero); } if (charIndex < currentLevel.CharacterEntities.Entities().Count<GameCharacter>() && heroPos != null) { IntVec enemyPosition = currentLevel.CharacterEntities.FindPosition(currentLevel.CharacterEntities.Entities().ElementAt<GameCharacter>(charIndex)); if (enemyPosition.X > heroPos.X - AIDist && enemyPosition.X < heroPos.X + AIDist && enemyPosition.Y > heroPos.Y - AIDist && enemyPosition.Y < heroPos.Y + AIDist && HeroClasses.Hero.visible) { if (currentLevel.CharacterEntities.Entities().ElementAt<GameCharacter>(charIndex).TakeTurn(currentLevel)) { currentLevel.InvalidateCache(); charIndex++; } } else { charIndex++; } } if (charIndex >= currentLevel.CharacterEntities.Entities().Count<GameCharacter>()) { charIndex = 0; } } charIndex += hero.TakeTurn(currentLevel) ? 1 : 0; if (hero.hasReachedBranchLevel()) { tempPosition = currentLevel.CharacterEntities.FindPosition(hero); tempEquip = hero.GetEquipment(); tempInventory = hero.GetInventory(); currentLevel.CharacterEntities.Remove(hero); if (HeroClasses.Hero.level < 20) { gameStarted = false; showCharSelection = true; if (HeroClasses.Hero.heroRole == Enums.Classes.Warrior) { selection = new CharButton[] { bralwerButton, sentinelButton }; } else if (HeroClasses.Hero.heroRole == Enums.Classes.Mage) { selection = new CharButton[] { sorcererButton, magusButton }; } else if (HeroClasses.Hero.heroRole == Enums.Classes.Rogue) { selection = new CharButton[] { duelistButton, rangerButton }; } } else { //new class, not branching... if (HeroClasses.Hero.heroRole == Enums.Classes.Duelist) { hero = new HeroClasses.Assassin(); UpdateAbilities(); Log("You are now an Assasin."); splashes.Add(new Splash(upAssassin, new Vector2(game.Width / 2, game.Height / 2), 3, .05f)); drawXP = hero.getExperience(); gameStarted = true; hero.ObtainItems(tempInventory, tempEquip); hero.obtainStartingGear(currentLevel); currentLevel.CharacterEntities.Add(hero, tempPosition); } if (HeroClasses.Hero.heroRole == Enums.Classes.Brawler) { hero = new HeroClasses.Berserker(); UpdateAbilities(); Log("You are now a Berserker."); splashes.Add(new Splash(upBerserker, new Vector2(game.Width / 2, game.Height / 2), 3, .05f)); drawXP = hero.getExperience(); gameStarted = true; hero.ObtainItems(tempInventory, tempEquip); hero.obtainStartingGear(currentLevel); currentLevel.CharacterEntities.Add(hero, tempPosition); } if (HeroClasses.Hero.heroRole == Enums.Classes.Sentinel) { hero = new HeroClasses.Juggernaut(); UpdateAbilities(); Log("You are now a Juggernaut."); splashes.Add(new Splash(upJuggernaut, new Vector2(game.Width / 2, game.Height / 2), 3, .05f)); drawXP = hero.getExperience(); gameStarted = true; hero.ObtainItems(tempInventory, tempEquip); hero.obtainStartingGear(currentLevel); currentLevel.CharacterEntities.Add(hero, tempPosition); } if (HeroClasses.Hero.heroRole == Enums.Classes.Sorcerer) { hero = new HeroClasses.Spellweaver(); UpdateAbilities(); Log("You are now a SpellWeaver."); splashes.Add(new Splash(upSpellweaver, new Vector2(game.Width / 2, game.Height / 2), 3, .05f)); drawXP = hero.getExperience(); gameStarted = true; hero.ObtainItems(tempInventory, tempEquip); hero.obtainStartingGear(currentLevel); currentLevel.CharacterEntities.Add(hero, tempPosition); } if (HeroClasses.Hero.heroRole == Enums.Classes.Magus) { hero = new HeroClasses.SpellBlade(); UpdateAbilities(); Log("You are now a SpellBlade."); splashes.Add(new Splash(upSpellblade, new Vector2(game.Width / 2, game.Height / 2), 3, .05f)); drawXP = hero.getExperience(); gameStarted = true; hero.ObtainItems(tempInventory, tempEquip); hero.obtainStartingGear(currentLevel); currentLevel.CharacterEntities.Add(hero, tempPosition); } if (HeroClasses.Hero.heroRole == Enums.Classes.Ranger) { hero = new HeroClasses.Marksman(); UpdateAbilities(); Log("You are now a Marksman."); splashes.Add(new Splash(upMarksman, new Vector2(game.Width / 2, game.Height / 2), 3, .05f)); drawXP = hero.getExperience(); gameStarted = true; hero.ObtainItems(tempInventory, tempEquip); hero.obtainStartingGear(currentLevel); currentLevel.CharacterEntities.Add(hero, tempPosition); } } } if (currentLevel.CharacterEntities.FindPosition(hero) != null) { cameraPosition = currentLevel.CharacterEntities.FindPosition(hero); modifiedCameraPosition.X = cameraPosition.X - (windowSizeInTiles.X / 2); modifiedCameraPosition.Y = cameraPosition.Y - (windowSizeInTiles.Y / 2); currentLevel.InvalidateCache(); } } } else { if (mainMenuOpen) { if (mageButton.isClicked()) { hero = new HeroClasses.Mage(); HeroClasses.Hero.level = 5; UpdateAbilities(); mainMenuOpen = false; showSaveSlotSelection = true; } if (warriorButton.isClicked()) { hero = new HeroClasses.Warrior(); HeroClasses.Hero.level = 5; UpdateAbilities(); mainMenuOpen = false; showSaveSlotSelection = true; } if (rogueButton.isClicked()) { hero = new HeroClasses.Rogue(); HeroClasses.Hero.level = 5; UpdateAbilities(); mainMenuOpen = false; showSaveSlotSelection = true; } int saveSlot = saveSlotClicked(); if (saveSlot != -1) { LoadFromSlot(saveSlot); } if (quitButton.isClicked()) { System.Environment.Exit(0); } } else if (savePromptOpen) { if (saveButton.isClicked()) { SaveToSlot(currentSaveSlot); System.Environment.Exit(0); } if (continueButton.isClicked()) { savePromptOpen = false; gameStarted = true; } } else if (showSaveSlotSelection) { int saveClicked = saveSlotClicked(); if (saveClicked != -1) { currentSaveSlot = saveClicked; showSaveSlotSelection = false; StartGame(); } } else if (showEscMenu) { if (escQuit.isClicked()) { Environment.Exit(0); } if (escContinue.isClicked()) { showEscMenu = false; gameStarted = true; } if (escMainMenu.isClicked()) { showEscMenu = false; xpList.Clear(); currentDungeonLevel = 0; LoadSaveSlots(); vattacks.Clear(); mainMenuOpen = true; } } else if (showCharSelection) { if (selection.Contains(bralwerButton) && bralwerButton.isClicked()) { hero = new HeroClasses.Brawler(); UpdateAbilities(); Log("You are now a brawler."); showCharSelection = false; gameStarted = true; drawXP = hero.getExperience(); hero.ObtainItems(tempInventory, tempEquip); hero.obtainStartingGear(currentLevel); currentLevel.CharacterEntities.Add(hero, tempPosition); } if (selection.Contains(duelistButton) && duelistButton.isClicked()) { hero = new HeroClasses.Duelist(); UpdateAbilities(); Log("You are now a duelist."); showCharSelection = false; drawXP = hero.getExperience(); gameStarted = true; hero.ObtainItems(tempInventory, tempEquip); hero.obtainStartingGear(currentLevel); currentLevel.CharacterEntities.Add(hero, tempPosition); } if (selection.Contains(sorcererButton) && sorcererButton.isClicked()) { hero = new HeroClasses.Sorcerer(); UpdateAbilities(); Log("You are now a Sorcerer."); showCharSelection = false; drawXP = hero.getExperience(); gameStarted = true; hero.ObtainItems(tempInventory, tempEquip); hero.obtainStartingGear(currentLevel); currentLevel.CharacterEntities.Add(hero, tempPosition); } if (selection.Contains(magusButton) && magusButton.isClicked()) { hero = new HeroClasses.Magus(); UpdateAbilities(); Log("You are now a Magus."); showCharSelection = false; gameStarted = true; drawXP = hero.getExperience(); hero.ObtainItems(tempInventory, tempEquip); hero.obtainStartingGear(currentLevel); currentLevel.CharacterEntities.Add(hero, tempPosition); } if (selection.Contains(sentinelButton) && sentinelButton.isClicked()) { hero = new HeroClasses.Sentinel(); UpdateAbilities(); Log("You are now a Sentinel."); showCharSelection = false; gameStarted = true; drawXP = hero.getExperience(); hero.ObtainItems(tempInventory, tempEquip); hero.obtainStartingGear(currentLevel); currentLevel.CharacterEntities.Add(hero, tempPosition); } if (selection.Contains(rangerButton) && rangerButton.isClicked()) { hero = new HeroClasses.Ranger(); UpdateAbilities(); Log("You are now a Ranger."); showCharSelection = false; drawXP = hero.getExperience(); gameStarted = true; hero.ObtainItems(tempInventory, tempEquip); hero.obtainStartingGear(currentLevel); currentLevel.CharacterEntities.Add(hero, tempPosition); } } else if (showDeathScreen) { if (quitDeathButton.isClicked()) { Environment.Exit(0); } if (restartButton.isClicked()) { showDeathScreen = false; xpList.Clear(); currentDungeonLevel = 0; LoadSaveSlots(); vattacks.Clear(); mainMenuOpen = true; } } } if (gameStarted) { Audio.update(); } if (hero != null && !hero.isAlive() && gameStarted) { gameStarted = false; showDeathScreen = true; } }
public IntVec(IntVec other) { ints[0] = other.X; ints[1] = other.Y; }
private void createLocations(IntVec position) { int layer; positonsToChecked = new PositionCheck[size]; layer = 1; positonsToChecked[0] = CreatePosition(new IntVec(position.X - layer, position.Y - layer)); positonsToChecked[1] = CreatePosition(new IntVec(position.X, position.Y - layer)); positonsToChecked[2] = CreatePosition(new IntVec(position.X - layer, position.Y)); positonsToChecked[3] = CreatePosition(new IntVec(position.X, position.Y)); positonsToChecked[4] = CreatePosition(new IntVec(position.X + layer, position.Y + layer)); positonsToChecked[5] = CreatePosition(new IntVec(position.X + layer, position.Y)); positonsToChecked[6] = CreatePosition(new IntVec(position.X, position.Y + layer)); layer = 2; positonsToChecked[7] = CreatePosition(new IntVec(position.X - layer, position.Y - layer)); positonsToChecked[8] = CreatePosition(new IntVec(position.X, position.Y - layer)); positonsToChecked[9] = CreatePosition(new IntVec(position.X - layer, position.Y)); positonsToChecked[10] = CreatePosition(new IntVec(position.X, position.Y)); positonsToChecked[11] = CreatePosition(new IntVec(position.X + layer, position.Y + layer)); positonsToChecked[12] = CreatePosition(new IntVec(position.X + layer, position.Y)); positonsToChecked[13] = CreatePosition(new IntVec(position.X, position.Y + layer)); }