Skip to content

Commit

Permalink
Fixed a crash on creating new fighters
Browse files Browse the repository at this point in the history
  • Loading branch information
digiholic committed Feb 9, 2020
1 parent d09d1a2 commit 5e61808
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 32 deletions.
6 changes: 6 additions & 0 deletions Assets/Editor/PostBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
using UnityEditor.Build;
using UnityEngine;
using UnityEditor.Build.Reporting;
using System;

class PostBuild : IPostprocessBuildWithReport
{
public int callbackOrder { get { return 0; } }
public void OnPostprocessBuild(BuildReport report)
{
Debug.Log(report.summary.outputPath);
CopyModuleDirectory(report);
}

private void CopyModuleDirectory(BuildReport report){
FileInfo info = new FileInfo(report.summary.outputPath);
DirectoryInfo buildTargetDirectory = info.Directory;
DirectoryInfo buildAssetsDirectory = buildTargetDirectory.CreateSubdirectory("Assets");
Expand All @@ -23,4 +28,5 @@ public void OnPostprocessBuild(BuildReport report)

Debug.Log("Copied Modules Directory");
}

}
11 changes: 11 additions & 0 deletions Assets/Engine/CommandLineParser.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/Engine/SerializedClasses/FighterInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public void GenerateDefaultAttributes()
variables = new List<VarData>();
variables.Add(new VarData(TussleConstants.FighterAttributes.WEIGHT, "10", VarType.FLOAT));
variables.Add(new VarData(TussleConstants.FighterAttributes.GRAVITY, "-20", VarType.FLOAT));
variables.Add(new VarData(TussleConstants.FighterAttributes.MAX_FALL_SPEED, "7", VarType.FLOAT));
variables.Add(new VarData(TussleConstants.FighterAttributes.MAX_FALL_SPEED, "-7", VarType.FLOAT));
variables.Add(new VarData(TussleConstants.FighterAttributes.MAX_GROUND_SPEED, "5.5", VarType.FLOAT));
variables.Add(new VarData(TussleConstants.FighterAttributes.RUN_SPEED, "2.5", VarType.FLOAT));
variables.Add(new VarData(TussleConstants.FighterAttributes.MAX_AIR_SPEED, "8.5", VarType.FLOAT));
Expand Down
Binary file modified Assets/Menu/LegacyEditor/LegacyEditor.unity
Binary file not shown.
71 changes: 40 additions & 31 deletions Assets/Menu/LegacyEditor/NewFighterPopup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,7 @@ public void CreateFighter(DirectoryInfo createdDir, FighterInfo templateFighter)
FighterInfo newInfo;
if (templateFighter != null)
{
newInfo = templateFighter.Clone();
DirectoryInfo oldDir = FileLoader.GetFighterDir(templateFighter.directory_name);
try {
FileLoader.CopyDirectory(oldDir.FullName,createdDir.FullName,true);
} catch {
DisplayError("Could not find an existing Fighter named " + templateFighter + ", are you sure you used the Directory name?");
}

newInfo.displayName = directoryName;
newInfo.directory_name = directoryName;
newInfo.actionFilePath = "fighter_actions.json";
newInfo.GenerateDefaultAttributes();

//Copy over relevant files
// FileInfo action_file_info = new FileInfo(FileLoader.PathCombine(FileLoader.ProgramDirectoryInfo.FullName,templateFighter.actionFilePath));
// action_file_info.CopyTo(FileLoader.PathCombine(createdDir.FullName,newInfo.actionFilePath));
newInfo = CloneTemplateFighter(createdDir, templateFighter);
}
else
{
Expand All @@ -49,26 +34,50 @@ public void CreateFighter(DirectoryInfo createdDir, FighterInfo templateFighter)
{
//TODO Clone default actions here
}
}

if (useSprite)
{
DirectoryInfo spriteDir = Directory.CreateDirectory(Path.Combine(createdDir.FullName, "sprites"));
SpriteInfo spriteInfo = new SpriteInfo();
spriteInfo.Save(Path.Combine(createdDir.FullName,"sprite_info.json"));

spriteInfo.spriteDirectory = "sprites";
spriteInfo.default_sprite = "idle";
spriteInfo.costumeName = "default";
newInfo.sprite_info = spriteInfo;
}
if (useSprite)
{
DirectoryInfo spriteDir = Directory.CreateDirectory(Path.Combine(createdDir.FullName, "sprites"));
SpriteInfo spriteInfo = new SpriteInfo();

if (useModel)
{
//TODO create model directory and stuff
spriteInfo.spriteDirectory = "sprites";
spriteInfo.default_sprite = "idle";
spriteInfo.costumeName = "default";

spriteInfo.Save(Path.Combine(createdDir.FullName,"sprite_info.json"));
newInfo.sprite_info = spriteInfo;
}

if (useModel)
{
//TODO create model directory and stuff
}
}

newInfo.Save(Path.Combine(FileLoader.GetFighterDir(directoryName).FullName, "fighter_info.json"));
newInfo.sprite_info.Save(Path.Combine(createdDir.FullName,"sprite_info.json"));

LegacyEditorData.instance.LoadNewFighter(newInfo);
Dispose();
}

private FighterInfo CloneTemplateFighter(DirectoryInfo createdDir, FighterInfo templateFighter){
Debug.Log("Cloning Template Fighter");
FighterInfo newInfo = templateFighter.Clone();
DirectoryInfo oldDir = FileLoader.GetFighterDir(templateFighter.directory_name);
try {
FileLoader.CopyDirectory(oldDir.FullName,createdDir.FullName,true);
} catch {
DisplayError("Could not find an existing Fighter named " + templateFighter + ", are you sure you used the Directory name?");
}

newInfo.displayName = directoryName;
newInfo.directory_name = directoryName;
newInfo.actionFilePath = "fighter_actions.json";

newInfo.sprite_info = templateFighter.sprite_info;

return newInfo;
}

public void OnConfirm()
Expand Down

0 comments on commit 5e61808

Please sign in to comment.