public ActionConfiguration(ActionTemplate Template = null)
 {
     if (Template != null)
     {
         this.Set_From_Template(Template);
     }
 }
 public void Set_From_Template(ActionTemplate Template)
 {
     this.TemplateToken = Template.TemplateToken;
     foreach (string s in Template.Get_Parameters())
     {
         this.Parameters.Add(s, string.Empty);
     }
 }
 public void ExecuteAction(ActionTemplate template, TeamScript team)
 {
     if (!Character.IsDead &&
         !template.Targeting.GetTarget(this, team).Character.IsDead&&
         _actionBeingExecuted == null)
     {
         template.ExecuteAction(this, team);
     }
 }
Esempio n. 4
0
    public void Add(CharState state, System.Action Enter, System.Action Run, System.Action Exit)
    {
        if (!actionDic.ContainsKey(state))
        {
            ActionTemplate template = new ActionTemplate();
            template.Add(ActionState.Enter, Enter);
            template.Add(ActionState.Run, Run);
            template.Add(ActionState.Exit, Exit);

            actionDic.Add(state, template);
        }
    }
		private async Task<bool> BeUniqueByName(ApiActionTemplateRequestModel model,  CancellationToken cancellationToken)
		{
			ActionTemplate record = await this.actionTemplateRepository.ByName(model.Name);

			if (record == null || (this.existingRecordId != default(string) && record.Id == this.existingRecordId))
			{
				return true;
			}
			else
			{
				return false;
			}
		}
        public async Task <ApiActionTemplateResponseModel> ByName(string name)
        {
            ActionTemplate record = await this.actionTemplateRepository.ByName(name);

            if (record == null)
            {
                return(null);
            }
            else
            {
                return(this.bolActionTemplateMapper.MapBOToModel(this.dalActionTemplateMapper.MapEFToBO(record)));
            }
        }
        public virtual ActionTemplate MapBOToEF(
            BOActionTemplate bo)
        {
            ActionTemplate efActionTemplate = new ActionTemplate();

            efActionTemplate.SetProperties(
                bo.ActionType,
                bo.CommunityActionTemplateId,
                bo.Id,
                bo.JSON,
                bo.Name,
                bo.Version);
            return(efActionTemplate);
        }
        public virtual BOActionTemplate MapEFToBO(
            ActionTemplate ef)
        {
            var bo = new BOActionTemplate();

            bo.SetProperties(
                ef.Id,
                ef.ActionType,
                ef.CommunityActionTemplateId,
                ef.JSON,
                ef.Name,
                ef.Version);
            return(bo);
        }
Esempio n. 9
0
        public void MapEFToBOList()
        {
            var            mapper = new DALActionTemplateMapper();
            ActionTemplate entity = new ActionTemplate();

            entity.SetProperties("A", "A", "A", "A", "A", 1);

            List <BOActionTemplate> response = mapper.MapEFToBO(new List <ActionTemplate>()
            {
                entity
            });

            response.Count.Should().Be(1);
        }
Esempio n. 10
0
        public void MapBOToEF()
        {
            var mapper = new DALActionTemplateMapper();
            var bo     = new BOActionTemplate();

            bo.SetProperties("A", "A", "A", "A", "A", 1);

            ActionTemplate response = mapper.MapBOToEF(bo);

            response.ActionType.Should().Be("A");
            response.CommunityActionTemplateId.Should().Be("A");
            response.Id.Should().Be("A");
            response.JSON.Should().Be("A");
            response.Name.Should().Be("A");
            response.Version.Should().Be(1);
        }
Esempio n. 11
0
        public void MapEFToBO()
        {
            var            mapper = new DALActionTemplateMapper();
            ActionTemplate entity = new ActionTemplate();

            entity.SetProperties("A", "A", "A", "A", "A", 1);

            BOActionTemplate response = mapper.MapEFToBO(entity);

            response.ActionType.Should().Be("A");
            response.CommunityActionTemplateId.Should().Be("A");
            response.Id.Should().Be("A");
            response.JSON.Should().Be("A");
            response.Name.Should().Be("A");
            response.Version.Should().Be(1);
        }
        public async void Get()
        {
            var mock   = new ServiceMockFacade <IActionTemplateRepository>();
            var record = new ActionTemplate();

            mock.RepositoryMock.Setup(x => x.Get(It.IsAny <string>())).Returns(Task.FromResult(record));
            var service = new ActionTemplateService(mock.LoggerMock.Object,
                                                    mock.RepositoryMock.Object,
                                                    mock.ModelValidatorMockFactory.ActionTemplateModelValidatorMock.Object,
                                                    mock.BOLMapperMockFactory.BOLActionTemplateMapperMock,
                                                    mock.DALMapperMockFactory.DALActionTemplateMapperMock);

            ApiActionTemplateResponseModel response = await service.Get(default(string));

            response.Should().NotBeNull();
            mock.RepositoryMock.Verify(x => x.Get(It.IsAny <string>()));
        }
