public override void Apply(CharSheet sheet, int anim) { for (int ii = 0; ii < sheet.AnimData[anim].Sequences.Count; ii++) { DirH dirH; DirV dirV; DirExt.Separate((Dir8)ii, out dirH, out dirV); if (dirH == DirH.Left && !StartRight || dirH == DirH.Right && StartRight) { dirH = dirH.Reverse(); Dir8 flipDir = DirExt.Combine(dirH, dirV); List <CharAnimFrame> frames = new List <CharAnimFrame>(); for (int jj = 0; jj < sheet.AnimData[anim].Sequences[ii].Frames.Count; jj++) { CharAnimFrame origFrame = sheet.AnimData[anim].Sequences[ii].Frames[jj]; CharAnimFrame newFrame = new CharAnimFrame(origFrame); newFrame.Flip = !newFrame.Flip; newFrame.Offset = new Loc(-newFrame.Offset.X, newFrame.Offset.Y); newFrame.ShadowOffset = new Loc(-newFrame.ShadowOffset.X, newFrame.ShadowOffset.Y); frames.Add(newFrame); } sheet.AnimData[anim].Sequences[(int)flipDir].Frames = frames; } } sheet.Collapse(false, true); }
public void DrawShadow(SpriteBatch spriteBatch, Loc offset) { CharSheet sheet = GraphicsManager.GetChara(CurrentForm); int teamShadow = 1; currentCharAction.DrawShadow(spriteBatch, offset, sheet, new Loc(1, teamShadow * 2)); }
public override void Draw(SpriteBatch spriteBatch, Loc offset, CharSheet sheet) { Loc drawLoc = GetDrawLoc(offset, sheet); drawLoc.Y -= LocHeight; //draw sprite at current frame sheet.DrawChar(spriteBatch, AnimFrameType, false, DirExt.AddAngles(CharDir, dirOffset), drawLoc.ToVector2(), FrameMethod, Microsoft.Xna.Framework.Color.White * ((float)opacity / 255)); }
public virtual void Draw(SpriteBatch spriteBatch, Loc offset, CharSheet sheet) { Loc drawLoc = GetDrawLoc(sheet, offset); drawLoc.Y -= LocHeight; //draw sprite at current frame sheet.DrawChar(spriteBatch, charFrameType, true, DirExt.AddAngles(CharDir, dirOffset), drawLoc.ToVector2(), determineFrame, Microsoft.Xna.Framework.Color.White * ((float)opacity / 255)); }
public void GetCurrentSprite(out MonsterID currentForm, out Loc currentOffset, out int currentHeight, out int currentAnim, out int currentTime, out int currentFrame) { currentForm = CurrentForm; currentOffset = drawOffset; currentHeight = LocHeight; CharSheet sheet = GraphicsManager.GetChara(CurrentForm); currentCharAction.GetCurrentSprite(sheet, out currentAnim, out currentTime, out currentFrame); }
public void CallOnDidPerform(Action a) { if (OnDidPerform != null) { OnDidPerform(a); } CharSheet.CallOnDidPerform(a); }
public void DrawShadow(SpriteBatch spriteBatch, Loc offset) { CharSheet sheet = GraphicsManager.GetChara(CurrentForm); Loc shadowType = new Loc(0, 0 + sheet.ShadowSize * 2); Loc shadowPoint = currentCharAction.GetActionPoint(sheet, ActionPointType.Shadow); GraphicsManager.Shadows.DrawTile(spriteBatch, (shadowPoint - offset).ToVector2() - new Vector2(GraphicsManager.Shadows.TileWidth / 2, GraphicsManager.Shadows.TileHeight / 2), shadowType.X, shadowType.Y); }
public void Draw(SpriteBatch spriteBatch, Loc offset) { CharSheet sheet = GraphicsManager.GetChara(CurrentForm); currentCharAction.Draw(spriteBatch, offset, sheet); if (currentEmote != null) { currentEmote.Draw(spriteBatch, offset - MapLoc - drawOffset); } }
public List <Action> QueryActions() { List <Action> opts = new List <Action> (); CharSheet.ProduceActions(this, opts); foreach (Action act in opts) { act.actor = this; } return(opts); }
public void Draw(SpriteBatch spriteBatch, Loc offset) { CharSheet sheet = GraphicsManager.GetChara(CurrentForm); currentCharAction.Draw(spriteBatch, offset, sheet); if (currentEmote != null) { Loc head = currentCharAction.GetActionPoint(sheet, ActionPointType.Head); currentEmote.Draw(spriteBatch, offset - head - drawOffset); } }
public void ActorTurnBegan() { if (!TurnInProgress) { CharSheet.TurnBegan(this); TurnInProgress = true; } if (OnTurnBegan != null) { OnTurnBegan(this); } }
public async Task <ActionResult> Put(int id, [FromBody] CharSheet charSheet) { var old = await Db.CharSheets.AsNoTracking().FirstOrDefaultAsync(c => c.Id == id); if (old == null) { new NotFoundResult(); } charSheet.Id = id; Db.CharSheets.Update(charSheet); await Db.SaveChangesAsync(); return(new OkResult()); }
public override void Apply(CharSheet sheet, int anim) { for (int ii = 0; ii < sheet.AnimData[anim].Sequences.Count; ii++) { CharAnimFrame firstFrame = sheet.AnimData[anim].Sequences[ii].Frames[0]; Loc diff = StandardCenter - firstFrame.ShadowOffset; for (int jj = 0; jj < sheet.AnimData[anim].Sequences[ii].Frames.Count; jj++) { CharAnimFrame origFrame = sheet.AnimData[anim].Sequences[ii].Frames[jj]; CharAnimFrame newFrame = new CharAnimFrame(origFrame); newFrame.Offset = newFrame.Offset + diff; newFrame.ShadowOffset = newFrame.ShadowOffset + diff; sheet.AnimData[anim].Sequences[ii].Frames[jj] = newFrame; } } sheet.Collapse(false, true); }
private void Export(string currentPath, MonsterID currentForm) { if (checkSprites) { CharSheet sheet = GraphicsManager.GetChara(currentForm); CharSheet.Export(sheet, currentPath); } else { PortraitSheet sheet = GraphicsManager.GetPortrait(currentForm); PortraitSheet.Export(sheet, currentPath); } DiagManager.Instance.LogInfo("Frames from:\n" + GetFormString(currentForm) + "\nhave been exported to:" + currentPath); btnReimport.Enabled = true; }
private void DressRootWithStandardActions(ActionButtonNode root) { List <Action> actions = QueryActions(); foreach (Action action in actions) { ActionButtonNode actionRoot = action.GetOptionTreeRoot(); if (action.IsAttack) { if (AttacksLeft() <= 0) { actionRoot.disabled = true; actionRoot.disabledReason = "You cannot attack more than\n" + CharSheet.AttacksPerRound + " time(s) per turn."; } else if (UsedAction()) { actionRoot.disabled = true; actionRoot.disabledReason = "You've already taken an action this turn"; } } else if (UsedAction() && !action.IsWait) { actionRoot.disabled = true; actionRoot.disabledReason = "You've already taken an action this turn"; } //implements the rule where casting can't be done with unproficent equipment if (action is Cast) { if (!CharSheet.IsProficientInAllWornEquipment()) { actionRoot.disabled = true; actionRoot.disabledReason = "You cannot cast spells when wielding weapons or armour you are not proficient in"; } } root.AddChild(actionRoot); } }
public static void BakeCharSheet(string spriteDir, Dictionary <MonsterID, byte[]> spriteData, MonsterID formData) { //check to see if files exist string[] pngs = Directory.GetFiles(spriteDir, "*.png", SearchOption.TopDirectoryOnly); if (pngs.Length < 1) { DiagManager.Instance.LogInfo("Skipped loading from " + Path.GetFullPath(spriteDir)); return; } using (CharSheet sprite = CharSheet.Import(spriteDir)) { using (MemoryStream stream = new MemoryStream()) { using (BinaryWriter writer = new BinaryWriter(stream)) sprite.Save(writer); byte[] writingBytes = stream.ToArray(); spriteData[formData] = writingBytes; } } DiagManager.Instance.LogInfo("Loaded " + pngs.Length + " from " + Path.GetFullPath(spriteDir)); }
public List <ATTile> TilesWithinAttackReach() { return(occupying.TilesWithinRange(CharSheet.Reach())); }
public override void Apply(CharSheet sheet, int anim) { CharAnimGroup charAnim = new CharAnimGroup(); if (anim == 40) { charAnim.InternalIndex = 8; charAnim.HitFrame = 5; charAnim.ReturnFrame = 5; for (int ii = 0; ii < sheet.AnimData[GraphicsManager.IdleAction].Sequences.Count; ii++) { CharAnimSequence newSequence = new CharAnimSequence(); int curEndTime = 0; for (int jj = 0; jj < DirExt.DIR8_COUNT + 1; jj++) { curEndTime += swing_durations[jj]; CharAnimSequence sequence = sheet.AnimData[GraphicsManager.IdleAction].Sequences[(ii + jj) % DirExt.DIR8_COUNT]; CharAnimFrame frame = new CharAnimFrame(sequence.Frames[0]); frame.Offset = frame.Offset + swing_offsets[ii, jj]; frame.ShadowOffset = frame.ShadowOffset + swing_shadows[ii, jj]; frame.EndTime = curEndTime; newSequence.Frames.Add(frame); } charAnim.Sequences.Add(newSequence); } } else if (anim == 41) { charAnim.InternalIndex = 9; for (int ii = 0; ii < sheet.AnimData[GraphicsManager.IdleAction].Sequences.Count; ii++) { CharAnimSequence sequence = sheet.AnimData[GraphicsManager.IdleAction].Sequences[ii]; CharAnimSequence newSequence = new CharAnimSequence(); int curEndTime = 0; for (int jj = 0; jj < double_durations.Length; jj++) { curEndTime += double_durations[jj]; CharAnimFrame frame = new CharAnimFrame(sequence.Frames[0]); frame.Offset = frame.Offset + double_offsets[ii, jj]; frame.ShadowOffset = frame.ShadowOffset + double_shadows[ii, jj]; frame.EndTime = curEndTime; newSequence.Frames.Add(frame); } charAnim.Sequences.Add(newSequence); } } else if (anim == 42) { charAnim.InternalIndex = 12; charAnim.HitFrame = 8; for (int ii = 0; ii < sheet.AnimData[GraphicsManager.IdleAction].Sequences.Count; ii++) { CharAnimSequence newSequence = new CharAnimSequence(); int curEndTime = 0; for (int jj = 0; jj < DirExt.DIR8_COUNT + 1; jj++) { curEndTime += 2; CharAnimSequence sequence = sheet.AnimData[GraphicsManager.IdleAction].Sequences[(ii + jj) % DirExt.DIR8_COUNT]; CharAnimFrame frame = new CharAnimFrame(sequence.Frames[0]); frame.EndTime = curEndTime; newSequence.Frames.Add(frame); } charAnim.Sequences.Add(newSequence); } } sheet.AnimData[anim] = charAnim; }
public abstract void Apply(CharSheet sheet, int anim);
public async Task Post([FromBody] CharSheet charSheet) { Db.CharSheets.Add(charSheet); await Db.SaveChangesAsync(); }
public override void Apply(CharSheet sheet, int anim) { }
private int totalFrameTickFrame(List <CharAnimFrame> frames) { return(CharSheet.TrueFrame(frames, (long)GraphicsManager.TotalFrameTick, false)); }
protected override int FrameMethod(List <CharAnimFrame> frames) { return(CharSheet.TrueFrame(frames, PrevActionTime.Ticks + ActionTime.Ticks * ((SpeedMult > 1) ? 2 : 1), false)); }
protected override int FrameMethod(List <CharAnimFrame> frames) { return(CharSheet.FractionFrame(frames, ActionTime.Ticks, FrameTick.FrameToTick(AnimTotalTime), true)); }
protected override int FrameMethod(List <CharAnimFrame> frames) { return(CharSheet.TrueFrame(frames, ActionTime.Ticks, false)); }
protected override int FrameMethod(List <CharAnimFrame> frames) { return(CharSheet.TrueFrame(frames, Math.Min(ActionTime.Ticks, FrameTick.FrameToTick(AnimReturnTime)), true)); }
public override void Apply_Feat(CharSheet chr) { chr._actions.Add (Actions.Mode (_name, _bonus)); }
public void RollInitiative() { currentInitiative = CharSheet.ProduceAndRollInitiative(); Debug.Log(CharSheet.Name + " rolled initiative: " + currentInitiative.ToString()); }
/// <summary> /// Set up this character. /// </summary> /// <param name="id">ID for this character used by the GM</param> /// <param name="isnpc">Whether this character is a NPC</param> /// <param name="loadfrom">Load the character from a character sheet file</param> public void Set_Character(int id, bool isnpc, string chartxt="", Texture2D img=default(Texture2D) ) { my_id = id; imnpc = isnpc; my_group = isnpc ? 0 : 1; if (chartxt == "") { stats = new CharSheet(); } else { stats = new CharSheet(chartxt); if (img!=default(Texture2D)){ float imglen=Math.Max(img.width,img.height); Sprite npcsprite=Sprite.Create(img,new Rect(new Vector2(0,0), new Vector2(img.width,img.height)),new Vector2(.5f,.5f),imglen); GetComponent<SpriteRenderer>().sprite=npcsprite; } } if (imnpc) { myAI = new CharAI(this); } charname = stats._name; Set_Size (stats.Get_Attr("size")); // occupy square map.Occupy_At (my_squares, my_id); }
public void GetCurrentSprite(CharSheet sheet, out int currentAnim, out int currentTime, out int currentFrame) { currentAnim = charFrameType; currentTime = ActionTime.ToFrames(); currentFrame = sheet.GetCurrentFrame(charFrameType, DirExt.AddAngles(CharDir, dirOffset), FrameMethod); }
public Loc GetDrawLoc(CharSheet sheet, Loc offset) { return(new Loc(MapLoc.X + GraphicsManager.TileSize / 2 - sheet.TileWidth / 2, MapLoc.Y + GraphicsManager.TileSize / 2 - sheet.TileHeight / 2) + drawOffset - offset); }
public override Loc GetActionPoint(CharSheet sheet, ActionPointType pointType) { Loc midTileOffset = new Loc(GraphicsManager.TileSize / 2); return(MapLoc + midTileOffset + drawOffset + sheet.GetActionPoint(charFrameType, false, DirExt.AddAngles(CharDir, dirOffset), pointType, determineFrame)); }
public virtual void Apply_Feat(CharSheet chr) { }