public byte[] MoveDown(AnimationCommand command, ref int topOffset)
        {
            if (selectedNode.NextNode == null)
            {
                return(null);
            }
            if (command.Opcode == 0x07 ||
                command.Opcode == 0x11 ||
                command.Opcode == 0x5E)
            {
                return(null);
            }
            AnimationCommand nextCommand = (AnimationCommand)selectedNode.NextNode.Tag;

            if (nextCommand.Opcode == 0x07 ||
                nextCommand.Opcode == 0x11 ||
                nextCommand.Opcode == 0x5E)
            {
                return(null);
            }
            if (selectedNode.Parent != null)
            {
                if (selectedNode.Index >= selectedNode.Parent.Nodes.Count - 1)
                {
                    return(null);
                }
            }
            else if (selectedNode.Index >= treeView.Nodes.Count - 1)
            {
                return(null);
            }
            return(Reverse(command, nextCommand, ref topOffset, 0));
        }
        public byte[] MoveUp(AnimationCommand command, ref int topOffset)
        {
            if (selectedNode.PrevNode == null)
            {
                return(null);
            }
            if (command.Opcode == 0x07 ||
                command.Opcode == 0x11 ||
                command.Opcode == 0x5E)
            {
                return(null);
            }
            AnimationCommand prevCommand = (AnimationCommand)selectedNode.PrevNode.Tag;

            if (prevCommand.Opcode == 0x07 ||
                prevCommand.Opcode == 0x11 ||
                prevCommand.Opcode == 0x5E)
            {
                return(null);
            }
            if (selectedNode.Index == 0)
            {
                return(null);
            }
            return(Reverse(prevCommand, command, ref topOffset, 1));
        }
        private byte[] Reverse(AnimationCommand commandA, AnimationCommand commandB, ref int topOffset, int selectedIndex)
        {
            byte[] byteA = Bits.Copy(commandB.CommandData);
            byte[] byteB = Bits.Copy(commandA.CommandData);
            commandA.CommandData = byteA;
            commandB.CommandData = byteB;
            //
            int offset = commandA.InternalOffset;

            topOffset = commandA.InternalOffset;
            byte[] changes = new byte[commandA.Length + commandB.Length];
            for (int i = 0; i < byteA.Length; i++, offset++)
            {
                changes[i] = commandA.CommandData[i];
            }
            int temp = commandB.InternalOffset;

            commandB.InternalOffset = commandA.InternalOffset;
            commandA.InternalOffset = offset;
            int index = byteA.Length;

            for (int i = 0; i < byteB.Length; i++, offset++)
            {
                changes[index++] = commandB.CommandData[i];
            }
            commandA.Offset = commandA.OriginalOffset = commandA.InternalOffset;
            commandB.Offset = commandB.OriginalOffset = commandB.InternalOffset;
            // check multiple instances of command in current script, and change each accordingly
            return(changes);
        }
        /// <summary>
        /// Selects a node in the treeView with a specified internalOffset.
        /// </summary>
        /// <param name="internalOffset">The internal offset of the node's command.</param>
        /// <param name="index">The full parent index of the node.</param>
        public void SelectNode(int internalOffset, int fullParentIndex)
        {
            selectedNode = null;
            int parentIndex = -1; // root has no parent
            int index       = 0;  // the current full index

            foreach (TreeNode node in this.treeView.Nodes)
            {
                AnimationCommand asc = (AnimationCommand)node.Tag;
                if (internalOffset == asc.InternalOffset && parentIndex == fullParentIndex)
                {
                    selectedNode = node;
                    break;
                }
                else
                {
                    SelectChildNode(node, internalOffset, fullParentIndex, ref index);
                }
                if (selectedNode != null)
                {
                    break;
                }
            }
            this.treeView.SelectedNode = selectedNode;
        }
        // treeview managers
        private void AddCommand(AnimationCommand command)
        {
            // Add node
            this.treeView.Nodes.Add("[" + (command.Offset).ToString("X6") + "]   " + command.ToString());
            TreeNode node = treeView.Nodes[treeView.Nodes.Count - 1];

            node.Tag = command;
            //
            switch (command.Opcode)
            {
            case 0x07:
            case 0x11:
            case 0x5E:
                node.BackColor = Color.FromArgb(255, 255, 255, 160);
                break;

            case 0x09:
            case 0x10:
            case 0x5D:
            case 0x64:
            case 0x68:
                node.BackColor = Color.FromArgb(255, 192, 224, 255);
                AddNode(command, node);
                break;

            default:
                if (command.Opcode >= 0x24 && command.Opcode <= 0x2B)
                {
                    node.BackColor = Color.FromArgb(255, 192, 224, 255);
                    AddNode(command, node);
                }
                break;
            }
        }