Esempio n. 13
0
 internal void addAction(ActionTemplate actionTemplate)
 {
     if (actionTemplate.subActionList.Count >= 1)
     { // 找到最子的动作
         foreach (ActionTemplate xxx in actionTemplate.subActionList)
         {
             addAction(xxx);
         }
     }
     else
     { // 最子的动作
         ActionBoxIndex index = new ActionBoxIndex(actionTemplate.__passed, actionTemplate.__spanStart + curHeight, actionTemplate.__duration);
         if (!actionBoxs.ContainsKey(index))
         {
             ActionsBox xxx = new ActionsBox(index);
             actionBoxs[index] = xxx;
         }
         actionBoxs[index].actions.Add(actionTemplate);
     }
 }
Esempio n. 14
0
        private GetActionTemplatesResponse parseGetActionTemplatesResponse(ServiceResponse Response)
        {
            GetActionTemplatesResponse response = Response.Factory <GetActionTemplatesResponse>();

            if (Response.IsSuccess)
            {
                try
                {
                    XElement       templates = response.SOAPContent.Element(NS_SOAP_ENV + "Body").Element(NS_ACTION + "GetActionTemplatesResponse").Element(NS_ACTION + "ActionTemplates");
                    ActionTemplate newTemplate;

                    foreach (XElement el in templates.Elements())
                    {
                        newTemplate = new ActionTemplate();

                        newTemplate.TemplateToken = el.Element(NS_ACTION + "TemplateToken").Value;

                        if (el.Element(NS_ACTION + "RecipientTemplate") != null)
                        {
                            newTemplate.RecipientTemplate = el.Element(NS_ACTION + "RecipientTemplate").Value;
                        }

                        foreach (XElement param in el.Element(NS_ACTION + "Parameters").Elements())
                        {
                            newTemplate.Parameters.Add(param.Attribute("Name").Value, string.Empty);
                        }

                        response.Templates.Add(newTemplate.TemplateToken, newTemplate);
                    }
                }
                catch (Exception ex)
                {
                    response.IsSuccess = false;
                    response.Content   = "[ParseActionTemplatesResponse] " + ex.Message;
                }
            }

            return(response);
        }
Esempio n. 15
0
        private void NewAction(object sender, EventArgs e)
        {
            HideAllDynamicMenus();
            HideAllContextMenus();

            TreeNode t = tv.Nodes.Add("New Action");

            t.Name = Ids.Get().ToString();
            Console.Out.WriteLine(t.Name);
            t.Nodes.Add("Requirements").ForeColor = Color.Blue;
            t.Nodes.Add("Effects").ForeColor      = Color.Blue;

            ActionTemplate        AT  = new ActionTemplate();
            ActionTemplateWrapper ATW = new ActionTemplateWrapper();

            ATW.ActionTemplate = AT;

            AT.Name        = "New Action";
            AT.Description = "Type here!";
            Data.Add(t.Name, ATW);
            tv.SelectedNode = t;
            workingDataNode = t;
            ShowAO(ATW);
        }
