//更新MActorFolder级别的节点 public void updateTreeNode_ActorFolder() { if (currentActorFolder == null) { return; } int folderID = currentActorFolder.GetID(); TreeNode actorFolderNode = treeView_Animation.Nodes[folderID]; actorFolderNode.Nodes.Clear(); for (int i = 0; i < currentActorFolder.Count(); i++) { TreeNode actorNode = new TreeNode(); MActor actor = currentActorFolder[i]; actorNode.Text = actor.name; actorNode.ImageIndex = 1; actorNode.SelectedImageIndex = 1; for (int k = 0; k < actor.Count(); k++) { TreeNode actionNode = new TreeNode(); MAction action = actor[k]; actionNode.Text = action.name; actionNode.ImageIndex = 2; actionNode.SelectedImageIndex = 2; actorNode.Nodes.Add(actionNode); } actorFolderNode.Nodes.Add(actorNode); } }
//(角色列表)设置当前焦点角色单元 public void setCurrentActor(int index, bool updateUI, int foxID) { if (currentActorFolder != null) { currentActorElement = currentActorFolder[index]; } else { currentActorElement = null; } int newIndex = -1; if (currentActorElement != null && currentActorElement.GetID() >= 0) { newIndex = currentActorElement.GetID(); if (foxID == 1) { Form_MAnimation.noNodeEvent = true; treeView_Animation.SelectedNode = treeView_Animation.Nodes[currentActorFolder.GetID()].Nodes[newIndex]; Form_MAnimation.noNodeEvent = false; } } else { currentActorElement = null; currentActionElement = null; } if (updateUI) { this.setCurrentAction(0, true, foxID); } }
//串行化输入与输出=================================================================== #region SerializeAble Members public void ReadObject(System.IO.Stream s) { short actorFolderIndex = IOUtil.readShort(s); short actorIndex = IOUtil.readShort(s); AntetypesManager antetypesManager = (AntetypesManager)GetTopParent(); if (actorFolderIndex >= 0 && actorIndex >= 0) { if (antetypesManager.actorsManager[actorFolderIndex] == null || antetypesManager.actorsManager[actorFolderIndex][actorIndex] == null) { MessageBox.Show("角色原型中动画索引丢失,需重新指定。", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { this.Actor = antetypesManager.actorsManager[actorFolderIndex][actorIndex]; } } name = IOUtil.readString(s); int imgMappingLen = IOUtil.readInt(s); for (int i = 0; i < imgMappingLen; i++) { ImageMappingElement imgMapElement = new ImageMappingElement(antetypesManager.mapsManager.form_Main.form_MAnimation.form_MImgsList.mImgsManager); imgMapElement.ReadObject(s); imgMappingList.addElement(imgMapElement); } }
/// <summary> /// An actor has been removed from the scene /// </summary> /// <param name="destroyedActor">Actor to remove</param> private void MMActor_MMActorDestroyed(MActor destroyedActor) { _actors.Remove(destroyedActor); if (mapView != null) mapView.RemoveActor(destroyedActor); }
//刷新Anims数据状态 public void updateAnimsItems() { noEvent = true; for (int i = 0; i < listBox_Anims.Items.Count; i++) { if (listBox_Anims.GetItemCheckState(i) == CheckState.Checked) { continue; } MActorsManager actorsManager = srcForm.form_MAnimation.form_MActorList.actorsManager; MActor actor = actorsManager.getActorBySumID(i); bool used = false; for (int j = 0; j < ListBox_AnteType.Items.Count; j++) { if (ListBox_AnteType.GetItemCheckState(j) == CheckState.Checked) { Antetype anteType = (Antetype)srcForm.mapsManager.antetypesManager.getAntetypeBySumID(j); if (anteType.Actor != null && anteType.Actor.Equals(actor)) { used = true; break; } } } if (used) { listBox_Anims.SetItemCheckState(i, CheckState.Checked); } } noEvent = false; }
//在treeView中初始化当前结构 public void updateTreeView_Animation() { treeView_Animation.Nodes.Clear(); for (int i = 0; i < actorsManager.Count(); i++) { TreeNode actorFolderNode = new TreeNode(); MActorFolder actorFolder = actorsManager[i]; currentActorFolder = actorFolder; actorFolderNode.Text = actorFolder.name; actorFolderNode.ImageIndex = 0; actorFolderNode.SelectedImageIndex = 0; for (int j = 0; j < actorFolder.Count(); j++) { TreeNode actorNode = new TreeNode(); MActor actor = actorFolder[j]; currentActorElement = actor; actorNode.Text = actor.name; actorNode.ImageIndex = 1; actorNode.SelectedImageIndex = 1; for (int k = 0; k < actor.Count(); k++) { TreeNode actionNode = new TreeNode(); MAction action = actor[k]; currentActionElement = action; actionNode.Text = action.name; actionNode.ImageIndex = 2; actionNode.SelectedImageIndex = 2; actorNode.Nodes.Add(actionNode); } actorFolderNode.Nodes.Add(actorNode); } treeView_Animation.Nodes.Add(actorFolderNode); } treeView_Animation.ExpandAll(); }
/// <summary> /// A new actor has been added to the scene /// </summary> /// <param name="newActor">New actor</param> private void MMActor_MMActorCreated(MActor newActor) { //only create objects when actually running the game otherwise they would stack up in the scene if (!Application.isPlaying) return; _actors.Add(newActor); if (mapView != null) mapView.AddNewObj(newActor, newActor.ObjPrefab); }
private void showParamsList() { noEvent = true; if (element != null) { //AT_Name if (element.antetype != null) { textBox_ATName.Text = element.antetype.name + "[" + element.antetype.getFolderName() + "]"; } //NpcID numericUpDown_ID.Value = element.NpcID; comboBox_ActionID.Items.Clear(); comboBox_ActionID.SelectedIndex = -1; numericUpDown_FrameID.Value = 0; if (element.antetype != null && element.antetype.Actor != null) { //actionID MActor actor = element.antetype.Actor; for (int i = 0; i < actor.Count(); i++) { comboBox_ActionID.Items.Add(actor[i].name); } if (element.actionID >= 0 && element.actionID < comboBox_ActionID.Items.Count) { comboBox_ActionID.SelectedIndex = element.actionID; } else { comboBox_ActionID.SelectedIndex = -1; } if (element.startTime >= numericUpDown_FrameID.Minimum && element.startTime <= numericUpDown_FrameID.Maximum) { numericUpDown_FrameID.Value = element.startTime; } } //isActive checkBox_active.Checked = element.isVisible; //keyValue panel_SelfLeft.Controls.Clear(); panel_SelfRight.Controls.Clear(); for (int i = 0; i < element.keyValueManager.Count(); i++) { TileObjKeyValue item = element.keyValueManager[i]; TextBoxEX textBoxLeft = createNewTextBox(item.strKey); panel_SelfLeft.Controls.Add(textBoxLeft); TextBoxEX textBoxRight = createNewTextBox(item.strValue); panel_SelfRight.Controls.Add(textBoxRight); } } noEvent = false; }
//刷新记录 private void refreshMemory() { actors.Clear(); MActorFolder folder = actorsManager[comboBox_folder.SelectedIndex]; for (int i = 0; i < folder.Count(); i++) { if (listBox_Actors.GetItemChecked(i)) { MActor actor = folder[i]; actors.Add(new ActorAndFolder(folder, actor)); } } }
//刷新可选角色列表 private void refreshActorList() { AntetypesManager antetypesManager = (AntetypesManager)antetype.GetTopParent(); MActorFolder actorsFolder = antetypesManager.actorsManager[comboBox_folder.SelectedIndex]; comboBox_Actor.Items.Clear(); if (actorsFolder != null) { for (int i = 0; i < actorsFolder.Count(); i++) { MActor actor = actorsFolder[i]; comboBox_Actor.Items.Add(actor.name); } } }
private void RenderMesh() { if (Global.bEmptyMesh == true) { return; } float fTime = DateTime.Now.Ticks * 0.001f; MActor actor = Global.actorMgr.GetFast(0); if (actor.Valid) { // actor.Frame(fTime); // actor.Render(fTime); } }
private void comboBox_Actor_SelectedIndexChanged(object sender, EventArgs e) { if (noEvent || antetype == null) { return; } AntetypesManager antetypesManager = (AntetypesManager)antetype.GetTopParent(); MActorFolder actorsFolder = antetypesManager.actorsManager[comboBox_folder.SelectedIndex]; MActor actor = actorsFolder[comboBox_Actor.SelectedIndex]; if (actor != null) { antetype.Actor = actor; antetype.name = antetype.Actor.name + ""; textBox_Name.Text = antetype.name; this.refreshActor(); } }
private void refreshActorList() { if (actorsManager == null) { return; } if (comboBox_folder.Items.Count <= 0) { return; } MActorFolder folder = actorsManager[comboBox_folder.SelectedIndex]; listBox_Actors.Items.Clear(); for (int i = 0; i < folder.Count(); i++) { MActor actor = folder[i]; listBox_Actors.Items.Add(actor.name); } }
//(角色列表)复制单元 public void cloneActorElement() { if (currentActorFolder == null || currentActorElement == null) { return; } form_MA.historyManager.ReadyHistory(HistoryType.Actor); MActor actor = (MActor)currentActorElement.Clone(currentActorFolder); String name = actor.name; SmallDialog_WordEdit txtDialog = new SmallDialog_WordEdit("复制单元", name); txtDialog.ShowDialog(); name = txtDialog.getValue(); actor.name = name; currentActorFolder.Add(actor); updateTreeNode_ActorFolder(); setCurrentActor(currentActorFolder.GetSonID(actor), true, 1); form_MA.historyManager.AddHistory(HistoryType.Actor); }
private void treeView_Animation_DragDrop(object sender, DragEventArgs e) { //得到拖放数据,并转换为TreeNode型 TreeNode theNode = (TreeNode)e.Data.GetData(typeof(TreeNode)); TreeView theTree = (TreeView)sender; //得到鼠标进入TreeNode,而拖放目标targetNode TreeNode targetNode = theTree.GetNodeAt(treeView_Animation.PointToClient(new Point(e.X, e.Y))); if (targetNode != null && !targetNode.Equals(theNode.Parent) && ((theNode.Level == 1 && targetNode.Level == 0) || (theNode.Level == 2 && targetNode.Level == 1))) { form_MA.historyManager.ReadyHistory(HistoryType.Actor); //先调整数据 if (theNode.Level == 1) { MActorFolder folderSrc = (MActorFolder)actorsManager[theNode.Parent.Index]; MActor actor = folderSrc[theNode.Index]; MActorFolder folderDest = (MActorFolder)actorsManager[targetNode.Index]; folderSrc.RemoveAt(theNode.Index); folderDest.Add(actor); } else if (theNode.Level == 2) { MActorFolder folderSrc = (MActorFolder)actorsManager[theNode.Parent.Parent.Index]; MActor actorSrc = folderSrc[theNode.Parent.Index]; MAction actionSrc = actorSrc[theNode.Index]; MActorFolder folderDest = (MActorFolder)actorsManager[targetNode.Parent.Index]; MActor actorDest = folderDest[targetNode.Index]; actorSrc.RemoveAt(theNode.Index); actorDest.Add(actionSrc); } //调整UI TreeNode targetParent = targetNode.Parent; //删除拖放的TreeNode theNode.Remove(); //添加到目标TreeView下 targetNode.Nodes.Add(theNode); theTree.SelectedNode = targetNode; form_MA.historyManager.AddHistory(HistoryType.Actor); } }
//角色列表部分================================================================================================== //(角色列表)加入新单元 public void addActorElement() { if (currentActorFolder == null) { return; } String name = "角色" + currentActorFolder.Count(); SmallDialog_WordEdit txtDialog = new SmallDialog_WordEdit("新建角色", name); txtDialog.ShowDialog(); name = txtDialog.getValue(); form_MA.historyManager.ReadyHistory(HistoryType.Actor); MActor element = new MActor(currentActorFolder); element.name = name; currentActorFolder.Add(element); updateTreeNode_ActorFolder(); setCurrentActor(currentActorFolder.GetSonID(element), true, 1); form_MA.historyManager.AddHistory(HistoryType.Actor); }
//更新Actor级别的节点 public void updateTreeNode_Actor() { if (currentActorFolder == null || currentActorElement == null) { return; } TreeNode actorNode = treeView_Animation.Nodes[currentActorFolder.GetID()].Nodes[currentActorFolder.GetSonID(currentActorElement)]; MActor actor = currentActorElement; actorNode.Nodes.Clear(); for (int k = 0; k < actor.Count(); k++) { TreeNode actionNode = new TreeNode(); MAction action = actor[k]; actionNode.Text = action.name; actionNode.ImageIndex = 2; actionNode.SelectedImageIndex = 2; actorNode.Nodes.Add(actionNode); } }
//(角色列表)重命名单元 public void renameActorElement() { if (currentActorElement == null || currentActorFolder == null) { return; } MActor actor = currentActorElement; String name = actor.name; SmallDialog_WordEdit txtDialog = new SmallDialog_WordEdit("重命名", name); txtDialog.ShowDialog(); String nameNew = txtDialog.getValue(); if (!nameNew.Equals(name)) { form_MA.historyManager.ReadyHistory(HistoryType.Actor); actor.name = nameNew; treeView_Animation.Nodes[currentActorFolder.GetID()].Nodes[currentActorElement.GetID()].Text = nameNew; form_MA.historyManager.AddHistory(HistoryType.Actor); } }
//(角色列表)向上移动单元 public void moveUpActorElement() { if (currentActorElement == null || currentActorFolder == null) { return; } form_MA.historyManager.ReadyHistory(HistoryType.Actor); MActor actor = currentActorElement; MActorFolder actorFolder = currentActorFolder; int index = actor.GetID(); if (!actorFolder.MoveUpElement(index)) { return; } updateTreeNode_ActorFolder(); index--; if (index < 0) { index = 0; } setCurrentActor(index, true, 1); form_MA.historyManager.AddHistory(HistoryType.Actor); }
//(角色列表)向下移动单元 public void moveDownActorElement() { if (currentActorElement == null || currentActorFolder == null) { return; } form_MA.historyManager.ReadyHistory(HistoryType.Actor); MActor actor = currentActorElement; MActorFolder actorFolder = currentActorFolder; int index = actorFolder.GetSonID(actor); if (!actorFolder.MoveDownElement(index)) { return; } updateTreeNode_ActorFolder(); index++; if (index > actorFolder.Count() - 1) { index = actorFolder.Count() - 1; } setCurrentActor(index, true, 1); form_MA.historyManager.AddHistory(HistoryType.Actor); }
private void TransformObjAccordActor(MObject obj, MActor actor) { Transform actorTrans = actor.transform; //object's map coordinates Vector2 actorCoord = WorldToMap(actorTrans.position); Vector2 objCoord = actorCoord - currentCenterCoord; //calculate the position within the mask and check if it is within the mask Rect locRect = rTrans.rect; float xPos = (actorCoord.x + locRect.width / 2 - currentCenterCoord.x) / locRect.width; float yPos = (actorCoord.y + locRect.height / 2 - currentCenterCoord.y) / locRect.height; bool isVisible = false; if (xPos <= 1.0f && xPos >= 0.0f && yPos <= 1.0f && yPos >= 0.0f) isVisible = IsWithinMaskTex(new Vector2(xPos, yPos)); obj.UpdateObject(orientation, objCoord, actorTrans.forward, isVisible, currentCenterCoord, mObjectDefaultSize, CalculateZoomScaleRatio(), isScalingMObjects, isZoomingSmoothly, smoothZoomSpeed); }
public Antetype(AntetypeFolder parentT, MActor actorT) { parent = parentT; Actor = actorT; name = Actor.name + ""; }
//角色列表部分================================================================================================== //(角色列表)加入新单元 public void addActorElement() { if (currentActorFolder == null) { return; } String name = "角色" + currentActorFolder.Count(); SmallDialog_WordEdit txtDialog = new SmallDialog_WordEdit("新建角色", name); txtDialog.ShowDialog(); name = txtDialog.getValue(); form_MA.historyManager.ReadyHistory(HistoryType.Actor); MActor element = new MActor(currentActorFolder); element.name=name; currentActorFolder.Add(element); updateTreeNode_ActorFolder(); setCurrentActor(currentActorFolder.GetSonID(element), true, 1); form_MA.historyManager.AddHistory(HistoryType.Actor); }
private void TransformObjAccordActor(MObject obj, MActor actor) { Transform actorTrans = actor.transform; //get the position of the actor within the world Vector2 actorVpPos = WorldToMap(actorTrans.position); //and it's map coordinates Vector2 objCoord = actorVpPos - currentCenterCoord; //if mask either doesn't exist or exists and the actor is in the visible area of the mask //also cut out actors outside of visible area of the view float xPos = (actorVpPos.x + rTrans.rect.width / 2 - currentCenterCoord.x) / rTrans.rect.width; float yPos = (actorVpPos.y + rTrans.rect.height / 2 - currentCenterCoord.y) / rTrans.rect.height; bool isVisible = false; if (xPos <= 1.0f && xPos >= 0.0f && yPos <= 1.0f && yPos >= 0.0f) isVisible = IsWithinMaskTex(new Vector2(xPos, yPos)); obj.UpdateObject(orientation, objCoord, actorTrans.forward, isVisible, currentCenterCoord, mObjectDefaultSize, CalculateZoomScaleRatio(), isScalingMObjects, isZoomingSmoothly, smoothZoomSpeed); }
/// <summary> /// Remove an existing pin from this view /// </summary> /// <param name="mActor">The actor whose pin to remove</param> public virtual void RemoveActor(MActor mActor) { //has to be casted to Array otherwise wouldn't work var objsToRemove = objInstances.Where(kvpObjAct => kvpObjAct.Value == mActor).ToArray(); foreach (var objToRemove in objsToRemove) { RemoveObj(objToRemove.Key); } }
public ActorAndFolder(MActorFolder folderT, MActor antetypeT) { folder = folderT; actor = antetypeT; }
//刷新数据显示======================================================== public void updateRes() { //载入地图 listBox_Maps.Items.Clear(); for (int i = 0; i < srcForm.mapsManager.getElementCount(); i++) { String text = "" + srcForm.mapsManager.getElement(i).getName(); listBox_Maps.Items.Add(text); } listBox_Maps.Refresh(); //载入角色原型 ListBox_AnteType.Items.Clear(); for (int i = 0; i < srcForm.mapsManager.antetypesManager.Count(); i++) { AntetypeFolder folder = srcForm.mapsManager.antetypesManager[i]; for (int j = 0; j < folder.Count(); j++) { Antetype anteType = folder[i]; String text = ""; if (anteType != null) { text = "[" + anteType.getFolderName() + "]" + anteType.name; if (anteType.Actor == null) { MessageBox.Show("角色原型“" + anteType.name + "”指向的角色为空!", "警告", MessageBoxButtons.OK); } } else { text = "错误的角色原型"; } ListBox_AnteType.Items.Add(text); } } ListBox_AnteType.Refresh(); //载入动画 listBox_Anims.Items.Clear(); MActorsManager actorsManager = srcForm.form_MAnimation.form_MActorList.actorsManager; for (int i = 0; i < actorsManager.Count(); i++) { MActorFolder folder = actorsManager[i]; for (int j = 0; j < folder.Count(); j++) { MActor actor = folder[j]; String text = folder.name + "_" + actor.name; listBox_Anims.Items.Add(text); } } listBox_Anims.Refresh(); //载入触发器 listBox_Triggers.Items.Clear(); listBox_Triggers.Refresh(); //载入属性表 listBox_Props.Items.Clear(); for (int i = 0; i < srcForm.propertyTypesManager.getElementCount(); i++) { String text = "" + ((PropertyTypeElement)srcForm.propertyTypesManager.getElement(i)).name; listBox_Props.Items.Add(text); } listBox_Props.Refresh(); }
/// <summary> /// Add new pin on this view /// </summary> public GameObject AddNewObj(MActor newActor, MObject prefab) { GameObject newObjGo = InstantiateObject(prefab); MObject mObj = MUtil.GetComponentInChildren<MObject>(newObjGo); if (mObj == null) MUtil.Error("mObj is null!", this); objInstances.Add(mObj, newActor); mObj.mObjectDestroyedHandler += mObj_mObjectDestroyedHandler; return newObjGo; }