public override void TileProc(int aX, int aY, ref bool refContinue) { NWField f = Field; NWTile tile = (NWTile)f.GetTile(aX, aY); Step(aX, aY); if (f.IsBarrier(aX, aY)) { if (tile.ForeBase == PlaceID.pid_Tree) { tile.Foreground = PlaceID.pid_DeadTree; string nm = BaseLocale.GetStr(StaticData.dbPlaces[5].NameRS); GlobalVars.nwrWin.ShowText(Creature, BaseLocale.Format(RS.rs_TheXIsMelted, new object[] { nm })); } refContinue = false; } else { NWCreature c = (NWCreature)f.FindCreature(aX, aY); if (c != null && c.HasAffect(EffectID.eid_Flaying)) { c.ApplyDamage(RandomHelper.GetBoundedRnd(13, 36), DamageKind.dkRadiation, null, BaseLocale.Format(RS.rs_TheXIsMelted, new object[] { c.Name })); } } }
public override void TileProc(int aX, int aY, ref bool aContinue) { NWField fld = Field; NWTile tile = (NWTile)fld.GetTile(aX, aY); Step(aX, aY); if (fld.IsBarrier(aX, aY)) { if (tile.ForeBase == PlaceID.pid_Tree) { tile.Foreground = PlaceID.pid_Undefined; fld.AddCreature(aX, aY, GlobalVars.nwrDB.FindEntryBySign("Faleryn").GUID); } aContinue = false; } else { NWCreature c = (NWCreature)fld.FindCreature(aX, aY); if (c != null) { EffectsFactory.e_Transformation(EffectID.eid_Transformation, c, null, ItemState.is_Normal, InvokeMode.im_ItSelf, null); } } }
public NWTilePath(NWTilePath tp) { listOfTiles = tp.listOfTiles.ToList(); costOfPath = tp.costOfPath; lastTile = tp.lastTile; // im not sure what this last tile deal is. figure that out later i guess }
public override void CheckTile(bool aHere) { NWField map = (NWField)CurrentMap; if (map == null) { return; } int num = fSegments.Count; for (int i = 0; i < num; i++) { ArticulateSegment seg = GetSegment(i); NWTile tile = (NWTile)map.GetTile(seg.X, seg.Y); if (tile != null) { if (aHere) { tile.CreaturePtr = this; } else { tile.CreaturePtr = null; } } } }
public static NWTileXml CreateTileXml(NWTile tile) { return(new NWTileXml() { id = (int)tile.type, locX = (int)tile.gridPosition.x, locY = (int)tile.gridPosition.y }); }
private static void ChangeFCTile(IMap map, int x, int y, object extData, ref bool refContinue) { NWTile nwTile = (NWTile)map.GetTile(x, y); if (nwTile.Foreground == PlaceID.pid_Undefined) { nwTile.FogID = (ushort)PlaceID.pid_Fog; nwTile.FogAge = (sbyte)(nwTile.FogAge + RandomHelper.GetBoundedRnd(5, 17)); } }
// public void moveCurrentUnit(NWTile t) { // perhaps the issue is that when client is trying to move a unit, it's calling moveCurrentUnit, which is trying to call CmdMoveCurrentPlayer, // but the client cannot call this, so we get blocked. // originally, we only had the line from CmdMoveCurrentPlayer here, not any of the other lines. // seems commands can only be sent from the local player object. so i think i just need to move this over to there? // but actually i cannot do that because it's a unit that's supposed to be calling it ('activeUnit'). // hmm CmdMoveCurrentPlayer(JsonUtility.ToJson(t.gridPosition)); }
public override void TileProc(int aX, int aY, ref bool aContinue) { NWField fld = Field; NWTile tile = (NWTile)fld.GetTile(aX, aY); Step(aX, aY); if (tile == null) { aContinue = false; } else { int fgp = tile.ForeBase; switch (fgp) { case PlaceID.pid_Undefined: break; case PlaceID.pid_Mountain: case PlaceID.pid_Vulcan: aContinue = false; break; case PlaceID.pid_Vortex: case PlaceID.pid_StairsDown: case PlaceID.pid_StairsUp: case PlaceID.pid_GStairsDown: case PlaceID.pid_GStairsUp: case PlaceID.pid_HoleDown: case PlaceID.pid_HoleUp: break; default: tile.Foreground = PlaceID.pid_Rubble; break; } NWCreature c = (NWCreature)fld.FindCreature(aX, aY); if (c != null) { RaceID race = c.Entry.Race; if (race == RaceID.crDefault || race == RaceID.crHuman) { c.Death("", null); } } } }
public static List <NWTile> FindPath(NWTile originTile, NWTile destinationTile, Vector2[] occupied) { List <NWTile> closed = new List <NWTile>(); List <NWTilePath> open = new List <NWTilePath>(); NWTilePath originPath = new NWTilePath(); originPath.addTile(originTile); open.Add(originPath); while (open.Count > 0) { NWTilePath current = open[0]; open.Remove(open[0]); if (closed.Contains(current.lastTile)) { continue; } // there may be some stuff here inconsistent with how i was told to do it so check on that later if you have issues if (current.lastTile == destinationTile) { current.listOfTiles.Remove(originTile); return(current.listOfTiles); } closed.Add(current.lastTile); foreach (NWTile t in current.lastTile.neighbors) { if (t.impassable || occupied.Contains(t.gridPosition)) { continue; } NWTilePath newTilePath = new NWTilePath(current); newTilePath.addTile(t); open.Add(newTilePath); } } return(null); }
private void PrepareStalk() { try { NWCreature self = (NWCreature)fSelf; AbstractMap map = self.CurrentField; if (self.Entry.Sign.Equals("WildDog")) { NWTile tile = (NWTile)map.GetTile(self.PosX, self.PosY); if (tile.ScentTrail != null) { int age = (int)tile.ScentAge; int mx = self.PosX; int my = self.PosY; for (int y = self.PosY - 1; y <= self.PosY + 1; y++) { for (int x = self.PosX - 1; x <= self.PosX + 1; x++) { tile = ((NWTile)map.GetTile(x, y)); if (age < (int)tile.ScentAge) { age = (int)tile.ScentAge; mx = x; my = y; } } } StalkGoal goal = (StalkGoal)FindGoalByKind(GoalKind.gk_Stalk); if (goal == null) { goal = ((StalkGoal)CreateGoal(GoalKind.gk_Stalk)); } goal.Position = new ExtPoint(mx, my); goal.Duration = 2; } } } catch (Exception ex) { Logger.Write("BeastBrain.prepareStalk(): " + ex.Message); } }
public override void LeavePlace(NWField field, NWTile tile) { try { base.LeavePlace(field, tile); if (field.LandID == GlobalVars.Land_Crossroads) { int fg = tile.ForeBase; if (fg == PlaceID.pid_cr_Disk || fg == PlaceID.pid_cr_Disk_Pressed) { tile.Foreground = PlaceID.pid_Undefined; GlobalVars.nwrWin.ShowText(this, BaseLocale.GetStr(RS.rs_DiskFalls)); } } } catch (Exception ex) { Logger.Write("Player.leavePlace(): " + ex.Message); throw ex; } }
private void PrepareHallucinations() { NWField field = CurrentField; HalMap = new NWField(null, field.Layer, field.Coords.Clone()); for (int y = 0; y < StaticData.FieldHeight; y++) { for (int x = 0; x < StaticData.FieldWidth; x++) { NWTile tile = (NWTile)field.GetTile(x, y); NWTile halTile = (NWTile)HalMap.GetTile(x, y); halTile.Assign(tile); halTile.Background = Hallucination.GetPlaceID(tile.BackBase); halTile.Foreground = Hallucination.GetPlaceID(tile.ForeBase); } } HalMap.Normalize(); }
public override void TileProc(int aX, int aY, ref bool refContinue) { NWField f = Field; NWTile tile = (NWTile)f.GetTile(aX, aY); Step(aX, aY); if (f.IsBarrier(aX, aY)) { if (tile.ForeBase == PlaceID.pid_Tree) { tile.Foreground = PlaceID.pid_DeadTree; string tmp = BaseLocale.GetStr(StaticData.dbPlaces[5].NameRS); GlobalVars.nwrWin.ShowText(Creature, BaseLocale.Format(RS.rs_TheXIsFrozen, new object[] { tmp })); } refContinue = false; } else { NWCreature c = (NWCreature)f.FindCreature(aX, aY); if (c != null && c.HasAffect(EffectID.eid_Ice)) { c.AddEffect(EffectID.eid_Ice, ItemState.is_Normal, EffectAction.ea_Persistent, false, BaseLocale.GetStr(RS.rs_YouAreFrozen)); Effect e = c.Effects.FindEffectByID(EffectID.eid_Ice); if (e != null && e.Magnitude >= 30) { string tmp; if (c.IsPlayer) { tmp = BaseLocale.GetStr(RS.rs_EncasedInIce); } else { tmp = BaseLocale.Format(RS.rs_TheXIsFrozen, new object[] { c.Name }); } c.Death(tmp, null); } } } }
public static void DrawSymTile(NWGameSpace space, NWField field, int px, int py, BaseScreen screen, ExtRect mapRect, ExtRect viewRect, ImageList symImages) { NWTile place = (NWTile)field.GetTile(px, py); int sx = viewRect.Left + 8 * (px + 1); int sy = viewRect.Top + 10 * (py + 1); if (place != null && !place.EmptyStates) { ushort bg = place.Background; ushort fg = place.Foreground; fg = PtTransDoor(place); short op = space.GetTileBrightness(field, place, true); symImages.DrawImage(screen, sx, sy, GetSymImageIndex(bg), op); int fog = place.FogID; if (fog != PlaceID.pid_Undefined) { symImages.DrawImage(screen, sx, sy, GetSymImageIndex((ushort)PlaceID.pid_Fog), op); } else { if (fg != PlaceID.pid_Undefined) { bool trap = field.IsTrap(px, py); if (!trap || (trap && (place.Trap_Discovered || GlobalVars.Debug_Divinity))) { symImages.DrawImage(screen, sx, sy, GetSymImageIndex(fg), op); } } } if (!field.IsBarrier(px, py) && mapRect.IsBorder(px, py)) { symImages.DrawImage(screen, sx, sy, StaticData.dbSymbols[(int)GetBorderSymbol(px, py)].ImageIndex, op); } } }
public override void TileProc(int aX, int aY, ref bool aContinue) { NWField fld = Field; NWTile tile = (NWTile)fld.GetTile(aX, aY); Step(aX, aY); if (fld.IsBarrier(aX, aY)) { if (tile.ForeBase == PlaceID.pid_Tree) { tile.Foreground = PlaceID.pid_Undefined; } aContinue = false; } else { NWCreature c = (NWCreature)fld.FindCreature(aX, aY); if (c != null) { EffectsFactory.FireHit(EffectID.eid_Fire, Creature, c, RandomHelper.GetBoundedRnd(6, 21)); } } }
void OnMouseDown() { myTile = this; // change that game scnee to whatver the acutal name of the game scene is. this applies to other situatios where i did this, make sur eyou get it right if (Application.loadedLevelName == "NetworkVersus") { myTile = this; if (NWGameManager.myUnit != null) { if (visual.transform.GetComponent <Renderer>().materials[0].color != Color.white && !impassable && NWGameManager.myUnit.moving) { NWGameManager.myUnit.moveCurrentUnit(this); } else if (NWGameManager.myUnit.attacking) { NWGameManager.instance.attackWithCurrentPlayer(this); } } } /* trying fascination edition version above. * * * * * //Player.instance.moving * //GameManager.instance.players[GameManager.instance.currentPlayerIndex].moving * * * if (NWGameManager.myUnit.moving) * { * // can call something like 'confirm path' method here, in the future * NWGameManager.instance.moveCurrentUnit(this); * } * //else if (GameManager.instance.players[GameManager.instance.currentPlayerIndex].attacking) * else if (NWGameManager.myUnit.attacking) * { * // trying to first call ConfirmTarget method * NWGameManager.instance.confirmTarget(this); * // may need to move attackWithCurrentPlayer to confirmTarget or something? * NWGameManager.instance.attackWithCurrentPlayer(this); * * } * /* else * { * // if the tile is a base, and is owned by the player whose turn it is, you can build units from it * if (this.canBuildLandUnits && ((this.addsIncomePlayerOne && GameManager.instance.playerOneTurn) || (addsIncomePlayerTwo && GameManager.instance.playerTwoTurn))) * { * // need some sort of gui thing to pick a unit * * OnGUI(); * // then, it'll instantiate the unit just like in gamemanager's auto unit generation. * } * * /* this is test code that allows you to click tiles to highlight them and make them impassable * impassable = impassable ? false : true; * if (impassable) * { * visual.transform.GetComponent<Renderer>().materials[0].color = new Color(0.5f, 0.5f, 0.0f); * } * else * { * visual.transform.GetComponent<Renderer>().materials[0].color = Color.white; * } * * }*/ else if (Application.loadedLevelName == "Map Creator") { setType(MapCreatorManager.instance.paletteSelection); } }
public override void TileProc(int aX, int aY, ref bool refContinue) { NWField f = Field; if (f.IsBarrier(aX, aY)) { refContinue = false; } else { NWTile tile = (NWTile)f.GetTile(aX, aY); int bg = tile.BackBase; if (bg == PlaceID.pid_Mud || bg == PlaceID.pid_Rubble) { tile.Background = PlaceID.pid_Ground; } else { tile.Background = dbTransmutatedList[RandomHelper.GetRandom(2)]; } NWCreature c = (NWCreature)f.FindCreature(aX, aY); if (c != null) { string cSign = c.Entry.Sign; if (cSign.Equals("Mudman") || cSign.Equals("MudFlow")) { EffectsFactory.Deanimate(f, c, tile, PlaceID.pid_Mud); } else { if (cSign.Equals("LavaFlow")) { EffectsFactory.Deanimate(f, c, tile, PlaceID.pid_Lava); } else { if (cSign.Equals("Jagredin") || cSign.Equals("LiveRock")) { EffectsFactory.Deanimate(f, c, tile, PlaceID.pid_Rubble); } else { if (cSign.Equals("SandForm")) { EffectsFactory.Deanimate(f, c, tile, PlaceID.pid_Quicksand); } else { if (cSign.Equals("WateryForm")) { EffectsFactory.Deanimate(f, c, tile, PlaceID.pid_Water); } } } } } } } }
public void addStaticTile(NWTile t) { costOfPath += 1; listOfTiles.Add(t); lastTile = t; }
public static List <NWTile> FindHighlight(NWTile originTile, int movementPoints, Vector2[] occupied, bool staticRange) { List <NWTile> closed = new List <NWTile>(); List <NWTilePath> open = new List <NWTilePath>(); NWTilePath originPath = new NWTilePath(); if (staticRange) { originPath.addStaticTile(originTile); } else { originPath.addTile(originTile); } open.Add(originPath); while (open.Count > 0) { NWTilePath current = open[0]; open.Remove(open[0]); if (closed.Contains(current.lastTile)) { continue; } // there may be some stuff here inconsistent with how i was told to do it so check on that later if you have issues if (current.costOfPath > movementPoints + 1) { continue; } closed.Add(current.lastTile); foreach (NWTile t in current.lastTile.neighbors) { if ( //t.impassable || occupied.Contains(t.gridPosition)) { continue; } NWTilePath newTilePath = new NWTilePath(current); if (staticRange) { newTilePath.addStaticTile(t); } else { newTilePath.addTile(t); } open.Add(newTilePath); } } closed.Remove(originTile); // closed.Remove(alliedUnitTiles), which is something we'll have to define and add to the method that determines that stuff, // just like it determines that we can't move past occupied tiles // we'll have to hope this doesn't obliterate pathing. // if it does i'm not sure what to do yet closed.Distinct(); return(closed); }
public void moveCurrentUnit(NWTile t) { CmdMoveCurrentUnit(JsonUtility.ToJson(t.gridPosition)); //GameManager.instance.moveCurrentPlayer(t); }
public static List <NWTile> FindHighlight(NWTile originTile, int movementPoints, bool staticRange) { return(FindHighlight(originTile, movementPoints, new Vector2[0], staticRange)); }
public static void DrawLocTile(NWGameSpace space, NWField field, int px, int py, BaseScreen screen, Player player, ExtRect mapRect, ExtRect viewRect, ImageList resImages) { NWTile place = (NWTile)field.GetTile(px, py); int xx = viewRect.Left + 32 * (px - mapRect.Left); int yy = viewRect.Top + 30 * (py - mapRect.Top); if (place != null && !place.EmptyStates) { int bg = (int)place.Background; int fg = (int)place.Foreground; int bgExt = (int)place.BackgroundExt; int fgExt = (int)place.ForegroundExt; int fog = place.FogID; int fogExt = place.FogExtID; fg = PtTransDoor(place); short op = space.GetTileBrightness(field, place, false); resImages.DrawImage(screen, xx, yy, GetTileImageIndex((ushort)bg), op); if (bgExt != PlaceID.pid_Undefined) { resImages.DrawImage(screen, xx, yy, GetTileImageIndex((ushort)bgExt), op); } if (fog != PlaceID.pid_Undefined) { resImages.DrawImage(screen, xx, yy, GetTileImageIndex((ushort)fogExt), op); } else { if (fg != PlaceID.pid_Undefined) { bool trap = field.IsTrap(px, py); if (!trap || (trap && (place.Trap_Discovered || GlobalVars.Debug_Divinity))) { resImages.DrawImage(screen, xx, yy, GetTileImageIndex((ushort)fg), op); if (fgExt != PlaceID.pid_Undefined) { resImages.DrawImage(screen, xx, yy, GetTileImageIndex((ushort)fgExt), op); } } } if (fogExt != PlaceID.pid_Undefined) { resImages.DrawImage(screen, xx, yy, GetTileImageIndex((ushort)fogExt), op); } } SymbolID sid = GetBorderSymbol(px, py); if (sid != SymbolID.sid_None && player.CanMove(field, px, py)) { switch (sid) { case SymbolID.sid_Left: resImages.DrawImage(screen, xx, yy, StaticData.dbItfElements[(int)ItfElement.id_Left].ImageIndex, op); break; case SymbolID.sid_Up: resImages.DrawImage(screen, xx, yy, StaticData.dbItfElements[(int)ItfElement.id_Up].ImageIndex, op); break; case SymbolID.sid_Right: resImages.DrawImage(screen, xx, yy, StaticData.dbItfElements[(int)ItfElement.id_Right].ImageIndex, op); break; case SymbolID.sid_Down: resImages.DrawImage(screen, xx, yy, StaticData.dbItfElements[(int)ItfElement.id_Down].ImageIndex, op); break; } } } }
// // public void DoSomethingUseful(NWTile t) { CmdDoSomethingUseful(JsonUtility.ToJson(t.gridPosition)); }
public void addTile(NWTile t) { costOfPath += t.movementCost; listOfTiles.Add(t); lastTile = t; }
public override void EnterPlace(NWField field, NWTile tile) { try { base.EnterPlace(field, tile); if (field.LandID == GlobalVars.Land_Crossroads) { if (tile.ForeBase == PlaceID.pid_cr_Disk) { tile.Foreground = PlaceID.pid_cr_Disk_Pressed; } else { int lid = -1; int fx = 0; int fy = 0; switch ((sbyte)tile.Background) { case 31: { NWField f = Space.GetRndFieldByLands(GlobalVars.Land_Niflheim, GlobalVars.Land_GiollRiver); if (f != null) { lid = f.Layer.EntryID; fx = f.Coords.X; fy = f.Coords.Y; } break; } case 32: case 33: { NWField f = Space.GetRndFieldByLands(GlobalVars.Land_SlaeterSea, GlobalVars.Land_VidRiver); if (f != null) { lid = f.Layer.EntryID; fx = f.Coords.X; fy = f.Coords.Y; } break; } case 34: case 35: { NWField f = Space.GetRndFieldByLands(GlobalVars.Land_Caves, GlobalVars.Land_DeepCaves, GlobalVars.Land_GreatCaves, GlobalVars.Land_Crypt, GlobalVars.Land_Bazaar); if (f != null) { lid = f.Layer.EntryID; fx = f.Coords.X; fy = f.Coords.Y; } break; } case 36: { NWField f = Space.GetRndFieldByLands(GlobalVars.Land_Nidavellir); if (f != null) { lid = GlobalVars.Layer_Midgard; fx = f.Coords.X; fy = f.Coords.Y; } break; } case 37: { NWField f = Space.GetRndFieldByLands(GlobalVars.Land_Forest, GlobalVars.Land_Village, GlobalVars.Land_Jotenheim); if (f != null) { lid = f.Layer.EntryID; fx = f.Coords.X; fy = f.Coords.Y; } break; } case 38: { NWField f = Space.GetRndFieldByLands(GlobalVars.Land_Wasteland, GlobalVars.Land_Muspelheim); if (f != null) { lid = f.Layer.EntryID; fx = f.Coords.X; fy = f.Coords.Y; } break; } case 39: case 40: { lid = GlobalVars.Layer_GrynrHalls; fx = 0; fy = 0; break; } case 41: case 42: { NWField f = Space.GetRndFieldByLands(GlobalVars.Land_Alfheim, GlobalVars.Land_MimerRealm); if (f != null) { lid = f.Layer.EntryID; fx = f.Coords.X; fy = f.Coords.Y; } break; } } if (lid != -1) { TransferTo(lid, fx, fy, -1, -1, StaticData.MapArea, true, true); } } } else { tile.ScentAge = 100; tile.ScentTrail = this; } } catch (Exception ex) { Logger.Write("Player.enterPlace(): " + ex.Message); throw ex; } }
public static List <NWTile> FindHighlight(NWTile originTile, int movementPoints, Vector2[] occupied) { return(FindHighlight(originTile, movementPoints, occupied, false)); }
public static List <NWTile> FindPath(NWTile originTile, NWTile destinationTile) { return(FindPath(originTile, destinationTile, new Vector2[0])); }