Esempio n. 16
0
        //// true / false : res
        //private String isFileInResDir(String strFile)
        //{
        //    foreach (String strResDir in resPath) {
        //        //File f;
        //    }
        //}

        //private String selectPngFileInResDir()
        //{
        //    if (DialogResult.OK == openPngFileDialog.ShowDialog(this))
        //    {
        //        String file = openPngFileDialog.FileName;

        //    }
        //}

        private void contextmenu_Click(object sender, EventArgs e)
        {
            if (curTreeNodeBindedObject == null)
            {
                return;
            }
            MenuItem item = sender as MenuItem;

            if (item == null)
            {
                return;
            }

            bool __isOpDirty = true;

            if (curTreeNodeBindedObject is AEData)
            { // AEData
                AEData aeData = (AEData)curTreeNodeBindedObject;
                if (item.Text == "新建精灵")
                {
                    AESprite aeSprite = aeData.createSprite();
                    aeData.addSprite(aeSprite);
                    treeView1.SelectedNode = aeSprite.getTreeNode();
                }
            }
            else if (curTreeNodeBindedObject is AEConfig)
            { // AEConfig
                if (item.Text == "修改配置")
                {
                    curEditAEData.createConfigPropForm(this).ShowDialog(this);
                    __isOpDirty = false; // 内部设置了Dirty
                }
            }
            else if (curTreeNodeBindedObject is AESprite)
            { // AESprite
                AESprite aeSprite = (AESprite)curTreeNodeBindedObject;
                if (item.Text == "新建精灵(上方)")
                {
                    AESprite newAESprite = curEditAEData.createSprite();
                    this.curEditAEData.addSprite(newAESprite, aeSprite, true);
                    treeView1.SelectedNode = newAESprite.getTreeNode();
                }
                else if (item.Text == "新建精灵(下方)")
                {
                    AESprite newAESprite = curEditAEData.createSprite();
                    this.curEditAEData.addSprite(newAESprite, aeSprite, false);
                    treeView1.SelectedNode = newAESprite.getTreeNode();
                }
                else if (item.Text == "上移精灵")
                {
                    this.curEditAEData.moveSprite(aeSprite, true);
                    treeView1.SelectedNode = aeSprite.getTreeNode();
                }
                else if (item.Text == "下移精灵")
                {
                    this.curEditAEData.moveSprite(aeSprite, false);
                    treeView1.SelectedNode = aeSprite.getTreeNode();
                }
                else if (item.Text == "删除精灵")
                {
                    this.curEditAEData.removeSprite(aeSprite);
                }
                else if (item.Text == "修改精灵")
                {
                    this.curEditAEData.createSpritePropForm(aeSprite, this).ShowDialog(this);
                    __isOpDirty = false;  // dirty setted in PropForm setBack
                }
                else if (item.Text == "复制精灵")
                {
                    curToCopyed = aeSprite;
                    __isOpDirty = false;
                }
                else if (item.Text == "粘贴精灵(上方)")
                {
                    AESprite newSprite = curEditAEData.copySprite((AESprite)curToCopyed, table);
                    this.curEditAEData.addSprite(newSprite, aeSprite, true);
                    newSprite.recalcAndUpdate();
                    treeView1.SelectedNode = newSprite.getTreeNode();
                }
                else if (item.Text == "粘贴精灵(下方)")
                {
                    AESprite newSprite = curEditAEData.copySprite((AESprite)curToCopyed, table);
                    this.curEditAEData.addSprite(newSprite, aeSprite, false);
                    newSprite.recalcAndUpdate();
                    treeView1.SelectedNode = newSprite.getTreeNode();
                }
                else if (item.Text == "新建动作")
                {
                    alfForm.setItems(table.getActionsByIgnoreList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1, ActionTemplateTable.EActionFilterType.ACTION_LIST_2));

                    if (alfForm.ShowDialog(this) == DialogResult.OK)
                    {
                        String selected = alfForm.getSelected();
                        if (selected != null)
                        {
                            ActionTemplate action = table.createActionByNote(selected);
                            aeSprite.addAction(action);
                            treeView1.SelectedNode = action.getTreeNode();
                        }
                    }
                }
                else if (item.Text == "粘贴动作")
                {
                    if (curToCopyed is ActionTemplate)
                    {
                        aeSprite.addAction(((ActionTemplate)curToCopyed).copy(table));
                    }
                }
            }
            else if (curTreeNodeBindedObject is ActionTemplate)
            { // ActionTemplate
                ActionTemplate actionTemplate     = (ActionTemplate)curTreeNodeBindedObject;
                Object         parentBindedObject = curEditAEData.getNodeBindedObject(actionTemplate.getTreeNode().Parent);
                if (item.Text == "修改动作")
                {
                    new ActionPropForm(actionTemplate, this).ShowDialog(this);
                    __isOpDirty = false; // 内部设置了Dirty
                }
                if (item.Text == "复制动作")
                {
                    curToCopyed = actionTemplate.copy(table);
                    __isOpDirty = false;
                }
                else if (item.Text == "添加子动作")
                {
                    if (actionTemplate.actionList == 0)
                    {
                        return;
                    }
                    if (actionTemplate.actionList == 1 && actionTemplate.subActionList.Count >= 1)
                    {
                        return;
                    }

                    if (!actionTemplate.isContainGridSubAction())
                    {
                        alfForm.setItems(table.getActionsByIgnoreList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1,
                                                                      ActionTemplateTable.EActionFilterType.ACTION_LIST_2));
                    }
                    else
                    {
                        alfForm.setItems(table.getActionsByIgnoreList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1,
                                                                      ActionTemplateTable.EActionFilterType.ACTION_LIST_2,
                                                                      ActionTemplateTable.EActionFilterType.GRID));
                    }
                    if (alfForm.ShowDialog(this) == DialogResult.OK)
                    {
                        String selected = alfForm.getSelected();
                        if (selected != null)
                        {
                            ActionTemplate newAction = table.createActionByNote(selected);
                            actionTemplate.addSubAction(newAction);
                            treeView1.SelectedNode = newAction.getTreeNode();
                        }
                    }
                }
                else if (item.Text == "粘贴子动作")
                {
                    if (actionTemplate.actionList == 0)
                    {
                        return;
                    }
                    if (actionTemplate.actionList == 1 && actionTemplate.subActionList.Count >= 1)
                    {
                        return;
                    }
                    if (curToCopyed is ActionTemplate)
                    {
                        ActionTemplate newAction = ((ActionTemplate)curToCopyed).copy(table);
                        actionTemplate.addSubAction(newAction);
                        treeView1.SelectedNode = newAction.getTreeNode();
                    }
                }

                if (parentBindedObject is AESprite)
                {
                    AESprite parent = (AESprite)parentBindedObject;
                    if (item.Text == "覆盖动作 -- 使用复制")
                    {
                        if (curToCopyed is ActionTemplate)
                        {
                            ActionTemplate newAction = ((ActionTemplate)curToCopyed).copy(table);
                            parent.addAction(newAction, actionTemplate, true);
                            treeView1.SelectedNode = newAction.getTreeNode();
                            parent.removeAction(actionTemplate);
                        }
                    }
                    else if (item.Text == "删除动作")
                    {
                        if (actionTemplate.subActionList.Count == 1)
                        {
                            ActionTemplate actionToAddBack = actionTemplate.subActionList[0];
                            actionTemplate.removeSubAction(actionToAddBack, false);
                            parent.replaceAction(actionTemplate, actionToAddBack);

                            treeView1.SelectedNode = actionToAddBack.getTreeNode();
                        }
                        else
                        {
                            parent.removeAction(actionTemplate);
                        }
                    }
                    else if (item.Text == "上移动作")
                    {
                        parent.moveAction(actionTemplate, true);
                    }
                    else if (item.Text == "下移动作")
                    {
                        parent.moveAction(actionTemplate, false);
                    }
                    else if (item.Text == "添加父动作")
                    {
                        if (actionTemplate.eActionType == EActionType.CCActionInstant)
                        {
                            alfForm.setItems(table.getActionsByPerferList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.SPAWN_AND_SEQUENCE));
                        }
                        else
                        {
                            alfForm.setItems(table.getActionsByPerferList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1,
                                                                          ActionTemplateTable.EActionFilterType.ACTION_LIST_2));
                        }

                        if (alfForm.ShowDialog(this) == DialogResult.OK)
                        {
                            String selected = alfForm.getSelected();
                            if (selected != null)
                            {
                                ActionTemplate newAction = table.createActionByNote(selected);
                                parent.replaceAction(actionTemplate, newAction);
                                newAction.addSubAction(actionTemplate);
                                treeView1.SelectedNode = actionTemplate.getTreeNode();
                                newAction.getTreeNode().ExpandAll();
                            }
                        }
                    }
                }
                else if (parentBindedObject is ActionTemplate)
                {
                    ActionTemplate parent = (ActionTemplate)parentBindedObject;
                    if (item.Text == "覆盖动作 -- 使用复制")
                    {
                        if (curToCopyed is ActionTemplate)
                        {
                            ActionTemplate newAction = ((ActionTemplate)curToCopyed).copy(table);
                            parent.addSubAction(newAction, actionTemplate, true);
                            treeView1.SelectedNode = newAction.getTreeNode();
                            parent.removeSubAction(actionTemplate);
                        }
                    }
                    else if (item.Text == "删除动作")
                    {
                        if (actionTemplate.subActionList.Count == 1)
                        {
                            ActionTemplate actionToAddBack = actionTemplate.subActionList[0];
                            actionTemplate.removeSubAction(actionToAddBack, false);
                            parent.replaceAction(actionTemplate, actionToAddBack);

                            treeView1.SelectedNode = actionToAddBack.getTreeNode();
                        }
                        else
                        {
                            parent.removeSubAction(actionTemplate);
                        }
                    }
                    else if (item.Text == "新建动作(上方)")
                    {
                        if (parent.actionList <= 1)
                        {
                            return;
                        }
                        if (!parent.isContainGridSubAction())
                        {
                            alfForm.setItems(table.getActionsByIgnoreList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1,
                                                                          ActionTemplateTable.EActionFilterType.ACTION_LIST_2));
                        }
                        else
                        {
                            alfForm.setItems(table.getActionsByIgnoreList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1,
                                                                          ActionTemplateTable.EActionFilterType.ACTION_LIST_2,
                                                                          ActionTemplateTable.EActionFilterType.GRID));
                        }
                        if (alfForm.ShowDialog(this) == DialogResult.OK)
                        {
                            String selected = alfForm.getSelected();
                            if (selected != null)
                            {
                                ActionTemplate newAction = table.createActionByNote(selected);
                                parent.addSubAction(newAction, actionTemplate, true);
                                treeView1.SelectedNode = newAction.getTreeNode();
                            }
                        }
                    }
                    else if (item.Text == "新建动作(下方)")
                    {
                        if (parent.actionList <= 1)
                        {
                            return;
                        }
                        if (!parent.isContainGridSubAction())
                        {
                            alfForm.setItems(table.getActionsByIgnoreList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1,
                                                                          ActionTemplateTable.EActionFilterType.ACTION_LIST_2));
                        }
                        else
                        {
                            alfForm.setItems(table.getActionsByIgnoreList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1,
                                                                          ActionTemplateTable.EActionFilterType.ACTION_LIST_2,
                                                                          ActionTemplateTable.EActionFilterType.GRID));
                        }
                        if (alfForm.ShowDialog(this) == DialogResult.OK)
                        {
                            String selected = alfForm.getSelected();
                            if (selected != null)
                            {
                                ActionTemplate newAction = table.createActionByNote(selected);
                                parent.addSubAction(newAction, actionTemplate, false);
                                treeView1.SelectedNode = newAction.getTreeNode();
                            }
                        }
                    }
                    else if (item.Text == "粘贴动作(上方)")
                    {
                        if (parent.actionList <= 1)
                        {
                            return;
                        }
                        if (curToCopyed is ActionTemplate)
                        {
                            ActionTemplate newAction = ((ActionTemplate)curToCopyed).copy(table);
                            parent.addSubAction(newAction, actionTemplate, true);
                            treeView1.SelectedNode = newAction.getTreeNode();
                        }
                    }
                    else if (item.Text == "粘贴动作(下方)")
                    {
                        if (parent.actionList <= 1)
                        {
                            return;
                        }
                        if (curToCopyed is ActionTemplate)
                        {
                            ActionTemplate newAction = ((ActionTemplate)curToCopyed).copy(table);
                            parent.addSubAction(newAction, actionTemplate, false);
                            treeView1.SelectedNode = newAction.getTreeNode();
                        }
                    }
                    else if (item.Text == "上移动作")
                    {
                        parent.moveSubAction(actionTemplate, true);
                    }
                    else if (item.Text == "下移动作")
                    {
                        parent.moveSubAction(actionTemplate, false);
                    }
                    else if (item.Text == "添加父动作")
                    {
                        if (actionTemplate.eActionType == EActionType.CCActionInstant)
                        {
                            alfForm.setItems(table.getActionsByPerferList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.SPAWN_AND_SEQUENCE));
                        }
                        else
                        {
                            alfForm.setItems(table.getActionsByPerferList(curEditAEData.eType, ActionTemplateTable.EActionFilterType.ACTION_LIST_1,
                                                                          ActionTemplateTable.EActionFilterType.ACTION_LIST_2));
                        }

                        if (alfForm.ShowDialog(this) == DialogResult.OK)
                        {
                            String selected = alfForm.getSelected();
                            if (selected != null)
                            {
                                ActionTemplate newAction = table.createActionByNote(selected);
                                parent.replaceAction(actionTemplate, newAction);
                                newAction.addSubAction(actionTemplate);
                                treeView1.SelectedNode = actionTemplate.getTreeNode();
                                newAction.getTreeNode().ExpandAll();
                            }
                        }
                    }
                }
            }

            curEditAEData.recalcAndUpdate();
            if (__isOpDirty)
            {
                setDirty(__isOpDirty);
            }
            curTreeNodeBindedObject = null;
            treeView1.Update();
        }
