コード例 #1
0
ファイル: TestNess.cs プロジェクト: dogmahtagram/Finale
        public static void InitAnimations()
        {
            Texture2D nessTexture = WorldEditor.Instance.Content.Load<Texture2D>("commando");

            Animation walkAnimation = new Animation();
            walkAnimation.Name = "walk";
            walkAnimation.Texture = nessTexture;
            for (int index = 0; index < 4; index++)
            {
                walkAnimation.ChangeFrameMotionDelta(index, 0, new Vector2(0, 30.0f));
                walkAnimation.SetFrameDuration(index, 5);
            }
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.N, new Rectangle(0, 0, 64, 64), 0);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.N, new Rectangle(0, 64, 64, 64), 1);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.N, new Rectangle(0, 128, 64, 64), 2);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.N, new Rectangle(0, 64, 64, 64), 3);

            walkAnimation.AddFrame(RotationComponent.CardinalDirections.NE, new Rectangle(64, 0, 64, 64), 0);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.NE, new Rectangle(64, 64, 64, 64), 1);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.NE, new Rectangle(64, 128, 64, 64), 2);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.NE, new Rectangle(64, 64, 64, 64), 3);

            walkAnimation.AddFrame(RotationComponent.CardinalDirections.E, new Rectangle(128, 64, 64, 64), 0);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.E, new Rectangle(128, 128, 64, 64), 1);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.E, new Rectangle(128, 64, 64, 64), 2);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.E, new Rectangle(128, 0, 64, 64), 3);

            walkAnimation.AddFrame(RotationComponent.CardinalDirections.SE, new Rectangle(192, 0, 64, 64), 0);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.SE, new Rectangle(192, 64, 64, 64), 1);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.SE, new Rectangle(192, 128, 64, 64), 2);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.SE, new Rectangle(192, 64, 64, 64), 3);

            walkAnimation.AddFrame(RotationComponent.CardinalDirections.S, new Rectangle(256, 0, 64, 64), 0);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.S, new Rectangle(256, 64, 64, 64), 1);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.S, new Rectangle(256, 128, 64, 64), 2);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.S, new Rectangle(256, 64, 64, 64), 3);

            walkAnimation.AddFrame(RotationComponent.CardinalDirections.SW, new Rectangle(320, 0, 64, 64), 0);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.SW, new Rectangle(320, 64, 64, 64), 1);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.SW, new Rectangle(320, 128, 64, 64), 2);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.SW, new Rectangle(320, 64, 64, 64), 3);

            walkAnimation.AddFrame(RotationComponent.CardinalDirections.W, new Rectangle(384, 0, 64, 64), 0);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.W, new Rectangle(384, 64, 64, 64), 1);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.W, new Rectangle(384, 128, 64, 64), 2);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.W, new Rectangle(384, 64, 64, 64), 3);

            walkAnimation.AddFrame(RotationComponent.CardinalDirections.NW, new Rectangle(448, 0, 64, 64), 0);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.NW, new Rectangle(448, 64, 64, 64), 1);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.NW, new Rectangle(448, 128, 64, 64), 2);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.NW, new Rectangle(448, 64, 64, 64), 3);

            Animation attackAnimation = new Animation();
            attackAnimation.Name = "attack";
            attackAnimation.Texture = nessTexture;
            for (int index = 0; index < 2; index++)
            {
                attackAnimation.ChangeFrameMotionDelta(index, 0, new Vector2(0, 10.0f));
                attackAnimation.SetFrameDuration(index, 4);
            }

            attackAnimation.AddFrame(RotationComponent.CardinalDirections.N, new Rectangle(0, 192, 64, 64), 0);
            attackAnimation.AddFrame(RotationComponent.CardinalDirections.N, new Rectangle(0, 256, 64, 64), 1);

            attackAnimation.AddFrame(RotationComponent.CardinalDirections.NE, new Rectangle(64, 192, 64, 64), 0);
            attackAnimation.AddFrame(RotationComponent.CardinalDirections.NE, new Rectangle(64, 256, 64, 64), 1);

            attackAnimation.AddFrame(RotationComponent.CardinalDirections.E, new Rectangle(128, 192, 64, 64), 0);
            attackAnimation.AddFrame(RotationComponent.CardinalDirections.E, new Rectangle(128, 256, 64, 64), 1);

            attackAnimation.AddFrame(RotationComponent.CardinalDirections.SE, new Rectangle(192, 192, 64, 64), 0);
            attackAnimation.AddFrame(RotationComponent.CardinalDirections.SE, new Rectangle(192, 256, 64, 64), 1);

            attackAnimation.AddFrame(RotationComponent.CardinalDirections.S, new Rectangle(256, 192, 64, 64), 0);
            attackAnimation.AddFrame(RotationComponent.CardinalDirections.S, new Rectangle(256, 256, 64, 64), 1);

            attackAnimation.AddFrame(RotationComponent.CardinalDirections.SW, new Rectangle(320, 192, 64, 64), 0);
            attackAnimation.AddFrame(RotationComponent.CardinalDirections.SW, new Rectangle(320, 256, 64, 64), 1);

            attackAnimation.AddFrame(RotationComponent.CardinalDirections.W, new Rectangle(384, 192, 64, 64), 0);
            attackAnimation.AddFrame(RotationComponent.CardinalDirections.W, new Rectangle(384, 256, 64, 64), 1);

            attackAnimation.AddFrame(RotationComponent.CardinalDirections.NW, new Rectangle(448, 192, 64, 64), 0);
            attackAnimation.AddFrame(RotationComponent.CardinalDirections.NW, new Rectangle(448, 256, 64, 64), 1);

            int idleX = 0;
            Rectangle[] idleFrames = new Rectangle[8];
            for (int index = 0; index < 8; index++)
            {
                idleFrames[index] = new Rectangle(idleX, 0, 64, 64);
                idleX += 64;
            }

            Animation idleAnimation = new Animation();
            idleAnimation.Name = "idle";
            idleAnimation.SetFrameDuration(0, 1);
            idleAnimation.Texture = nessTexture;

            idleAnimation.AddFrame(RotationComponent.CardinalDirections.N, idleFrames[0], 0);
            idleAnimation.AddFrame(RotationComponent.CardinalDirections.NE, idleFrames[1], 0);
            idleAnimation.AddFrame(RotationComponent.CardinalDirections.E, idleFrames[2], 0);
            idleAnimation.AddFrame(RotationComponent.CardinalDirections.SE, idleFrames[3], 0);
            idleAnimation.AddFrame(RotationComponent.CardinalDirections.S, idleFrames[4], 0);
            idleAnimation.AddFrame(RotationComponent.CardinalDirections.SW, idleFrames[5], 0);
            idleAnimation.AddFrame(RotationComponent.CardinalDirections.W, idleFrames[6], 0);
            idleAnimation.AddFrame(RotationComponent.CardinalDirections.NW, idleFrames[7], 0);

            AnimatedManager.Instance.AddAnimation("idle", idleAnimation);
            AnimatedManager.Instance.AddAnimation("walk", walkAnimation);
            AnimatedManager.Instance.AddAnimation("attack", attackAnimation);
            InputScriptNode isLeftStickActiveNode = new InputScriptNode();
            isLeftStickActiveNode.ScriptType = InputScriptNode.InputScriptType.TYPE_LEFT_STICK_ACTIVE;

            PlayAnimationScriptNode playWalkAnimScriptNode = new PlayAnimationScriptNode();
            playWalkAnimScriptNode.AnimationToQueue = "walk";
            playWalkAnimScriptNode.FrameToQueue = 0;
            playWalkAnimScriptNode.PlayIfTrue = true;

            PlayAnimationScriptNode playIdleAnimScriptNode = new PlayAnimationScriptNode();
            playIdleAnimScriptNode.AnimationToQueue = "idle";
            playIdleAnimScriptNode.FrameToQueue = 0;
            playIdleAnimScriptNode.PlayIfTrue = false;

            ToggleMotionDeltaScriptNode toggleMotionDeltaNode = new ToggleMotionDeltaScriptNode();

            InputScriptNode attackButtonNode = new InputScriptNode();
            attackButtonNode.ScriptType = InputScriptNode.InputScriptType.TYPE_BUTTON_DOWN;
            object attackString = "attack";
            attackButtonNode.SetInputValue(attackString);

            PlayAnimationScriptNode playAttackScriptNode = new PlayAnimationScriptNode();
            playAttackScriptNode.PlayIfTrue = true;
            playAttackScriptNode.AnimationToQueue = "attack";

            PlayAnimationScriptNode backToIdleNode = new PlayAnimationScriptNode();
            backToIdleNode.AnimationToQueue = "idle";
            backToIdleNode.PlayIfTrue = false;

            isLeftStickActiveNode.Name = "Is left stick active";
            playWalkAnimScriptNode.Name = "Play walk animation";
            playIdleAnimScriptNode.Name = "Play idle animation";
            toggleMotionDeltaNode.Name = "Toggle motion delta";
            playAttackScriptNode.Name = "Play attack animation";
            attackButtonNode.Name = "If attack button hit";
            ScriptNodeManager.Instance.RegisterNode(isLeftStickActiveNode);
            ScriptNodeManager.Instance.RegisterNode(playWalkAnimScriptNode);
            ScriptNodeManager.Instance.RegisterNode(playIdleAnimScriptNode);
            ScriptNodeManager.Instance.RegisterNode(playAttackScriptNode);
            ScriptNodeManager.Instance.RegisterNode(toggleMotionDeltaNode);
            ScriptNodeManager.Instance.RegisterNode(attackButtonNode);

            //ScriptNodeManager.Instance.SerializeNodes("ness.nodes");

            ScriptRoutine inputToWalkScript = new ScriptRoutine();
            inputToWalkScript.Add("Is left stick active");
            inputToWalkScript.Add("Play walk animation");
            idleAnimation.AddScriptRoutine(inputToWalkScript);

            ScriptRoutine noInputToIdleScript = new ScriptRoutine();
            noInputToIdleScript.Add("Is left stick active");
            noInputToIdleScript.Add("Play idle animation");
            walkAnimation.AddScriptRoutine(noInputToIdleScript);

            ScriptRoutine toggleMotionDeltaScript = new ScriptRoutine();
            toggleMotionDeltaScript.Add("Is left stick active");
            toggleMotionDeltaScript.Add("Toggle motion delta");
            walkAnimation.AddScriptRoutine(toggleMotionDeltaScript);
            attackAnimation.AddScriptRoutine(toggleMotionDeltaScript);

            ScriptRoutine playAttackScript = new ScriptRoutine();
            playAttackScript.Add("If attack button hit");
            playAttackScript.Add("Play attack animation");
            walkAnimation.AddScriptRoutine(playAttackScript);
            idleAnimation.AddScriptRoutine(playAttackScript);

            ScriptRoutine keepAttackingScript = new ScriptRoutine();
            keepAttackingScript.Add("If attack button hit");
            keepAttackingScript.Add("Play attack animation");
            attackAnimation.AddFrameRoutine(1, keepAttackingScript);

            ScriptRoutine backToIdleScript = new ScriptRoutine();
            backToIdleScript.Add("If attack button hit");
            backToIdleScript.Add("Play idle animation");
            attackAnimation.AddFrameRoutine(1, backToIdleScript);
        }