示例#6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="asc">The command being modified.</param>
 /// <param name="offset">The offset of the data.</param>
 /// <param name="internalOffset">The internal offset of the command.</param>
 /// <param name="data">The ROM data.</param>
 public AnimationEdit(AnimationScripts form, AnimationCommand asc, int offset, byte[] data)
 {
     this.form   = form;
     this.asc    = asc;
     this.offset = offset;
     this.data   = data;
     Execute(true);
 }
示例#7
0
        internal void Animation(string animName)
        {
            AnimationCommand cmd = CommandManager.Instance.CreateCommand("animation") as AnimationCommand;

            cmd.Load(animName);

            cmd.Execute(m_Instance, m_DeltaTime);
        }
示例#8
0
 void Start()
 {
     rb            = this.GetComponent <Rigidbody>();
     animator      = GetComponentInChildren <Animator>();
     idelAnimation = new IdleAnimation();
     deadAnimation = new DeadAnimation();
     walkAnimation = new IdleAnimation();
     walkAnimation.Animate(animator, true);
 }
示例#9
0
 public void Execute(bool push)
 {
     for (int i = 0; i < data.Length; i++)
     {
         byte temp = Model.ROM[offset + i];
         Model.ROM[offset + i] = data[i];
         data[i] = temp;
     }
     if (!push)
     {
         AnimationCommand temp = this.asc;
         this.asc      = this.form.ASC;
         this.form.ASC = temp;
     }
 }
 IEnumerator showGraphicCoroutine(EffectGraphic graphic, AnimationCommand cmd)
 {
     timePassed = 0;
     showGraphic(graphic);
     while (timePassed < DISPLAY_TIME)
     {
         newX = remainingTimeDefaultWidth - remainingTimeDefaultWidth * timePassed / DISPLAY_TIME;
         cachedV2.Set(newX, remainingTimeGraphic.size.y);
         remainingTimeGraphic.size = cachedV2;
         timePassed += Time.deltaTime * timePassedCoeff;
         yield return(null);
     }
     cvGameObject.SetActive(false);
     cmd.finished = true;
 }
示例#11
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            int indexLamp   = lbLamps.SelectedIndex;
            int indexAction = lbActions.SelectedIndex;

            if (indexLamp > -1 && indexAction > -1)
            {
                Lamp   l = (Lamp)lbLamps.Items[indexLamp];
                Object o = lbActions.Items[indexAction];

                if (o is Power)
                {
                    PowerCommand pc = new PowerCommand(l, Convert.ToBoolean(o));
                    cal.AddAnimation(pc);
                }
                else if (o is Color)
                {
                    AnimationCommand ac = new AnimationCommand(l, (Color)o);
                    cal.AddAnimation(ac);
                }
            }
        }
        private void SelectChildNode(TreeNode parent, int internalOffset, int fullParentIndex, ref int index)
        {
            int parentIndex = parent.Nodes.Count > 0 ? index++ : index;

            foreach (TreeNode child in parent.Nodes)
            {
                AnimationCommand asc = (AnimationCommand)child.Tag;
                if (internalOffset == asc.InternalOffset && parentIndex == fullParentIndex)
                {
                    selectedNode = child;
                    break;
                }
                else
                {
                    SelectChildNode(child, internalOffset, fullParentIndex, ref index);
                }
                if (selectedNode != null)
                {
                    break;
                }
            }
        }
        private void AddNode(AnimationCommand command, TreeNode node)
        {
            TreeNode childNode;

            foreach (AnimationCommand childCommand in command.Commands)
            {
                node.Nodes.Add("[" + (childCommand.Offset).ToString("X6") + "]   " + childCommand.ToString());
                childNode     = node.Nodes[node.Nodes.Count - 1];
                childNode.Tag = childCommand;
                //
                switch (childCommand.Opcode)
                {
                case 0x07:
                case 0x11:
                case 0x5E:
                    childNode.BackColor = Color.FromArgb(255, 255, 255, 160);
                    break;

                case 0x09:
                case 0x10:
                case 0x5D:
                case 0x64:
                case 0x68:
                    childNode.BackColor = Color.FromArgb(255, 192, 224, 255);
                    AddNode(childCommand, childNode);
                    break;

                default:
                    if (childCommand.Opcode >= 0x24 && childCommand.Opcode <= 0x2B)
                    {
                        childNode.BackColor = Color.FromArgb(255, 192, 224, 255);
                        AddNode(childCommand, childNode);
                    }
                    break;
                }
            }
        }