Esempio n. 17
0
        public void RunAnalysis()
        {
            var mountainPassArea = AreaCollection.Areas[38];
            var lighterEvent     = mountainPassArea.Events[35];
            var guardEvent       = mountainPassArea.Events[56];
            var rockEvent        = mountainPassArea.Events[38];

            //mountainPassArea.WriteByte(0x00, 0x1FEB);
            //mountainPassArea.WriteByte(0x00, 0x1FF1); // 0x1FF1

            var lighterIdOccurences = new List <int>();
            var guardIdOccurences   = new List <int>();

            for (var i = 0; i < AreaObject.ObjectSize; i++)
            {
                var value = mountainPassArea.ReadByte(i);
                if (value == 36)
                {
                    lighterIdOccurences.Add(i);
                }
                if (value == 57)
                {
                    guardIdOccurences.Add(i); //2256
                }
            }
            //9CC - 1FEA, 2509 - 2779, 2609-2779
            var guardEventValue = mountainPassArea.ReadUnsignedShort(2654); //4127 0x101F 1FEB (0xFCC)
            var lightEventValue = mountainPassArea.ReadUnsignedShort(2612); //3610 1DE6 (diff 517 0x205)
            var rockEventValue  = mountainPassArea.ReadUnsignedShort(2618); //65035

            //EventParser.PrintEvents(mountainPassArea, "mountainPassAreaEvents.txt");

            //event types/offsets start at 2540

            /*
             * var count = 0;
             * for (var i = 2540; i < 2540 + 144; i += 2)
             * {
             *  var value = mountainPassArea.ReadUnsignedShort(i);
             *  Console.WriteLine($"{count} - {value}");
             *  count++;
             * }
             * foreach (var eventPosition in mountainPassArea.EventPositions)
             * {
             *  Console.WriteLine($"{eventPosition.Id} - {eventPosition.Offset}");
             * }*/

            mountainPassArea.WriteByte(0x00, 0x1FE3);

            /*mountainPassArea.WriteByte(0x00, 0x1FE4);
             * mountainPassArea.WriteByte(0x00, 0x1FE5);
             * mountainPassArea.WriteByte(0x00, 0x1FE6);
             * mountainPassArea.WriteByte(0x00, 0x1FE7);
             * mountainPassArea.WriteByte(0x00, 0x1FE8);
             * mountainPassArea.WriteByte(0x00, 0x1FE9);
             * mountainPassArea.WriteByte(0x00, 0x1FEA);
             * mountainPassArea.WriteByte(0x00, 0x1FEB);
             * mountainPassArea.WriteByte(0x00, 0x1FEC);
             * mountainPassArea.WriteByte(0x00, 0x1FED);
             * mountainPassArea.WriteByte(0x00, 0x1FEE);
             * mountainPassArea.WriteByte(0x00, 0x1FEF);
             *
             * var offset = 0x1FE4 + 0;
             * if (false)
             * {
             *  mountainPassArea.WriteByte(0x0D, offset);
             *  mountainPassArea.WriteByte(0x06, offset + 1);
             *  mountainPassArea.WriteByte(0x01, offset + 2);
             * }*/


            var eventActionBytes    = new List <List <byte> >();
            var lighterEventDetails = mountainPassArea.EventDetails.First(d => d.Id == 36);

            /*
             * var position = 0;
             * for (var i = 8; i < lighterEventDetails.Size; i++)
             * {
             *  //lighterEventDetails.WriteByte(lighterEventDetails.ReadByte(i), position);
             *  lighterEventDetails.WriteByte(0x00, i);
             *  position++;
             * }
             * //lighterEventDetails.WriteByte(0x00, position);
             * Console.WriteLine(string.Format("{0:X2}", lighterEventDetails.ReadByte(0)));*/


            var currentPosition = 0;

            while (currentPosition < lighterEventDetails.Size)
            {
                var actionBytes = new List <byte>();
                var actionId    = lighterEventDetails.ReadByte(currentPosition);
                actionBytes.Add(actionId);
                currentPosition++;
                ActionTemplate actionTemplate = null;
                if (TemplateDictionary.Templates.ContainsKey(actionId))
                {
                    actionTemplate = TemplateDictionary.Templates[actionId];
                }
                else
                {
                    actionTemplate = new ActionTemplate(actionId, "Unknown Action", 0);
                }
                if (actionTemplate.StringStart || actionTemplate.NullTerminated)
                {
                    var actionString = "";
                    while (true)
                    {
                        var characterByte = lighterEventDetails.ReadByte(currentPosition);
                        actionBytes.Add(characterByte);
                        if (characterByte == 0 && lighterEventDetails.ReadByte(currentPosition + 1) != 0)
                        {
                            break;
                        }
                        actionString += (char)characterByte;
                        currentPosition++;
                    }
                    currentPosition++;
                }

                else
                {
                    for (var i = currentPosition; i < currentPosition + actionTemplate.ArgumentByteSize; i++)
                    {
                        actionBytes.Add(lighterEventDetails.ReadByte(i));
                    }
                    currentPosition += actionTemplate.ArgumentByteSize;
                }
                eventActionBytes.Add(actionBytes);
            }

            //61 - memory change to obtain lighter
            //84 - memory change to set lighter flag
            var position = 0;
            var skipTo   = 61;
            var stopAt   = 83; //106

            lighterEventDetails.WriteByte(0x24, 0);

            /*
             * position = WriteAction(lighterEventDetails, eventActionBytes[61], position);
             * for (var i = 62; i < 66; i++)
             * {
             *  position = WriteAction(lighterEventDetails, eventActionBytes[i], position);
             * }
             * position = WriteAction(lighterEventDetails, eventActionBytes[66], position);
             * for (var i = 67; i < 71; i++)
             * {
             *  position = WriteAction(lighterEventDetails, eventActionBytes[i], position);
             * }
             * position = WriteAction(lighterEventDetails, eventActionBytes[71], position);
             * position = WriteAction(lighterEventDetails, eventActionBytes[72], position);
             * for (var i = 73; i < 75; i++)
             * {
             *  position = WriteAction(lighterEventDetails, eventActionBytes[i], position);
             * }
             * position = WriteAction(lighterEventDetails, eventActionBytes[76], position);
             * position = WriteAction(lighterEventDetails, eventActionBytes[79], position);
             * position = WriteAction(lighterEventDetails, eventActionBytes[83], position);
             * position = WriteAction(lighterEventDetails, eventActionBytes[84], position);
             * for (var i = position; i < lighterEventDetails.Size; i++)
             * {
             *  lighterEventDetails.WriteByte(0x00, i);
             * }
             * /*
             * for (var i = skipTo; i < stopAt; i++)
             * {
             *  foreach (var b in eventActionBytes[i])
             *  {
             *      lighterEventDetails.WriteByte(b, position);
             *      position++;
             *  }
             * }
             * for (var i = stopAt; i < eventActionBytes.Count; i++)
             * {
             *  foreach (var b in eventActionBytes[i])
             *  {
             *      lighterEventDetails.WriteByte(0x00, position);
             *      position++;
             *  }
             * }
             * lighterEventDetails.WriteByte(0x00, position);
             * foreach (var b in eventActionBytes[skipTo])
             * {
             *  Console.WriteLine(string.Format("{0:X2}", b));
             * }*/

            /*
             * position = 0;
             * for (var i = 8; i < lighterEventDetails.Size; i++)
             * {
             *  //lighterEventDetails.WriteByte(lighterEventDetails.ReadByte(i), position);
             *  lighterEventDetails.WriteByte(0x00, i);
             *  position++;
             * }
             * lighterEventDetails.WriteByte(0x00, position);
             * Console.WriteLine(string.Format("{0:X2}", lighterEventDetails.ReadByte(0)));*/

            /*
             * mountainPassArea.WriteByte(0x00, 2612);
             * mountainPassArea.WriteByte(0x00, 2613);
             *
             * mountainPassArea.WriteByte(0x00, 2618);
             * mountainPassArea.WriteByte(0x00, 2619);
             *
             * mountainPassArea.WriteByte(0x00, 2654);
             * mountainPassArea.WriteByte(0x00, 2655);*/

            //events 42 - 46
            //8040 - 8045
            //starting: 4036
            //location: 8042, offset: 4006
            //lighter offset: 3610
            //guard offset: 4127
            //mountainPassArea.WriteByte(0x06, 8042);
            AreaCollection.WriteObjects(Agent.GeneralConfiguration.TempFile);
        }
