Пример #1
0
        public static void GenerateSkills(PlayerExporter exporter, CodeGenerator output)
        {
            SkillGeneratorEnv env = (SkillGeneratorEnv)exporter.GenEnv;

            for (int i = 0; i < exporter.Skills.Count; ++i)
            {
                var skill         = exporter.Skills[i];
                var skillFuncName = "skill_" + i.ToString();
                if (skill is NormalSkill)
                {
                    var cskill = (NormalSkill)skill;
                    env.CurrentSkillKeyName = cskill.Key.GetKeyName();
                    env.CurrentActionName   = cskill.ActionID;

                    var functionContent = GenerateNormalSkillFunction(exporter, env, cskill.ActionID, false);
                    functionContent = new ILineObject[] {
                        new ControlBlock(ControlBlockType.If, "!(\"uu\" in this.u)", new ILineObject[] {
                            new SimpleLineObject("this.u.uu <- { uuu = this.u.weakref() };"),
                        }).Statement(),
                    }.Concat(functionContent);

                    var func = new FunctionBlock(skillFuncName, new string[0], functionContent);
                    output.WriteStatement(func.Statement());
                }
            }
        }
 private static FunctionBlock GenerateBeginAirJump(PlayerExporter exporter, Pat.Project proj)
 {
     return(new FunctionBlock("BeginAirJump", new string[0], new ILineObject[] {
         new ControlBlock(ControlBlockType.If, "this.u.jumpCount == 0", new ILineObject[] {
             new SimpleLineObject("this.ChangeFreeMove();"),
             new SimpleLineObject("this.sitLabel = this.u.BeginSit;"),
             new SimpleLineObject("this.u.jumpCount++;"),
             new SimpleLineObject("this.isAir = true;"),
             new SimpleLineObject("this.collisionMask = 8 | 16;"),
             new SimpleLineObject("this.vy = -15.0;"),
             new SimpleLineObject("this.PlaySE(1000);"),
             new ControlBlock(ControlBlockType.If, "this.input.x * this.input.x >= 0.01", new ILineObject[] {
                 new SimpleLineObject("this.vx = this.input.x >= 0.1 ? 4.0 : -4.0;"),
                 new SimpleLineObject("this.direction = this.input.x >= 0.1 ? 1.0 : -1.0;"),
                 new SimpleLineObject("this.SetMotion(this.u.CA + 4, 0);"),
                 new SimpleLineObject("return;"),
             }).Statement(),
             new ControlBlock(ControlBlockType.Else, new ILineObject[] {
                 new SimpleLineObject("this.vx = 0.0;"),
                 new SimpleLineObject("this.SetMotion(this.u.CA + 3, 0);"),
                 new SimpleLineObject("return;"),
             }).Statement(),
         }).Statement(),
     }));
 }
Пример #3
0
 public static GenerationEnvironment CreateEnv(PlayerExporter exporter, CodeGenerator output)
 {
     return(new SkillGeneratorEnv()
     {
         Exporter = exporter,
         Output = output,
     });
 }