コード例 #2
0
        private void AddRoutineClicked(object sender, EventArgs e)
        {
            string newName = "New Script Routine";
            ScriptRoutine routine = new ScriptRoutine();
            routine.Name = "New Script Routine";
            mActiveScript.Add(routine);

            AddRoutine(newName, routine);
        }
コード例 #3
0
ファイル: TestNess.cs プロジェクト: dogmahtagram/Finale
        public static void SerializeAnimations()
        {
            Texture2D nessTexture = WorldEditor.Instance.Content.Load<Texture2D>("ness");

            Animation walkAnimation = new Animation();
            walkAnimation.Name = "walk";
            walkAnimation.Texture = nessTexture;
            walkAnimation.TextureName = "ness";
            for (int index = 0; index < 4; index++)
            {
                walkAnimation.ChangeFrameMotionDelta(index, 0, new Vector2(0, 30.0f));
                walkAnimation.SetFrameDuration(index, 5);
            }
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.N, new Rectangle(0, 0, 64, 64), 0);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.N, new Rectangle(0, 64, 64, 64), 1);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.N, new Rectangle(0, 128, 64, 64), 2);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.N, new Rectangle(0, 64, 64, 64), 3);

            walkAnimation.AddFrame(RotationComponent.CardinalDirections.NE, new Rectangle(64, 0, 64, 64), 0);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.NE, new Rectangle(64, 64, 64, 64), 1);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.NE, new Rectangle(64, 128, 64, 64), 2);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.NE, new Rectangle(64, 64, 64, 64), 3);

            walkAnimation.AddFrame(RotationComponent.CardinalDirections.E, new Rectangle(128, 64, 64, 64), 0);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.E, new Rectangle(128, 128, 64, 64), 1);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.E, new Rectangle(128, 64, 64, 64), 2);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.E, new Rectangle(128, 0, 64, 64), 3);

            walkAnimation.AddFrame(RotationComponent.CardinalDirections.SE, new Rectangle(192, 0, 64, 64), 0);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.SE, new Rectangle(192, 64, 64, 64), 1);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.SE, new Rectangle(192, 128, 64, 64), 2);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.SE, new Rectangle(192, 64, 64, 64), 3);

            walkAnimation.AddFrame(RotationComponent.CardinalDirections.S, new Rectangle(256, 0, 64, 64), 0);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.S, new Rectangle(256, 64, 64, 64), 1);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.S, new Rectangle(256, 128, 64, 64), 2);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.S, new Rectangle(256, 64, 64, 64), 3);

            walkAnimation.AddFrame(RotationComponent.CardinalDirections.SW, new Rectangle(320, 0, 64, 64), 0);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.SW, new Rectangle(320, 64, 64, 64), 1);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.SW, new Rectangle(320, 128, 64, 64), 2);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.SW, new Rectangle(320, 64, 64, 64), 3);

            walkAnimation.AddFrame(RotationComponent.CardinalDirections.W, new Rectangle(384, 0, 64, 64), 0);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.W, new Rectangle(384, 64, 64, 64), 1);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.W, new Rectangle(384, 128, 64, 64), 2);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.W, new Rectangle(384, 64, 64, 64), 3);

            walkAnimation.AddFrame(RotationComponent.CardinalDirections.NW, new Rectangle(448, 0, 64, 64), 0);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.NW, new Rectangle(448, 64, 64, 64), 1);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.NW, new Rectangle(448, 128, 64, 64), 2);
            walkAnimation.AddFrame(RotationComponent.CardinalDirections.NW, new Rectangle(448, 64, 64, 64), 3);

            Animation attackAnimation = new Animation();
            attackAnimation.Name = "attack";
            attackAnimation.Texture = nessTexture;
            attackAnimation.TextureName = "ness";
            for (int index = 0; index < 2; index++)
            {
                attackAnimation.ChangeFrameMotionDelta(index, 0, new Vector2(0, 10.0f));
                attackAnimation.SetFrameDuration(index, 4);
            }

            attackAnimation.AddFrame(RotationComponent.CardinalDirections.N, new Rectangle(0, 192, 64, 64), 0);
            attackAnimation.AddFrame(RotationComponent.CardinalDirections.N, new Rectangle(0, 256, 64, 64), 1);

            attackAnimation.AddFrame(RotationComponent.CardinalDirections.NE, new Rectangle(64, 192, 64, 64), 0);
            attackAnimation.AddFrame(RotationComponent.CardinalDirections.NE, new Rectangle(64, 256, 64, 64), 1);

            attackAnimation.AddFrame(RotationComponent.CardinalDirections.E, new Rectangle(128, 192, 64, 64), 0);
            attackAnimation.AddFrame(RotationComponent.CardinalDirections.E, new Rectangle(128, 256, 64, 64), 1);

            attackAnimation.AddFrame(RotationComponent.CardinalDirections.SE, new Rectangle(192, 192, 64, 64), 0);
            attackAnimation.AddFrame(RotationComponent.CardinalDirections.SE, new Rectangle(192, 256, 64, 64), 1);

            attackAnimation.AddFrame(RotationComponent.CardinalDirections.S, new Rectangle(256, 192, 64, 64), 0);
            attackAnimation.AddFrame(RotationComponent.CardinalDirections.S, new Rectangle(256, 256, 64, 64), 1);

            attackAnimation.AddFrame(RotationComponent.CardinalDirections.SW, new Rectangle(320, 192, 64, 64), 0);
            attackAnimation.AddFrame(RotationComponent.CardinalDirections.SW, new Rectangle(320, 256, 64, 64), 1);

            attackAnimation.AddFrame(RotationComponent.CardinalDirections.W, new Rectangle(384, 192, 64, 64), 0);
            attackAnimation.AddFrame(RotationComponent.CardinalDirections.W, new Rectangle(384, 256, 64, 64), 1);

            attackAnimation.AddFrame(RotationComponent.CardinalDirections.NW, new Rectangle(448, 192, 64, 64), 0);
            attackAnimation.AddFrame(RotationComponent.CardinalDirections.NW, new Rectangle(448, 256, 64, 64), 1);

            int idleX = 0;
            Rectangle[] idleFrames = new Rectangle[8];
            for (int index = 0; index < 8; index++)
            {
                idleFrames[index] = new Rectangle(idleX, 0, 64, 64);
                idleX += 64;
            }

            Animation idleAnimation = new Animation();
            idleAnimation.Name = "idle";
            idleAnimation.SetFrameDuration(0, 1);
            idleAnimation.Texture = nessTexture;
            idleAnimation.TextureName = "ness";

            idleAnimation.AddFrame(RotationComponent.CardinalDirections.N, idleFrames[0], 0);
            idleAnimation.AddFrame(RotationComponent.CardinalDirections.NE, idleFrames[1], 0);
            idleAnimation.AddFrame(RotationComponent.CardinalDirections.E, idleFrames[2], 0);
            idleAnimation.AddFrame(RotationComponent.CardinalDirections.SE, idleFrames[3], 0);
            idleAnimation.AddFrame(RotationComponent.CardinalDirections.S, idleFrames[4], 0);
            idleAnimation.AddFrame(RotationComponent.CardinalDirections.SW, idleFrames[5], 0);
            idleAnimation.AddFrame(RotationComponent.CardinalDirections.W, idleFrames[6], 0);
            idleAnimation.AddFrame(RotationComponent.CardinalDirections.NW, idleFrames[7], 0);

            InputScriptNode isLeftStickActiveNode = new InputScriptNode();
            isLeftStickActiveNode.ScriptType = InputScriptNode.InputScriptType.TYPE_LEFT_STICK_ACTIVE;

            PlayAnimationScriptNode playWalkAnimScriptNode = new PlayAnimationScriptNode();
            playWalkAnimScriptNode.AnimationToQueue = "walk";
            playWalkAnimScriptNode.FrameToQueue = 0;
            playWalkAnimScriptNode.PlayIfTrue = true;

            PlayAnimationScriptNode playIdleAnimScriptNode = new PlayAnimationScriptNode();
            playIdleAnimScriptNode.AnimationToQueue = "idle";
            playIdleAnimScriptNode.FrameToQueue = 0;
            playIdleAnimScriptNode.PlayIfTrue = false;

            ToggleMotionDeltaScriptNode toggleMotionDeltaNode = new ToggleMotionDeltaScriptNode();

            InputScriptNode attackButtonNode = new InputScriptNode();
            attackButtonNode.ScriptType = InputScriptNode.InputScriptType.TYPE_BUTTON_DOWN;
            object attackString = "attack";
            attackButtonNode.SetInputValue(attackString);

            PlayAnimationScriptNode playAttackScriptNode = new PlayAnimationScriptNode();
            playAttackScriptNode.PlayIfTrue = true;
            playAttackScriptNode.AnimationToQueue = "attack";

            PlayAnimationScriptNode backToIdleNode = new PlayAnimationScriptNode();
            backToIdleNode.AnimationToQueue = "idle";
            backToIdleNode.PlayIfTrue = false;

            isLeftStickActiveNode.Name = "Is left stick active";
            playWalkAnimScriptNode.Name = "Play walk animation";
            playIdleAnimScriptNode.Name = "Play idle animation";
            toggleMotionDeltaNode.Name = "Toggle motion delta";
            playAttackScriptNode.Name = "Play attack animation";
            attackButtonNode.Name = "If attack button hit";
            ScriptNodeManager.Instance.RegisterNode(isLeftStickActiveNode);
            ScriptNodeManager.Instance.RegisterNode(playWalkAnimScriptNode);
            ScriptNodeManager.Instance.RegisterNode(playIdleAnimScriptNode);
            ScriptNodeManager.Instance.RegisterNode(playAttackScriptNode);
            ScriptNodeManager.Instance.RegisterNode(toggleMotionDeltaNode);
            ScriptNodeManager.Instance.RegisterNode(attackButtonNode);

            ScriptRoutine inputToWalkScript = new ScriptRoutine();
            inputToWalkScript.Name = "Input to walk";
            inputToWalkScript.Add("Is left stick active");
            inputToWalkScript.Add("Play walk animation");
            idleAnimation.AddScriptRoutine(inputToWalkScript);

            ScriptRoutine noInputToIdleScript = new ScriptRoutine();
            noInputToIdleScript.Name = "No input to idle";
            noInputToIdleScript.Add("Is left stick active");
            noInputToIdleScript.Add("Play idle animation");
            walkAnimation.AddScriptRoutine(noInputToIdleScript);

            ScriptRoutine toggleMotionDeltaScript = new ScriptRoutine();
            toggleMotionDeltaScript.Name = "Toggle motion delta";
            toggleMotionDeltaScript.Add("Is left stick active");
            toggleMotionDeltaScript.Add("Toggle motion delta");
            walkAnimation.AddScriptRoutine(toggleMotionDeltaScript);
            attackAnimation.AddScriptRoutine(toggleMotionDeltaScript);

            ScriptRoutine playAttackScript = new ScriptRoutine();
            playAttackScript.Name = "Play attack";
            playAttackScript.Add("If attack button hit");
            playAttackScript.Add("Play attack animation");
            walkAnimation.AddScriptRoutine(playAttackScript);
            idleAnimation.AddScriptRoutine(playAttackScript);

            ScriptRoutine keepAttackingScript = new ScriptRoutine();
            keepAttackingScript.Name = "Keep attacking";
            keepAttackingScript.Add("If attack button hit");
            keepAttackingScript.Add("Play attack animation");
            attackAnimation.AddFrameRoutine(1, keepAttackingScript);

            ScriptRoutine backToIdleScript = new ScriptRoutine();
            backToIdleScript.Name = "Back to idle";
            backToIdleScript.Add("If attack button hit");
            backToIdleScript.Add("Play idle animation");
            attackAnimation.AddFrameRoutine(1, backToIdleScript);

            //crispy
            //List<string> attackTrigger = new List<string>();
            //TriggerNode newTrig = new TriggerNode(TrigType.HITBOX, new Object[] { new Rectangle(-20, -20, 20, 20), Vector2.Zero, 0f, AffectFlags.ALL});
            //newTrig.Name = "Hitbox";
            //ScriptNodeManager.Instance.RegisterNode((INode)attackTrigger);
            //attackTrigger.Add(newTrig.Name);
            //attackAnimation.AddFrameScript(1, attackTrigger);
            //crispy

            ScriptNodeManager.Instance.SerializeNodes("ness.nodes");

            string filePath = Application.StartupPath;
            filePath += "\\Content\\" + "ness" + ".fap";

            Stream stream = File.Create(filePath);
            BinaryFormatter formatter = new BinaryFormatter();
            BinaryWriter writer = new BinaryWriter(stream);

            int numAnimations = 3;
            writer.Write(numAnimations);
            formatter.Serialize(stream, idleAnimation);
            formatter.Serialize(stream, walkAnimation);
            formatter.Serialize(stream, attackAnimation);

            stream.Close();
        }