Esempio n. 18
0
        private void treeView_KeyUp(object sender, KeyEventArgs e)
        {
            TreeNode node = treeView1.SelectedNode;

            if (node == null)
            {
                return;
            }

            curTreeNodeBindedObject = curEditAEData.getNodeBindedObject(node);
            if (curTreeNodeBindedObject == null)
            {
                return;
            }

            if (e.KeyCode == Keys.Enter)
            {
                if (curTreeNodeBindedObject is AEData)
                {
                }
                else if (curTreeNodeBindedObject is AEConfig)
                {
                    curEditAEData.createConfigPropForm(this).ShowDialog(this);
                }
                else if (curTreeNodeBindedObject is AESprite)
                {
                    curEditAEData.createSpritePropForm((AESprite)curTreeNodeBindedObject, this).ShowDialog(this);
                }
                else if (curTreeNodeBindedObject is ActionTemplate)
                {
                    new ActionPropForm((ActionTemplate)curTreeNodeBindedObject, this).ShowDialog(this);
                }
            }
            else if (e.KeyCode == Keys.W)
            {
                if (curTreeNodeBindedObject is AESprite)
                {
                    this.curEditAEData.moveSprite((AESprite)curTreeNodeBindedObject, true);
                    treeView1.SelectedNode = ((AESprite)curTreeNodeBindedObject).getTreeNode();
                }
                else if (curTreeNodeBindedObject is ActionTemplate)
                {
                    ActionTemplate actionTemplate     = (ActionTemplate)curTreeNodeBindedObject;
                    Object         parentBindedObject = curEditAEData.getNodeBindedObject(actionTemplate.getTreeNode().Parent);
                    if (parentBindedObject is AESprite)
                    {
                        ((AESprite)parentBindedObject).moveAction(actionTemplate, true);
                        treeView1.SelectedNode = ((ActionTemplate)curTreeNodeBindedObject).getTreeNode();
                    }
                    else if (parentBindedObject is ActionTemplate)
                    {
                        ((ActionTemplate)parentBindedObject).moveSubAction(actionTemplate, true);
                        treeView1.SelectedNode = ((ActionTemplate)curTreeNodeBindedObject).getTreeNode();
                    }
                }
                setDirty(true);
                curEditAEData.recalcAndUpdate();
            }
            else if (e.KeyCode == Keys.S)
            {
                if (curTreeNodeBindedObject is AESprite)
                {
                    this.curEditAEData.moveSprite((AESprite)curTreeNodeBindedObject, false);
                    treeView1.SelectedNode = ((AESprite)curTreeNodeBindedObject).getTreeNode();
                }
                else if (curTreeNodeBindedObject is ActionTemplate)
                {
                    ActionTemplate actionTemplate     = (ActionTemplate)curTreeNodeBindedObject;
                    Object         parentBindedObject = curEditAEData.getNodeBindedObject(actionTemplate.getTreeNode().Parent);
                    if (parentBindedObject is AESprite)
                    {
                        ((AESprite)parentBindedObject).moveAction(actionTemplate, false);
                        treeView1.SelectedNode = ((ActionTemplate)curTreeNodeBindedObject).getTreeNode();
                    }
                    else if (parentBindedObject is ActionTemplate)
                    {
                        ((ActionTemplate)parentBindedObject).moveSubAction(actionTemplate, false);
                        treeView1.SelectedNode = ((ActionTemplate)curTreeNodeBindedObject).getTreeNode();
                    }
                }
                setDirty(true);
                curEditAEData.recalcAndUpdate();
            }
        }