Пример #4
0
 private static ILineObject GenerateSkill(PlayerExporter exporter, bool isFirst, Skill skill, string name)
 {
     if (skill is NormalSkill)
     {
         return(GenerateNormalSkill(exporter, isFirst, (NormalSkill)skill, name));
     }
     return(new SimpleLineObject(""));
 }
 public static void Generate(PlayerExporter exporter, Pat.Project proj, CodeGenerator output)
 {
     output.WriteStatement(GenerateBeginAirJump(exporter, proj).Statement());
     output.WriteStatement(GenerateBeginAirSlide(exporter, proj).Statement());
     output.WriteStatement(GenerateBeginJump(exporter, proj).Statement());
     output.WriteStatement(GenerateBeginWalk(exporter, proj).Statement());
     output.WriteStatement(GenerateInputCancelMove(exporter, proj).Statement());
     output.WriteStatement(GenerateInputAttack(exporter, proj).Statement());
 }
 private static FunctionBlock GenerateBeginAirSlide(PlayerExporter exporter, Pat.Project proj)
 {
     return(new FunctionBlock("BeginAirSlide", new string[0], new ILineObject[] {
         new ControlBlock(ControlBlockType.If, "this.input.x", new ILineObject[] {
             new SimpleLineObject("this.vx += this.input.x > 0 ? 0.2 : -0.2;"),
             new ControlBlock(ControlBlockType.If, "this.Abs(this.vx) > 4.0", new ILineObject[] {
                 new SimpleLineObject("this.vx = this.vx > 0.0 ? 4.0 : -4.0;"),
             }).Statement(),
         }).Statement(),
     }));
 }
 private static FunctionBlock GenerateInputCancelMove(PlayerExporter exporter, Pat.Project proj)
 {
     return(new FunctionBlock("InputCancelMove", new string[0], new ILineObject[] {
         new ControlBlock(ControlBlockType.If, "this.flagState & 2097152 && this.input.b2 > 0 && this.input.b2 < 10", new ILineObject[] {
             new ControlBlock(ControlBlockType.If, "this.isAir", new ILineObject[] {
                 new SimpleLineObject("this.u.BeginAirJump.call(this);"),
             }).Statement(),
             new ControlBlock(ControlBlockType.Else, new ILineObject[] {
                 new SimpleLineObject("this.u.BeginJump.call(this);"),
             }).Statement(),
         }).Statement(),
     }));
 }
 private static FunctionBlock GenerateInputAttack(PlayerExporter exporter, Pat.Project proj)
 {
     return(new FunctionBlock("InputAttack", new string[0], new ILineObject[] {
         new ControlBlock(ControlBlockType.If, "this.input.b0 == 1", new ILineObject[] {
             new SimpleLineObject("this.u.inputCountA = 10;"),
         }).Statement(),
         new ControlBlock(ControlBlockType.If, "this.input.b1 == 1", new ILineObject[] {
             new SimpleLineObject("this.u.inputCountB = 10;"),
         }).Statement(),
         new ControlBlock(ControlBlockType.If, "this.input.b3 == 1", new ILineObject[] {
             new SimpleLineObject("this.u.inputCountC = 10;"),
         }).Statement(),
         new SimpleLineObject("this.u.inputCountA--;"),
         new SimpleLineObject("this.u.inputCountB--;"),
         new SimpleLineObject("this.u.inputCountC--;"),
     }.Concat(SkillGenerator.GenerateInputAttackFunction(exporter))));
 }
 private static FunctionBlock GenerateBeginWalk(PlayerExporter exporter, Pat.Project proj)
 {
     return(new FunctionBlock("BeginWalk", new string[0], new ILineObject[] {
         new ControlBlock(ControlBlockType.If, "this.input.x > 0", new ILineObject[] {
             new SimpleLineObject("this.direction = 1.0;"),
             new SimpleLineObject("this.vx = 4.0;"),
         }).Statement(),
         new ControlBlock(ControlBlockType.Else, new ILineObject[] {
             new SimpleLineObject("this.direction = -1.0;"),
             new SimpleLineObject("this.vx = -4.0;"),
         }).Statement(),
         new ControlBlock(ControlBlockType.If, "this.motion != this.u.CA + 1", new ILineObject[] {
             new SimpleLineObject("this.ChangeFreeMove();"),
             new SimpleLineObject("this.fallLabel = this.u.BeginFall;"),
             new SimpleLineObject("this.SetMotion(this.u.CA + 1, 0);"),
         }).Statement(),
     }));
 }