コード例 #4
0
        private void AddRoutine(string name, ScriptRoutine routine)
        {
            Button button = new Button();
            button.Text = name;
            button.Click += new EventHandler(RoutineButtonSelected);
            button.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right)));

            RoutineButton routineButton = new RoutineButton();
            routineButton.Button = button;
            routineButton.Routine = routine;

            mActiveRoutine = new KeyValuePair<int, RoutineButton>(mRoutines.Count, routineButton);
            SetActiveRoutine();

            mRoutines.Add(mRoutines.Count, routineButton);
            button.Width = mScriptRoutinesPanel.Width;
            mScriptRoutinesPanel.Controls.Add(button);

            OrderRoutines();
        }
コード例 #5
0
        public void SetActiveRoutine(ScriptRoutine routine)
        {
            this.BackColor = Color.LightBlue;

            mRoutineNodesPanel.Controls.Clear();
            mRoutineNodes.Clear();

            mActiveRoutine = routine;

            mRoutineNodes = new Dictionary<int, EditableNode>();
            for (int nodeIndex = 0; nodeIndex < routine.Count; nodeIndex++)
            {
                INode nodeCopy = ExtensionFunctions_cl.DeepCopy<INode>(ScriptNodeManager_cl.Instance.GetNode(routine[nodeIndex]));
                AddScriptNode(nodeCopy, routine[nodeIndex]);
            }

            foreach (EditableNode node in mRoutineNodes.Values)
            {
                SetActiveNode(node);
                break;
            }

            mRoutineName.Text = mActiveRoutine.Name;
        }