Esempio n. 19
0
        private void treeView_NodeClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            if (treeView1 != sender)
            {
                return;
            }
            Console.WriteLine("treeView_NodeClick");

            Point point = treeView1.PointToClient(Cursor.Position);
            TreeViewHitTestInfo info = treeView1.HitTest(point.X, point.Y);
            TreeNode            node = info.Node;

            if (node == null)
            {
                return;
            }

            if (MouseButtons.Right == e.Button)
            {
                treeView1.SelectedNode = node;

                curTreeNodeBindedObject = curEditAEData.getNodeBindedObject(node);
                if (curTreeNodeBindedObject == null)
                {
                    return;
                }

                this.nodeContextMenu.MenuItems.Clear();

                this.nodeContextMenu.MenuItems.Add(node.Text);
                this.nodeContextMenu.MenuItems.Add("-");
                this.nodeContextMenu.MenuItems[0].Enabled = false;
                if (curTreeNodeBindedObject is AEData)
                { // nothing
                    this.nodeContextMenu.MenuItems.Add("新建精灵");
                }
                else if (curTreeNodeBindedObject is AEConfig)
                {
                    this.nodeContextMenu.MenuItems.Add("修改配置");
                }
                else if (curTreeNodeBindedObject is AESprite)
                {
                    AESprite __aeSprite    = (AESprite)curTreeNodeBindedObject;
                    AESprite __upperSprite = curEditAEData.getUpperSprite(__aeSprite);
                    this.nodeContextMenu.MenuItems.Add("修改精灵");
                    this.nodeContextMenu.MenuItems.Add("覆盖动作 -- 使用复制").Enabled = (curToCopyed is ActionTemplate);
                    if (__aeSprite._canDelete)
                    {
                        this.nodeContextMenu.MenuItems.Add("删除精灵");
                    }
                    if (__aeSprite._canMove)
                    {
                        if (__upperSprite == null || __upperSprite._canMove)
                        {
                            this.nodeContextMenu.MenuItems.Add("上移精灵");
                        }
                        this.nodeContextMenu.MenuItems.Add("下移精灵");
                        this.nodeContextMenu.MenuItems.Add("新建精灵(上方)");
                        this.nodeContextMenu.MenuItems.Add("新建精灵(下方)");
                        this.nodeContextMenu.MenuItems.Add("-");
                    }

                    this.nodeContextMenu.MenuItems.Add("新建动作");
                    if (curToCopyed is ActionTemplate)
                    {
                        this.nodeContextMenu.MenuItems.Add("当前复制: " + ((ActionTemplate)curToCopyed).getTreeNode().Text).Enabled = false;
                        this.nodeContextMenu.MenuItems.Add("粘贴动作");
                    }
                    this.nodeContextMenu.MenuItems.Add("-");
                    if (__aeSprite._canMove)
                    {
                        this.nodeContextMenu.MenuItems.Add("复制精灵");
                    }
                    if (curToCopyed != null && curToCopyed is AESprite)
                    {
                        this.nodeContextMenu.MenuItems.Add("当前复制: " + ((AESprite)curToCopyed).getTreeNode().Text).Enabled = false;
                        this.nodeContextMenu.MenuItems.Add("粘贴精灵(上方)");
                        this.nodeContextMenu.MenuItems.Add("粘贴精灵(下方)");
                    }
                }
                else if (curTreeNodeBindedObject is ActionTemplate)
                {
                    ActionTemplate actionTemplate     = (ActionTemplate)curTreeNodeBindedObject;
                    Object         parentBindedObject = curEditAEData.getNodeBindedObject(actionTemplate.getTreeNode().Parent);
                    this.nodeContextMenu.MenuItems.Add("修改动作").Enabled         = (actionTemplate.actionParams.Count > 0);
                    this.nodeContextMenu.MenuItems.Add("覆盖动作 -- 使用复制").Enabled = (curToCopyed is ActionTemplate);
                    if (actionTemplate.actionList == 1 && actionTemplate.subActionList.Count == 0 ||
                        actionTemplate.actionList > 1)
                    {
                        this.nodeContextMenu.MenuItems.Add("添加子动作");
                    }
                    if (parentBindedObject is ActionTemplate)
                    {
                        if (((ActionTemplate)parentBindedObject).subActionList.Count > 1)
                        {
                            this.nodeContextMenu.MenuItems.Add("删除动作");
                            this.nodeContextMenu.MenuItems.Add("上移动作");
                            this.nodeContextMenu.MenuItems.Add("下移动作");
                        }
                        else if (actionTemplate.subActionList.Count == 1)
                        {
                            this.nodeContextMenu.MenuItems.Add("删除动作");
                        }

                        if (((ActionTemplate)parentBindedObject).actionList > 1)
                        {
                            this.nodeContextMenu.MenuItems.Add("新建动作(上方)");
                            this.nodeContextMenu.MenuItems.Add("新建动作(下方)");
                            if (curToCopyed is ActionTemplate)
                            {
                                this.nodeContextMenu.MenuItems.Add("粘贴动作(上方)");
                                this.nodeContextMenu.MenuItems.Add("粘贴动作(下方)");
                            }
                        }
                    }
                    else
                    {
                        this.nodeContextMenu.MenuItems.Add("删除动作");
                        this.nodeContextMenu.MenuItems.Add("上移动作");
                        this.nodeContextMenu.MenuItems.Add("下移动作");
                    }
                    this.nodeContextMenu.MenuItems.Add("添加父动作");
                    this.nodeContextMenu.MenuItems.Add("-");
                    this.nodeContextMenu.MenuItems.Add("复制动作");
                    if (curToCopyed != null && curToCopyed is ActionTemplate)
                    {
                        this.nodeContextMenu.MenuItems.Add("当前复制: " + ((ActionTemplate)curToCopyed).getTreeNode().Text).Enabled = false;

                        if (actionTemplate.actionList == 1 && actionTemplate.subActionList.Count == 0 || actionTemplate.actionList > 1)
                        {
                            this.nodeContextMenu.MenuItems.Add("粘贴子动作");
                        }
                    }
                }

                // 0 for Name
                for (int i = 1; i < this.nodeContextMenu.MenuItems.Count; i++)
                {
                    this.nodeContextMenu.MenuItems[i].Click += new EventHandler(contextmenu_Click);
                }
            }

            this.treeView1.Refresh();
        }