Пример #10
0
 public static ILineObject[] GenerateInputAttackFunction(PlayerExporter exporter)
 {
     //ILineObject[] ret = new ILineObject[exporter.Skills.Count];
     //for (int i = 0; i < exporter.Skills.Count; ++i)
     //{
     //    ret[i] = GenerateSkill(i == 0, exporter.Skills[i], "skill_" + i.ToString());
     //}
     //return ret;
     return(Enumerable.Range(0, exporter.Skills.Count)
            .Select(i => new
     {
         Code = GenerateSkill(exporter, i == 0, exporter.Skills[i], "skill_" + i.ToString()),
         Priority = exporter.Skills[i].Priority,
     })
            .OrderByDescending(s => s.Priority)
            .Select(s => s.Code)
            .ToArray());
 }
Пример #11
0
        private static ILineObject GenerateNormalSkill(PlayerExporter exporter, bool isFirst, NormalSkill skill, string name)
        {
            var u         = ThisExpr.Instance.MakeIndex("u");
            var condition = ExpressionExt.AndAll(
                KeyCondition(skill.Key),
                CancelLevelCondition(skill.CancelLevel),
                AirCondition(skill.AirState),
                XCondition(skill.X),
                YCondition(skill.Y),
                MagicCondition(skill.MagicUse),
                RushCondition(exporter, skill));

            return(new ControlBlock(isFirst ? ControlBlockType.If : ControlBlockType.ElseIf,
                                    condition, new ILineObject[] {
                u.MakeIndex("InputReset").MakeIndex("call").Call(ThisExpr.Instance).Statement(),
                u.MakeIndex(name).MakeIndex("call").Call(ThisExpr.Instance).Statement(),
            }).Statement());
        }
Пример #12
0
 private static Expression RushCondition(PlayerExporter exporter, NormalSkill skill)
 {
     if (skill.IsRushSkill)
     {
         var skillActionID = skill.ActionID;
         var indexes       = exporter.Skills
                             .Where(s => s is NormalSkill)
                             .Select(s => (NormalSkill)s)
                             .Where(s => s.RushCancel == skillActionID)
                             .Select(s =>
                                     new BiOpExpr(ThisExpr.Instance.MakeIndex("motion"),
                                                  new BiOpExpr(ThisExpr.Instance.MakeIndex("u").MakeIndex("CA"),
                                                               new ConstNumberExpr(exporter.GetActionID(s.ActionID)), BiOpExpr.Op.Add),
                                                  BiOpExpr.Op.Equal))
                             .ToArray();
         return(ExpressionExt.OrAll(indexes));
     }
     return(new ConstNumberExpr(1));
 }
Пример #13
0
        public PlayerExporterOptionsForm(Pat.Project proj, PlayerExporter exporter)
        {
            InitializeComponent();

            treeView1.LinkedPropertyGrid   = propertyGrid1;
            treeView1.LinkedDeleteButton   = button1;
            treeView1.LinkedResetButton    = button2;
            treeView1.LinkedMoveDownButton = button3;
            treeView1.LinkedMoveUpButton   = button4;

            var env = new EditableEnvironment(proj);

            treeView1.Nodes.Add(new TreeNode
            {
                Text = "Export Options",
                Tag  = exporter,
            });

            treeView1.Nodes.Add(new TreeNode
            {
                Text = "System Animations",
                Tag  = exporter.Animations,
            });

            treeView1.Nodes.Add(new TreeNode
            {
                Text = "Player Information",
                Tag  = exporter.PlayerInformation,
            });

            var skills = new TreeNode
            {
                Text = "Skills",
            };

            treeView1.Nodes.Add(skills);
            skills.Nodes.AddEditableList(env, exporter.Skills);
        }