示例#14
0
        /// <summary>
        /// Update the actual animation (should be after all requests).
        /// </summary>
        public void update()
        {
            switch (m_requestedCommand)
            {
                case AnimationCommand.Play:
                    play();
                    break;
                case AnimationCommand.Idle:
                    idle();
                    break;
                default:
                    throw new Exception("Shouldn't reach here");
            }

            m_requestedCommand = AnimationCommand.Idle;
        }
示例#15
0
        /// <summary>
        /// Callers use this to suggest an animation to play. Priority checks
        /// are made to determine whether to accept the suggestion or keep
        /// playing the old animation.
        /// </summary>
        /// <param name="animName">Name of animation to play.</param>
        /// <param name="comm">What to do with that animation.</param>
        public void requestAnimation(string animName, AnimationCommand command)
        {
            int requestedAnimIdx = findAnimationIdx(animName);
            Animation requestedAnim = m_animSet.anims[requestedAnimIdx];

            if (requestedAnim == CurrentAnimation)
            {
                m_requestedCommand = command;
                return;
            }

            if (CurrentAnimation.priority == 0 ||
                requestedAnim.priority > CurrentAnimation.priority ||
                m_isIdle)
            {
                m_currentAnimIdx = requestedAnimIdx;
                m_currentSpriteIdx = 0;
                m_requestedCommand = command;
                return;
            }
        }
示例#16
0
        // functions
        private void ParseScript(byte[] rom)
        {
            int offset = baseOffset, length = 0;
            AnimationCommand temp;

            if (type == 8)
            {
                offset = baseOffset + 2;
                if (index == 22)
                {
                    offset = baseOffset + 4;
                }
                if (index == 70)
                {
                    offset = baseOffset + 6;
                }
                if (index == 85)
                {
                    offset = baseOffset + 6;
                }
            }
            if (this.commands == null)
            {
                this.commands = new List <AnimationCommand>();
            }
            while (offset < rom.Length)
            {
                if (offset == 0x3A6BA1)   // another annoying rare case
                {
                    break;
                }
                //
                length = GetOpcodeLength(rom, offset);
                temp   = new AnimationCommand(Bits.GetBytes(rom, offset, length), offset, this, null);
                // memory modifiying commands
                switch (temp.Opcode)
                {
                case 0x20:
                case 0x21: if ((temp.Param1 & 0x0F) == 0)
                    {
                        amem = temp.CommandData[2];
                    }
                    break;

                case 0x2C:
                case 0x2D: if ((temp.Param1 & 0x0F) == 0)
                    {
                        amem += temp.CommandData[2];
                    }
                    break;

                case 0x2E:
                case 0x2F: if ((temp.Param1 & 0x0F) == 0)
                    {
                        amem -= temp.CommandData[2];
                    }
                    break;

                case 0x30:
                case 0x31: if ((temp.Param1 & 0x0F) == 0)
                    {
                        amem++;
                    }
                    break;

                case 0x32:
                case 0x33: if ((temp.Param1 & 0x0F) == 0)
                    {
                        amem--;
                    }
                    break;

                case 0x34:
                case 0x35: if ((temp.Param1 & 0x0F) == 0)
                    {
                        amem = 0;
                    }
                    break;

                case 0x6A:
                case 0x6B: if ((temp.Param1 & 0x0F) == 0)
                    {
                        amem = (byte)(temp.CommandData[2] - 1);
                    }
                    break;
                }
                commands.Add(temp);
                // termination commands
                if (rom[offset] == 0x07 || // end animation packet
                    rom[offset] == 0x09 || // jump directly to address (thus ending this)
                    rom[offset] == 0x11 || // end subroutine
                    rom[offset] == 0x5E)   // end sprite subroutine
                {
                    break;
                }
                //
                offset += length;
            }
        }
示例#17
0
 public void Add(AnimationCommand command)
 {
     commands.Add(command);
 }