コード例 #6
0
ファイル: TestOldMan.cs プロジェクト: dogmahtagram/Finale
        public static void InitAnimations()
        {
            Texture2D oldManTexture = WorldEditor.Instance.Content.Load<Texture2D>("oldManSheet");

            Animation walkAnimation = new Animation();
            walkAnimation.Name = "oldManWalk";
            walkAnimation.Texture = oldManTexture;
            walkAnimation.TextureName = "oldManSheet";

            Animation attackAnimation = new Animation();
            attackAnimation.Name = "oldManAttack";
            attackAnimation.Texture = oldManTexture;
            attackAnimation.TextureName = "oldManSheet";

            Animation idleAnimation = new Animation();
            idleAnimation.Name = "oldManIdle";
            idleAnimation.Texture = oldManTexture;
            idleAnimation.TextureName = "oldManSheet";

            Animation takeCoverAnimation = new Animation();
            takeCoverAnimation.Name = "oldManTakeCover";
            takeCoverAnimation.Texture = oldManTexture;
            takeCoverAnimation.TextureName = "oldManSheet";

            int frameOffset = 0;
            for (int index = 0; index < 6; index++)
            {
                takeCoverAnimation.SetFrameDuration(index, 2);
                takeCoverAnimation.AddFrame(RotationComponent.CardinalDirections.NONE, new Rectangle(frameOffset, 640, 128, 128), index);

                walkAnimation.SetFrameDuration(index, 3);
                walkAnimation.AddFrame(RotationComponent.CardinalDirections.E, new Rectangle(frameOffset, 0, 128, 128), index);
                walkAnimation.AddFrame(RotationComponent.CardinalDirections.S, new Rectangle(frameOffset, 128, 128, 128), index);
                walkAnimation.AddFrame(RotationComponent.CardinalDirections.N, new Rectangle(frameOffset, 256, 128, 128), index);
                walkAnimation.AddFrame(RotationComponent.CardinalDirections.NE, new Rectangle(frameOffset, 384, 128, 128), index);
                walkAnimation.AddFrame(RotationComponent.CardinalDirections.SE, new Rectangle(frameOffset, 512, 128, 128), index);

                if (index < 2)
                {
                    attackAnimation.SetFrameDuration(index, 2);
                    attackAnimation.AddFrame(RotationComponent.CardinalDirections.N, new Rectangle(frameOffset, 768, 128, 128), index);
                    attackAnimation.AddFrame(RotationComponent.CardinalDirections.NE, new Rectangle(frameOffset + 384, 768, 128, 128), index);
                    attackAnimation.AddFrame(RotationComponent.CardinalDirections.E, new Rectangle(frameOffset, 896, 128, 128), index);
                    attackAnimation.AddFrame(RotationComponent.CardinalDirections.SE, new Rectangle(frameOffset + 384, 896, 128, 128), index);
                    attackAnimation.AddFrame(RotationComponent.CardinalDirections.S, new Rectangle(768, frameOffset, 128, 128), index);
                }

                if (index == 0)
                {
                    idleAnimation.SetFrameDuration(index, 10);
                    idleAnimation.AddFrame(RotationComponent.CardinalDirections.E, new Rectangle(frameOffset, 0, 128, 128), index);
                    idleAnimation.AddFrame(RotationComponent.CardinalDirections.S, new Rectangle(frameOffset, 128, 128, 128), index);
                    idleAnimation.AddFrame(RotationComponent.CardinalDirections.N, new Rectangle(frameOffset, 256, 128, 128), index);
                    idleAnimation.AddFrame(RotationComponent.CardinalDirections.NE, new Rectangle(frameOffset, 384, 128, 128), index);
                    idleAnimation.AddFrame(RotationComponent.CardinalDirections.SE, new Rectangle(frameOffset, 512, 128, 128), index);
                }

                frameOffset += 128;
            }

            walkAnimation.DirectionMap[RotationComponent.CardinalDirections.SW] = RotationComponent.CardinalDirections.SE;
            walkAnimation.DirectionMap[RotationComponent.CardinalDirections.W] = RotationComponent.CardinalDirections.E;
            walkAnimation.DirectionMap[RotationComponent.CardinalDirections.NW] = RotationComponent.CardinalDirections.NE;

            idleAnimation.DirectionMap[RotationComponent.CardinalDirections.SW] = RotationComponent.CardinalDirections.SE;
            idleAnimation.DirectionMap[RotationComponent.CardinalDirections.W] = RotationComponent.CardinalDirections.E;
            idleAnimation.DirectionMap[RotationComponent.CardinalDirections.NW] = RotationComponent.CardinalDirections.NE;

            attackAnimation.DirectionMap[RotationComponent.CardinalDirections.SW] = RotationComponent.CardinalDirections.SE;
            attackAnimation.DirectionMap[RotationComponent.CardinalDirections.W] = RotationComponent.CardinalDirections.E;
            attackAnimation.DirectionMap[RotationComponent.CardinalDirections.NW] = RotationComponent.CardinalDirections.NE;

            takeCoverAnimation.DirectionMap[RotationComponent.CardinalDirections.SW] = RotationComponent.CardinalDirections.SE;
            takeCoverAnimation.DirectionMap[RotationComponent.CardinalDirections.W] = RotationComponent.CardinalDirections.E;
            takeCoverAnimation.DirectionMap[RotationComponent.CardinalDirections.NW] = RotationComponent.CardinalDirections.NE;

            walkAnimation.ChangeFrameMotionDelta(0, 0, new Vector2(0, 0.0f));
            walkAnimation.ChangeFrameMotionDelta(1, 0, new Vector2(0, 0.0f));
            walkAnimation.ChangeFrameMotionDelta(2, 0, new Vector2(0, 0.0f));
            walkAnimation.ChangeFrameMotionDelta(3, 0, new Vector2(0, 5.5f));
            walkAnimation.ChangeFrameMotionDelta(4, 0, new Vector2(0, 10.5f));
            walkAnimation.ChangeFrameMotionDelta(5, 0, new Vector2(0, 8.0f));

            attackAnimation.ChangeFrameMotionDelta(0, 10, new Vector2(0, -50f));
            attackAnimation.ChangeFrameMotionDelta(1, 10, new Vector2(0, -50f));

            AnimatedManager.Instance.AddAnimation("oldManIdle", idleAnimation);
            AnimatedManager.Instance.AddAnimation("oldManWalk", walkAnimation);
            AnimatedManager.Instance.AddAnimation("oldManAttack", attackAnimation);
            AnimatedManager.Instance.AddAnimation("oldManTakeCover", takeCoverAnimation);

            InputScriptNode isLeftStickActiveNode = new InputScriptNode();
            isLeftStickActiveNode.ScriptType = InputScriptNode.InputScriptType.TYPE_LEFT_STICK_ACTIVE;

            PlayAnimationScriptNode playWalkAnimScriptNode = new PlayAnimationScriptNode();
            playWalkAnimScriptNode.AnimationToQueue = "oldManWalk";
            playWalkAnimScriptNode.FrameToQueue = 0;
            playWalkAnimScriptNode.PlayIfTrue = true;

            PlayAnimationScriptNode playIdleAnimScriptNode = new PlayAnimationScriptNode();
            playIdleAnimScriptNode.AnimationToQueue = "oldManIdle";
            playIdleAnimScriptNode.FrameToQueue = 0;
            playIdleAnimScriptNode.PlayIfTrue = false;

            PlayAnimationScriptNode playTakeCoverAnimScriptNode = new PlayAnimationScriptNode();
            playTakeCoverAnimScriptNode.AnimationToQueue = "oldManTakeCover";
            playTakeCoverAnimScriptNode.FrameToQueue = 1;
            playTakeCoverAnimScriptNode.PlayIfTrue = true;

            ToggleMotionDeltaScriptNode toggleMotionDeltaNode = new ToggleMotionDeltaScriptNode();

            InputScriptNode attackButtonNode = new InputScriptNode();
            attackButtonNode.ScriptType = InputScriptNode.InputScriptType.TYPE_BUTTON_DOWN;
            attackButtonNode.SetInputValue("attack");

            InputScriptNode secondaryButtonNode = new InputScriptNode();
            secondaryButtonNode.ScriptType = InputScriptNode.InputScriptType.TYPE_BUTTON_DOWN;
            secondaryButtonNode.SetInputValue("secondary");

            PlayAnimationScriptNode playAttackScriptNode = new PlayAnimationScriptNode();
            playAttackScriptNode.PlayIfTrue = true;
            playAttackScriptNode.AnimationToQueue = "oldManAttack";

            PlayAnimationScriptNode backToIdleNode = new PlayAnimationScriptNode();
            backToIdleNode.AnimationToQueue = "oldManIdle";
            backToIdleNode.PlayIfTrue = false;

            PlayAnimationScriptNode stopUnderCoverNode = new PlayAnimationScriptNode();
            stopUnderCoverNode.AnimationToQueue = "oldManTakeCover";
            stopUnderCoverNode.FrameToQueue = 5;
            stopUnderCoverNode.PlayIfTrue = true;

            PlayAnimationScriptNode getOutOfCoverNode = new PlayAnimationScriptNode();
            getOutOfCoverNode.AnimationToQueue = "oldManTakeCover";
            getOutOfCoverNode.FrameToQueue = 4;
            getOutOfCoverNode.SpeedToQueue = -1.0f;
            getOutOfCoverNode.PlayIfTrue = false;

            isLeftStickActiveNode.Name = "Is left stick active";
            playWalkAnimScriptNode.Name = "Play walk animation";
            playIdleAnimScriptNode.Name = "Play idle animation";
            playTakeCoverAnimScriptNode.Name = "Play take cover animation";
            toggleMotionDeltaNode.Name = "Toggle motion delta";
            playAttackScriptNode.Name = "Play attack animation";
            attackButtonNode.Name = "If attack button hit";
            secondaryButtonNode.Name = "If secondary button hit";
            stopUnderCoverNode.Name = "Stop under cover";
            getOutOfCoverNode.Name = "Get out of cover";

            ScriptNodeManager.Instance.RegisterNode(isLeftStickActiveNode);
            ScriptNodeManager.Instance.RegisterNode(playWalkAnimScriptNode);
            ScriptNodeManager.Instance.RegisterNode(playIdleAnimScriptNode);
            ScriptNodeManager.Instance.RegisterNode(playTakeCoverAnimScriptNode);
            ScriptNodeManager.Instance.RegisterNode(playAttackScriptNode);
            ScriptNodeManager.Instance.RegisterNode(toggleMotionDeltaNode);
            ScriptNodeManager.Instance.RegisterNode(attackButtonNode);
            ScriptNodeManager.Instance.RegisterNode(secondaryButtonNode);
            ScriptNodeManager.Instance.RegisterNode(stopUnderCoverNode);
            ScriptNodeManager.Instance.RegisterNode(getOutOfCoverNode);

            ScriptNodeManager.Instance.SerializeNodes("oldMan.nodes");

            ScriptRoutine inputToWalkScript = new ScriptRoutine();
            inputToWalkScript.Name = "Input to walk";
            inputToWalkScript.Add("Is left stick active");
            inputToWalkScript.Add("Play walk animation");
            idleAnimation.AddScriptRoutine(inputToWalkScript);

            ScriptRoutine noInputToIdleScript = new ScriptRoutine();
            noInputToIdleScript.Name = "No input to idle";
            noInputToIdleScript.Add("Is left stick active");
            noInputToIdleScript.Add("Play idle animation");
            walkAnimation.AddScriptRoutine(noInputToIdleScript);

            ScriptRoutine toggleMotionDeltaScript = new ScriptRoutine();
            toggleMotionDeltaScript.Name = "Toggle motion delta";
            toggleMotionDeltaScript.Add("Is left stick active");
            toggleMotionDeltaScript.Add("Toggle motion delta");
            walkAnimation.AddScriptRoutine(toggleMotionDeltaScript);
            attackAnimation.AddScriptRoutine(toggleMotionDeltaScript);

            ScriptRoutine playAttackScript = new ScriptRoutine();
            playAttackScript.Name = "Play attack";
            playAttackScript.Add("If attack button hit");
            playAttackScript.Add("Play attack animation");
            walkAnimation.AddScriptRoutine(playAttackScript);
            idleAnimation.AddScriptRoutine(playAttackScript);

            ScriptRoutine playSecondaryScript = new ScriptRoutine();
            playSecondaryScript.Name = "Play take cover";
            playSecondaryScript.Add("If secondary button hit");
            playSecondaryScript.Add("Play take cover animation");
            walkAnimation.AddScriptRoutine(playSecondaryScript);
            idleAnimation.AddScriptRoutine(playSecondaryScript);

            ScriptRoutine stopUnderCoverScript = new ScriptRoutine();
            stopUnderCoverScript.Name = "Stop while in cover";
            stopUnderCoverScript.Add("If secondary button hit");
            stopUnderCoverScript.Add("Stop under cover");
            takeCoverAnimation.AddFrameRoutine(5, stopUnderCoverScript);

            ScriptRoutine keepAttackingScript = new ScriptRoutine();
            keepAttackingScript.Name = "Keep attacking";
            keepAttackingScript.Add("If attack button hit");
            keepAttackingScript.Add("Play attack animation");
            attackAnimation.AddFrameRoutine(1, keepAttackingScript);

            ScriptRoutine backToIdleScript = new ScriptRoutine();
            backToIdleScript.Name = "Back to idle";
            backToIdleScript.Add("If attack button hit");
            backToIdleScript.Add("Play idle animation");
            attackAnimation.AddFrameRoutine(1, backToIdleScript);

            ScriptRoutine stopTakingCoverScript = new ScriptRoutine();
            stopTakingCoverScript.Name = "Get out of cover";
            stopTakingCoverScript.Add("If secondary button hit");
            stopTakingCoverScript.Add("Get out of cover");
            takeCoverAnimation.AddFrameRoutine(5, stopTakingCoverScript);

            ScriptRoutine getOutOfCoverScript = new ScriptRoutine();
            getOutOfCoverScript.Name = "Idle after cover";
            getOutOfCoverScript.Add("Play idle animation");
            takeCoverAnimation.AddFrameRoutine(0, getOutOfCoverScript);

            ScriptNodeManager.Instance.SerializeNodes("nodes.MILF");

            string filePath = Application.StartupPath;
            filePath += "\\Content\\" + "oldMan" + ".fap";

            Stream stream = File.Create(filePath);
            BinaryFormatter formatter = new BinaryFormatter();
            BinaryWriter writer = new BinaryWriter(stream);

            int numAnimations = 4;
            writer.Write(numAnimations);
            formatter.Serialize(stream, idleAnimation);
            formatter.Serialize(stream, walkAnimation);
            formatter.Serialize(stream, attackAnimation);
            formatter.Serialize(stream, takeCoverAnimation);

            stream.Close();
        }
コード例 #7
0
ファイル: Animation.cs プロジェクト: dogmahtagram/Finale
 /// <summary>
 /// 
 /// </summary>
 /// <param name="script"></param>
 public void AddScriptRoutine(ScriptRoutine script)
 {
     mWholeAnimationScript.Add(script);
 }
コード例 #8
0
ファイル: Animation.cs プロジェクト: dogmahtagram/Finale
 /// <summary>
 /// 
 /// </summary>
 /// <param name="frame"></param>
 /// <param name="script"></param>
 public void AddFrameRoutine(int frame, ScriptRoutine script)
 {
     if (mFrameScripts.ContainsKey(frame))
     {
         mFrameScripts[frame].Add(script);
     }
     else
     {
         mFrameScripts.Add(frame, new Script());
         mFrameScripts[frame].Add(script);
     }
 }