public override bool CheckProceduralPrecondition(GameObject _agent) { CampFire[] fires = FindObjectsOfType <CampFire>(); CampFire closest = null; float dist = 0; foreach (CampFire f in fires) { if (f.isFound) { if (closest == null) { closest = f; dist = Vector3.Distance(transform.position, f.transform.position); } else { float dist2 = Vector3.Distance(transform.position, f.transform.position); if (dist > dist2) { closest = f; dist = dist2; } } } } if (closest != null) { targetFire = closest; target = targetFire.gameObject; } //return closest != null; return(true); }
public InventorySlot SearchItem(int type, int itemClass) { // Return an item, as well as all its properties InventorySlot item = new Empty(); if (itemClass == 0) { // Is it a resource? switch (type) { case 0: // Wood item = new Wood(); break; case 1: // Dirt item = new Dirt(); break; case 2: // Stone item = new Stone(); break; case 3: // Grass item = new Grass(); break; } } else { // Is it a tool? switch (type) { case 11: // Spear item = new Spear(); break; case 12: // Fence item = new Fence(); break; case 13: // CampFire item = new CampFire(); break; case 14: // Rope item = new Rope(); break; case 15: // Hammer item = new Hammer(); break; } } return(item); }
public void CircleCast(Vector3 position) { var hit = Physics2D.CircleCast(position, CraftRange, Vector2.zero, 0f, _baseMask); if (hit) // bases nearby { if (!_lastFrameOnBase && OnEnter != null) { OnEnter(); _lastFrameOnBase = true; _campfire = hit.transform.gameObject.GetComponent <CampFire>(); } } else { if (_lastFrameOnBase && OnExit != null) { OnExit(); _lastFrameOnBase = false; _campfire = null; } } hit = Physics2D.CircleCast(position, CraftRange, Vector2.zero, 0f, LayerMask.GetMask("RuneStone")); // Tee array var RunestoneCast = Physics2D.CircleCastAll(position, 5, Vector2.zero, 0f, LayerMask.GetMask("RuneStone")); ClosebyInfoStones.Clear(); if (RunestoneCast.Length != 0) { foreach (RaycastHit2D t in RunestoneCast) { var infostone = t.transform.GetComponent <InfoStone>(); infostone.AlphaEffect(); ClosebyInfoStones.Add(infostone); // reki } } //if (hit) // runeStoneNearby! //{ // // !TODO: tänään aloitetaan tosta! // //hit.transform.gameObject.GetComponent<InfoStone>().Vibrate(); // //GameObject.FindGameObjectWithTag("ResourceUiController").GetComponent<CraftingUiController>().Vibrate(0, 0); // //GameObject.FindGameObjectWithTag("ResourceUiController").GetComponent<CraftingUiController>().Vibrate(1, 0); // //GameObject.FindGameObjectWithTag("ResourceUiController").GetComponent<CraftingUiController>().Vibrate(2, 0); // //GameObject.FindGameObjectWithTag("ResourceUiController").GetComponent<CraftingUiController>().Vibrate(1, 1); // //GameObject.FindGameObjectWithTag("ResourceUiController").GetComponent<CraftingUiController>().Vibrate(0, 2); // //GameObject.FindGameObjectWithTag("ResourceUiController").GetComponent<CraftingUiController>().Vibrate(1, 2); // //GameObject.FindGameObjectWithTag("ResourceUiController").GetComponent<CraftingUiController>().Vibrate(2, 2); //} }
void Awake() { Instance = this; info.AllLoadData(); DontDestroyOnLoad(this.gameObject); }
private Sprite DeserializeModel(string objKey, ISaveState objSave) { // Add base sprite models here, (AnimatedSprite namespace, not Model namespace) Sprite sp = null; OnGroundState ogs; ShipState ss; NpcState npcs; StructureState sts; switch (objKey) { // TODO: Should I save fired ammo state? case "baseShip": ss = (ShipState)objSave; BaseShip bs = new BaseShip(ss.team, ss.region, ss.location, _content, _graphics); bs.health = ss.health; bs.actionInventory = DeserializeInventory(ss.actionInventory); //bs.shipInterior = DeserializeInterior(ss.interiorState); we do this after models are created bs.playerAboard = ss.playerAboard; bs.SetInteriorForId(ss.shipId); if (bs.playerAboard) { bs.shipSail.playerAboard = true; } return(bs); case "baseTribal": npcs = (NpcState)objSave; BaseTribal bt = new BaseTribal(npcs.team, npcs.region, npcs.location, _content, _graphics); bt.health = npcs.health; bt.inventory = DeserializeInventory(npcs.inventory); return(bt); case "baseCat": npcs = (NpcState)objSave; BaseCat bct = new BaseCat(npcs.team, npcs.region, npcs.location, _content, _graphics); bct.health = npcs.health; bct.inventory = DeserializeInventory(npcs.inventory); return(bct); case "chicken": npcs = (NpcState)objSave; Chicken chk = new Chicken(npcs.team, npcs.region, npcs.location, _content, _graphics); chk.health = npcs.health; chk.inventory = DeserializeInventory(npcs.inventory); return(chk); case "blueBird": npcs = (NpcState)objSave; BlueBird bbr = new BlueBird(npcs.team, npcs.region, npcs.location, _content, _graphics); bbr.health = npcs.health; bbr.inventory = DeserializeInventory(npcs.inventory); return(bbr); case "snake": npcs = (NpcState)objSave; Snake snk = new Snake(npcs.team, npcs.region, npcs.location, _content, _graphics); snk.health = npcs.health; snk.inventory = DeserializeInventory(npcs.inventory); return(snk); case "teePee": sts = (StructureState)objSave; TeePee tp = new TeePee(sts.team, sts.region, sts.location, _content, _graphics); return(tp); case "baseBarrel": ogs = (OnGroundState)objSave; BaseBarrel bb = new BaseBarrel(ogs.team, ogs.region, ogs.location, _content, _graphics); bb.drops = DeserializeInventory(ogs.inventory); return(bb); case "baseChest": ogs = (OnGroundState)objSave; BaseChest bc = new BaseChest(ogs.team, ogs.region, ogs.location, _content, _graphics); bc.inventory = DeserializeInventory(ogs.inventory); return(bc); case "clayFurnace": ogs = (OnGroundState)objSave; ClayFurnace cf = new ClayFurnace(ogs.team, ogs.region, ogs.location, _content, _graphics); return(cf); case "campFire": ogs = (OnGroundState)objSave; CampFire caf = new CampFire(ogs.team, ogs.region, ogs.location, _content, _graphics); return(caf); case "craftingAnvil": ogs = (OnGroundState)objSave; CraftingAnvil ca = new CraftingAnvil(ogs.team, ogs.region, ogs.location, _content, _graphics); return(ca); } return(sp); }
// 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; }
public override void Reset() { cooked = false; targetFire = null; startTime = 0; }