Пример #14
0
        public static void Generate(PlayerExporter exporter, Pat.Project proj, CodeGenerator writer)
        {
            var func = new FunctionBlock(
                "Init_" + exporter.PlayerName,
                new[] { "t" },
                new ILineObject[] {
                new SimpleLineObject("this.type = 0;"),
                new SimpleLineObject("this.fontType = 0;"),
                new SimpleLineObject("this.PlayerInit(\"homura\", t.playerID);"),
                new SimpleLineObject("this.CompileFile(\"data/actor/" + exporter.ScriptFileName + ".nut\", this.u);"),
                new SimpleLineObject("this.u.CA = " + exporter.BaseIndex + ";"),
                new SimpleLineObject("this.u.regainCycle = " + exporter.PlayerInformation.RegainCycle + ";"),
                new SimpleLineObject("this.u.regainRate = " + exporter.PlayerInformation.RegainRate + ";"),
                new SimpleLineObject("this.u.magicUse = " + exporter.PlayerInformation.MagicUse + ";"),
                new SimpleLineObject("this.u.atkOffset = " + exporter.PlayerInformation.AtkOffset + ";"),
                new SimpleLineObject("this.SetMotion(this.u.CA + 0, 0);"),
                new SimpleLineObject("this.SetUpdateFunction(this.u.Update_Normal);"),
                new SimpleLineObject("this.fallLabel = this.u.BeginFall;"),
                new SimpleLineObject("this.u.dexLV = 5;"),
                new SimpleLineObject("this.world2d.CreateActor(this.x, this.y, this.direction, this.Player_Shadow, this.DefaultShotTable());"),
            });

            writer.WriteStatement(new BlockStatement(func));
        }
Пример #15
0
        private static IEnumerable <ILineObject> GenerateNormalSkillFunction(PlayerExporter exporter,
                                                                             SkillGeneratorEnv env, string id, bool stateLabelAsUpdate)
        {
            List <ILineObject> ret = new List <ILineObject>();

            var action = exporter.GetAction(id);
            var ae     = new Pat.ActionEffects(action);

            foreach (var b in action.Behaviors)
            {
                b.MakeEffects(ae);
            }

            exporter.SSERecorder.AddAction(ae, env.GetActionID(id), env);

            ret.AddRange(ae.InitEffects.Select(e => e.Generate(env)));

            var list2 = ae.UpdateEffects.Select(e => e.Generate(env));

            list2 = new ILineObject[] { GenerateNormalSkillUpdateSSEChecker() }.Concat(list2);
            if (stateLabelAsUpdate)
            {
                list2 = list2.Concat(new ILineObject[] { new SimpleLineObject("return true;") });
            }

            var         updateFunc = new FunctionBlock("", new string[0], list2).AsExpression();
            ILineObject setUpdate;

            if (stateLabelAsUpdate)
            {
                setUpdate = ThisExpr.Instance.MakeIndex("SetUpdateFunction").Call(updateFunc).Statement();
            }
            else
            {
                setUpdate = ThisExpr.Instance.MakeIndex("stateLabel").Assign(updateFunc).Statement();
            }
            ret.Add(setUpdate);

            var keys = ae.SegmentFinishEffects.Select(
                keyEffect => new FunctionBlock("", new string[0], keyEffect.Select(e => e.Generate(env))).AsExpression());
            var keyCount = action.Segments.Count - 1;

            if (ae.SegmentFinishEffects.Count < keyCount)
            {
                keyCount = ae.SegmentFinishEffects.Count;
            }
            var arrayObj = new ArrayExpr(keys.Take(keyCount).ToArray());
            var setKey   = ThisExpr.Instance.MakeIndex("keyAction").Assign(arrayObj).Statement();

            ret.Add(new SimpleLineObject("this.SetEndTakeCallbackFunction(this.KeyActionCheck);"));
            ret.Add(setKey);

            if (ae.SegmentFinishEffects.Count >= action.Segments.Count)
            {
                var effects       = ae.SegmentFinishEffects[action.Segments.Count - 1].Select(e => e.Generate(env));
                var funcEndMotion = new FunctionBlock("", new string[0], effects).AsExpression();
                var setEndMotion  = ThisExpr.Instance.MakeIndex("SetEndMotionCallbackFunction").Call(funcEndMotion).Statement();
                ret.Add(setEndMotion);
            }

            return(ret);
        }