Beispiel #1
0
        private ActionFrame GetActionFrame(string actionName, int frameIndex)
        {
            Action action = this.Actions.Find(act => act.Name == actionName);

            if (action == null)
            {
                return(null);
            }

            Wz_Node bodyNode = PluginBase.PluginManager.FindWz("Character\\00002000.img");

            if (action.Level == 2)
            {
                var frameNode = bodyNode.FindNodeByPath($@"{action.Name}\{frameIndex}");
                if (frameNode != null)
                {
                    ActionFrame frame = new ActionFrame();
                    frame.Action = frameNode.Nodes["action"].GetValueEx <string>(null);
                    frame.Frame  = frameNode.Nodes["frame"].GetValueEx <int>(0);
                    LoadActionFrameDesc(frameNode, frame);
                    return(frame);
                }
            }
            else
            {
                Wz_Node actionNode = this.Body?.Node.FindNodeByPath(action.Name)
                                     ?? bodyNode.FindNodeByPath(action.Name);

                var frameNode = actionNode?.Nodes[frameIndex.ToString()];
                if (frameNode != null)
                {
                    var frame = LoadStandardFrame(frameNode);
                    frame.Action = action.Name;
                    frame.Frame  = frameIndex;
                    return(frame);
                }
            }

            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// 读取扩展属性。
        /// </summary>
        private void LoadActionFrameDesc(Wz_Node frameNode, ActionFrame actionFrame)
        {
            actionFrame.Delay = frameNode.Nodes["delay"].GetValueEx <int>(100);
            actionFrame.Flip  = frameNode.Nodes["flip"].GetValueEx <int>(0) != 0;
            var faceNode = frameNode.Nodes["face"];

            if (faceNode != null)
            {
                actionFrame.Face = faceNode.GetValue <int>() != 0;
            }
            var move = frameNode.Nodes["move"].GetValueEx <Wz_Vector>(null);

            if (move != null)
            {
                actionFrame.Move = move;
            }
            actionFrame.RotateProp = frameNode.Nodes["rotateProp"].GetValueEx <int>(0);
            actionFrame.Rotate     = frameNode.Nodes["rotate"].GetValueEx <int>(0);

            actionFrame.ForceCharacterAction           = frameNode.Nodes["forceCharacterAction"].GetValueEx <string>(null);
            actionFrame.ForceCharacterActionFrameIndex = frameNode.Nodes["forceCharacterActionFrameIndex"].GetValueEx <int>();
            actionFrame.ForceCharacterFaceHide         = frameNode.Nodes["forceCharacterFaceHide"].GetValueEx <int>(0) != 0;
            actionFrame.ForceCharacterFlip             = frameNode.Nodes["forceCharacterFlip"].GetValueEx <int>(0) != 0;
        }
        private Wz_Node[] LinkPlayerParts(ActionFrame bodyAction, ActionFrame faceAction)
        {
            //寻找所有部件
            List <Wz_Node> partNode = new List <Wz_Node>();

            //链接人
            if (this.Body != null && this.Head != null && bodyAction != null &&
                this.Body.Visible && this.Head.Visible)
            {
                //身体
                Wz_Node bodyNode = FindBodyActionNode(bodyAction);
                partNode.Add(bodyNode);

                //头部
                bool?face = bodyAction.Face;          //扩展动作规定头部
                if (face == null && bodyNode != null) //链接的body内规定
                {
                    Wz_Node propNode = bodyNode.FindNodeByPath("face");
                    if (propNode != null)
                    {
                        face = propNode.GetValue <int>(0) != 0;
                    }
                }

                if (face ?? false)
                {
                    ActionFrame headAction = new ActionFrame()
                    {
                        Action = "front"
                    };
                    partNode.Add(FindActionFrameNode(this.Head.Node, headAction));
                }
                else
                {
                    partNode.Add(FindActionFrameNode(this.Head.Node, bodyAction));
                }

                //脸
                if (this.Face != null && this.Face.Visible && faceAction != null)
                {
                    partNode.Add(FindActionFrameNode(this.Face.Node, faceAction));
                }
                //毛
                if (this.Hair != null && this.Hair.Visible)
                {
                    if (face ?? false)
                    {
                        ActionFrame headAction = new ActionFrame()
                        {
                            Action = "default"
                        };
                        partNode.Add(FindActionFrameNode(this.Hair.Node, headAction));
                    }
                    else
                    {
                        partNode.Add(FindActionFrameNode(this.Hair.Node, bodyAction));
                    }
                }
                //其他部件
                for (int i = 4; i < 16; i++)
                {
                    var part = this.Parts[i];
                    if (part != null && part.Visible)
                    {
                        if (i == 12 && Gear.GetGearType(part.ID.Value) == GearType.cashWeapon) //点装武器
                        {
                            var wpNode = part.Node.FindNodeByPath(this.WeaponType.ToString());
                            partNode.Add(FindActionFrameNode(wpNode, bodyAction));
                        }
                        else if (i == 14) //脸
                        {
                            partNode.Add(FindActionFrameNode(part.Node, faceAction));
                        }
                        else //其他部件
                        {
                            partNode.Add(FindActionFrameNode(part.Node, bodyAction));
                        }
                    }
                }
            }

            partNode.RemoveAll(node => node == null);

            return(partNode.ToArray());
        }