public override void OnThink() { base.OnThink(); if (NextThink > DateTime.Now) { return; } if (m_Cannon == null) { m_Cannon = new CannonNorth(this); Direction = Direction.North; Cannon.MoveToWorld(new Point3D(X, Y - 3, Z), Map); } if (m_Cannon.Deleted) { Delete(); } if (Combatant == null) { return; } NextThink = DateTime.Now + TimeSpan.FromSeconds(2.5); FireCannon(Combatant); }
public override void Deserialize(GenericReader reader) { base.Deserialize(reader); int version = reader.ReadInt(); m_Cannon = (BaseCannon)reader.ReadItem(); }
public void ShootCannons(Mobile focus, bool shootAtBoat) { List <Item> cannons = new List <Item>(m_Galleon.Cannons); foreach (Item item in cannons) { if (item != null && item is BaseCannon && !item.Deleted) { BaseCannon cannon = item as BaseCannon; if (m_ShootTable.ContainsKey(cannon) && m_ShootTable[cannon] > DateTime.UtcNow) { continue; } Direction facing = cannon.GetFacing(); if (shootAtBoat && HasTarget(focus, cannon, true)) { cannon.AmmoType = AmmoType.Cannonball; cannon.LoadedAmmo = cannon.LoadTypes[0]; } else if (!shootAtBoat && HasTarget(focus, cannon, false)) { cannon.AmmoType = AmmoType.Grapeshot; cannon.LoadedAmmo = cannon.LoadTypes[1]; } else { continue; } cannon.Shoot(this); m_ShootTable[cannon] = DateTime.UtcNow + ShootFrequency + TimeSpan.FromSeconds(Utility.RandomMinMax(0, 3)); } } }
private bool HasTarget(Mobile focus, BaseCannon cannon, bool shootatboat) { if (cannon == null || cannon.Deleted || cannon.Map == null || cannon.Map == Map.Internal || m_Galleon == null || m_Galleon.Deleted) { return(false); } Direction d = cannon.GetFacing(); int xOffset = 0; int yOffset = 0; int cannonrange = cannon.Range; int currentRange = 0; Point3D pnt = cannon.Location; switch (d) { case Direction.North: xOffset = 0; yOffset = -1; break; case Direction.South: xOffset = 0; yOffset = 1; break; case Direction.West: xOffset = -1; yOffset = 0; break; case Direction.East: xOffset = 1; yOffset = 0; break; } int xo = xOffset; int yo = yOffset; while (currentRange++ <= cannonrange) { xOffset = xo; yOffset = yo; for (int i = -1; i <= 1; i++) { Point3D newPoint; if (xOffset == 0) { newPoint = new Point3D(pnt.X + (xOffset + i), pnt.Y + (yOffset * currentRange), pnt.Z); } else { newPoint = new Point3D(pnt.X + (xOffset * currentRange), pnt.Y + (yOffset + i), pnt.Z); } if (shootatboat) { BaseGalleon g = BaseGalleon.FindGalleonAt(newPoint, this.Map); if (g != null && g == m_TargetBoat && g != Galleon) { return(true); } } else { if (focus == null) { return(false); } if (newPoint.X == focus.X && newPoint.Y == focus.Y) { Console.WriteLine("Shooting: {0} at {1} / {2}", focus.Name, newPoint.X, newPoint.Y); return(true); } } } } return(false); }
public CannonGump(BaseCannon cannon, Mobile from) : base(50, 50) { m_Cannon = cannon; m_From = from; AddBackground(0, 0, 300, 200, 2620); Type charge = cannon is LightShipCannon ? typeof(LightPowderCharge) : typeof(HeavyPowderCharge); bool cleaned = cannon.Cleaned; bool charged = cannon.Charged; bool primed = cannon.Primed; bool loaded = cannon.AmmoType != AmmunitionType.Empty; AddHtmlLocalized(0, 10, 300, 16, 1149614 + (int)m_Cannon.Position, 21758, false, false); AddHtmlLocalized(45, 40, 100, 16, 1149626, LabelColor, false, false); //CLEAN if (!charged) { AddHtmlLocalized(45, 60, 100, 16, 1149630, LabelColor, false, false); //CHARGE } else { AddHtmlLocalized(45, 60, 100, 16, 1149629, LabelColor, false, false); //REMOVE } if (!loaded) { AddHtmlLocalized(45, 80, 100, 16, 1149635, LabelColor, false, false); //LOAD } else { AddHtmlLocalized(45, 80, 100, 16, 1149629, LabelColor, false, false); //REMOVE } if (!primed) { AddHtmlLocalized(45, 100, 100, 16, 1149637, LabelColor, false, false); //PRIME } else if (cannon.CanLight) { AddHtmlLocalized(45, 100, 100, 16, 1149638, LabelColor, false, false); //FIRE } else { AddHtmlLocalized(45, 100, 100, 16, 1149629, LabelColor, false, false); //REMOVE } if (!cleaned) { AddHtmlLocalized(150, 40, 100, 16, 1149628, RedHue, false, false); //Dirty } else { AddHtmlLocalized(150, 40, 100, 16, 1149627, GreenHue, false, false); //Clean } if (!charged) { AddHtmlLocalized(150, 60, 100, 16, 1149632, RedHue, false, false); //Not Charged } else { AddHtmlLocalized(150, 60, 100, 16, 1149631, GreenHue, false, false); //Charged } if (!loaded) { AddHtmlLocalized(150, 80, 100, 16, 1149636, RedHue, false, false); //Not Loaded } else { AddHtmlLocalized(150, 80, 100, 16, 1114057, AmmoInfo.GetAmmoName(cannon), GreenHue, false, false); } //AddHtmlLocalized(150, 80, 100, 16, cannon.AmmoType == AmmoType.Grapeshot ? 1095741 : 1116029, GreenHue, false, false); if (!primed) { AddHtmlLocalized(150, 100, 100, 16, 1149639, RedHue, false, false); //No Fuse } else { AddHtmlLocalized(150, 100, 100, 16, 1149640, GreenHue, false, false); //Primed } AddButton(10, 40, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0); AddButton(10, 60, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0); AddButton(10, 80, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0); AddButton(10, 100, 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0); if (!cannon.Actions.ContainsKey(from) || cannon.Actions[from].Count == 0) { cannon.AddAction(from, 1149653); //You are now operating the cannon. } int y = 170; int count = cannon.Actions[from].Count - 1; int hue = 0; for (int i = count; i >= 0; i--) { if (i < count - 3) { break; } if (i == count) { hue = 29315; //0xFFFF00; } else { hue = 12684; } AddHtmlLocalized(10, y, 385, 20, cannon.Actions[from][i], hue, false, false); y -= 16; } }
public BaseShip(TeamType team, string region, Vector2 location, ContentManager content, GraphicsDevice graphics) : base(team, content, graphics) { timeSinceLastTurn = 0; millisecondsPerTurn = 500; // turn speed timeSinceStartAnchor = 0; millisecondsToAnchor = 1000; msToRepair = 5000; millisecondsNewShot = 2000; movementSpeed = 0.2f; timeSinceStartSinking = 0; millisecondToSink = 10000; nSails = 1; fullHealth = 40; health = fullHealth; stopRange = 260f; maxInventorySlots = 5; string objKey = "baseShip"; //MapModelMovementVectorValues(); Texture2D textureBaseShip = content.Load <Texture2D>("BaseShip"); Texture2D textureBaseShipBB = null; if (Gusto.GameOptions.ShowBoundingBox) { textureBaseShipBB = new Texture2D(graphics, textureBaseShip.Width, textureBaseShip.Height); } Asset baseShipAsset = new Asset(textureBaseShip, textureBaseShipBB, 1, 8, 0.6f, objKey, region); // inventory List <Sprite> interiorObjs = null; if (team != TeamType.Player) { List <Tuple <string, int> > itemDrops = RandomEvents.RandomNPDrops(objKey, 5); interiorObjs = ItemUtility.CreateInteriorItems(itemDrops, team, region, location, content, graphics); mountedOnShip = new BaseCannon(teamType, regionKey, GetBoundingBox().Center.ToVector2(), content, graphics); } actionInventory = Enumerable.Repeat <InventoryItem>(null, maxInventorySlots).ToList(); // TEMPORARY -- hardcode basesail to baseship (later on we want base ship to start without a sail) shipSail = new BaseSail(team, region, location, content, graphics); shipSail.millisecondsPerFrame = 500; // match turn speed for sail shipInterior = new Interior("baseShip", this, content, graphics); // set the random drops as interior objects if (interiorObjs != null) { foreach (var obj in interiorObjs) { shipInterior.interiorObjects.Add(obj); // need to do this for containers so they drop items within ship if (obj is IContainer) { Container c = (Container)obj; c.inInteriorId = shipInterior.interiorId; } } } // set wake wake.MaxParticle = 5; wake.WakeDisplacement = 13; SetSpriteAsset(baseShipAsset, location); }
public virtual void OnHitByCannon(BaseCannon cannon, int damage) { }
// Creates the initial game state - this will probably be a huge method at the end of it.. TODO: find way to dynamically create items/npc/etc and place them in appropriate region public void CreateNewGame() { //TEMPORARY NEED TO CREATE SOME SORT OF GAME SETUP / REGION SETUP that is easily scalable List <Sprite> giannaLandTiles = BoundingBoxLocations.RegionMap["Gianna"].RegionLandTiles; List <Sprite> scLandTiles = BoundingBoxLocations.RegionMap["SnooCat"].RegionLandTiles; List <Sprite> usoppLandTiles = BoundingBoxLocations.RegionMap["Usopp"].RegionLandTiles; var screenCenter = new Vector2(_graphics.Viewport.Bounds.Width / 2, _graphics.Viewport.Bounds.Height / 2); ShortShip shortShip = new ShortShip(TeamType.Player, "GustoMap", new Vector2(-100, -600), _content, _graphics); shortShip.shipInterior.interiorId = Guid.NewGuid(); BoundingBoxLocations.interiorMap.Add(shortShip.shipInterior.interiorId, shortShip.shipInterior); BaseShip baseShip = new BaseShip(TeamType.Player, "GustoMap", new Vector2(-300, -600), _content, _graphics); baseShip.shipInterior.interiorId = Guid.NewGuid(); BoundingBoxLocations.interiorMap.Add(baseShip.shipInterior.interiorId, baseShip.shipInterior); BaseShip baseShipAI = new BaseShip(TeamType.A, "Usopp", new Vector2(500, -140), _content, _graphics); baseShipAI.shipInterior.interiorId = Guid.NewGuid(); BoundingBoxLocations.interiorMap.Add(baseShipAI.shipInterior.interiorId, baseShipAI.shipInterior); TeePee teePee = new TeePee(TeamType.A, "Gianna", new Vector2(340, -850), _content, _graphics); teePee.structureInterior.interiorId = Guid.NewGuid(); BoundingBoxLocations.interiorMap.Add(teePee.structureInterior.interiorId, teePee.structureInterior); BaseTribal baseTribalLand = new BaseTribal(TeamType.A, "Gianna", giannaLandTiles[RandomEvents.rand.Next(giannaLandTiles.Count)].location, _content, _graphics); BaseCat baseCatLand = new BaseCat(TeamType.B, "SnooCat", scLandTiles[RandomEvents.rand.Next(scLandTiles.Count)].location, _content, _graphics); Chicken chickenLand = new Chicken(TeamType.Animal, "Gianna", giannaLandTiles[RandomEvents.rand.Next(giannaLandTiles.Count)].location, _content, _graphics); Snake snakeLand = new Snake(TeamType.Animal, "Usopp", usoppLandTiles[RandomEvents.rand.Next(usoppLandTiles.Count)].location, _content, _graphics); BlueBird blueBird = new BlueBird(TeamType.Animal, "Usopp", usoppLandTiles[RandomEvents.rand.Next(usoppLandTiles.Count)].location, _content, _graphics); Tower tower = new BaseTower(TeamType.B, "GustoMap", new Vector2(-1600, -1500), _content, _graphics); ClayFurnace furnace = new ClayFurnace(TeamType.Player, "GustoMap", new Vector2(180, 140), _content, _graphics); CraftingAnvil craftingAnvil = new CraftingAnvil(TeamType.Player, "GustoMap", new Vector2(120, 40), _content, _graphics); BaseBarrel barrelLand = new BaseBarrel(TeamType.A, "GustoMap", new Vector2(-20, -160), _content, _graphics); BaseBarrel barrelOcean = new BaseBarrel(TeamType.A, "GustoMap", new Vector2(380, -90), _content, _graphics); BaseChest chestLand = new BaseChest(TeamType.A, "GustoMap", new Vector2(100, -120), _content, _graphics); CampFire campfire = new CampFire(TeamType.A, "GustoMap", new Vector2(70, -350), _content, _graphics); Shovel shovel = new Shovel(TeamType.A, "GustoMap", new Vector2(200, -330), _content, _graphics); shovel.onGround = true; Pickaxe pickaxe = new Pickaxe(TeamType.Player, "GustoMap", new Vector2(130, -430), _content, _graphics); pickaxe.onGround = true; //Pistol pistol = new Pistol(TeamType.A, "GustoMap", new Vector2(250, -300), _content, _graphics); //pistol.amountStacked = 1; //pistol.onGround = true; BaseCannon cannon = new BaseCannon(TeamType.A, "GustoMap", new Vector2(0, -450), _content, _graphics); cannon.onGround = true; Ballista ballista = new Ballista(TeamType.A, "GustoMap", new Vector2(-120, -550), _content, _graphics); ballista.onGround = true; CrossBow crossBow = new CrossBow(TeamType.A, "GustoMap", new Vector2(220, -350), _content, _graphics); crossBow.amountStacked = 1; crossBow.onGround = true; ArrowItem arrows = new ArrowItem(TeamType.A, "GustoMap", new Vector2(210, -340), _content, _graphics); arrows.onGround = true; arrows.amountStacked = 10; //PistolShotItem pistolAmmo = new PistolShotItem(TeamType.A, "GustoMap", new Vector2(220, -300), _content, _graphics); //pistolAmmo.amountStacked = 14; //pistolAmmo.onGround = true; CannonBallItem cannonAmmo = new CannonBallItem(TeamType.A, "GustoMap", new Vector2(200, -300), _content, _graphics); cannonAmmo.amountStacked = 10; cannonAmmo.onGround = true; RustyHarpoonItem harpoonAmmo = new RustyHarpoonItem(TeamType.A, "GustoMap", new Vector2(-120, -550), _content, _graphics); harpoonAmmo.amountStacked = 10; harpoonAmmo.onGround = true; Lantern lantern = new Lantern(TeamType.A, "GustoMap", new Vector2(180, -300), _content, _graphics); lantern.onGround = true; BasePlank basePlank = new BasePlank(TeamType.A, "GustoMap", new Vector2(150, -300), _content, _graphics); basePlank.onGround = true; basePlank.amountStacked = 10; // Item utility is global and is accessed in main update, all items that are "dropped" or placed on the world view ground exist in this list (placable, invetory, etc) ItemUtility.ItemsToUpdate.Add(lantern); ItemUtility.ItemsToUpdate.Add(furnace); ItemUtility.ItemsToUpdate.Add(craftingAnvil); ItemUtility.ItemsToUpdate.Add(barrelLand); ItemUtility.ItemsToUpdate.Add(barrelOcean); ItemUtility.ItemsToUpdate.Add(chestLand); ItemUtility.ItemsToUpdate.Add(shovel); //ItemUtility.ItemsToUpdate.Add(pistol); ItemUtility.ItemsToUpdate.Add(cannon); ItemUtility.ItemsToUpdate.Add(ballista); ItemUtility.ItemsToUpdate.Add(crossBow); ItemUtility.ItemsToUpdate.Add(arrows); ItemUtility.ItemsToUpdate.Add(pickaxe); //ItemUtility.ItemsToUpdate.Add(pistolAmmo); ItemUtility.ItemsToUpdate.Add(cannonAmmo); ItemUtility.ItemsToUpdate.Add(harpoonAmmo); ItemUtility.ItemsToUpdate.Add(basePlank); ItemUtility.ItemsToUpdate.Add(campfire); UpdateOrder.Add(shortShip); UpdateOrder.Add(baseShip); UpdateOrder.Add(baseShipAI); UpdateOrder.Add(player); UpdateOrder.Add(baseTribalLand); UpdateOrder.Add(baseCatLand); UpdateOrder.Add(chickenLand); UpdateOrder.Add(blueBird); UpdateOrder.Add(snakeLand); UpdateOrder.Add(tower); UpdateOrder.Add(teePee); // interior set BaseTribal baseTribalInShip = new BaseTribal(TeamType.A, "GustoMap", Vector2.Zero, _content, _graphics); baseTribalInShip.npcInInterior = baseShipAI.shipInterior; baseShipAI.shipInterior.interiorObjects.Add(baseTribalInShip); ready = true; }