Example #1
0
 public static void UpdateXML(string path, Transform trans, _States _s)
 {
     if (File.Exists(path))
     {
         //如果不包含则创建
         ContainsNode(path, trans, _s);
     }
 }
Example #2
0
 /// <summary>
 /// Raises the MouseEnter event.
 /// </summary>
 protected override void OnMouseEnter(System.EventArgs e)
 {
     if (_Active)
     {
         _State = _States.MouseOver;
         this.Invalidate();
     }
 }
Example #3
0
 protected override void OnMouseLeave(System.EventArgs e)
 {
     if (_Active)
     {
         _State = _States.Normal;
         this.Invalidate();
         base.OnMouseLeave(e);
     }
 }
Example #4
0
 protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
 {
     if (_Active)
     {
         _State = _States.Clicked;
         this.Invalidate();
         base.OnMouseDown(e);
     }
 }
Example #5
0
 public static void WriteDefult(_States _s, XmlNode xn, Transform trans)
 {
     if (_s.Equals(_States.Camera))
     {
         xn.InnerText = Camera.main.transform.position.x.ToString() + "," + Camera.main.transform.position.y + "," + Camera.main.transform.position.z.ToString() +
                        "/" + Camera.main.transform.eulerAngles.x.ToString() + "," + Camera.main.transform.eulerAngles.y.ToString() + "," + Camera.main.transform.parent.eulerAngles.z.ToString();
     }
     else
     {
         xn.InnerText = trans.position.x.ToString() + "," + trans.position.y.ToString() + "," + trans.position.z.ToString()
                        + "/" + trans.eulerAngles.x.ToString() + "," + trans.eulerAngles.y.ToString() + "," + trans.eulerAngles.z.ToString();
     }
 }
Example #6
0
 protected override void OnMouseEnter(System.EventArgs e)
 {
     if (_Active)
     {
         _State = _States.MouseOver;
         this.Invalidate();
         base.OnMouseEnter(e);
         if (_toolTip != null)
         {
             _toolTip.Active = false;
             _toolTip.Active = true;
         }
     }
 }
Example #7
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            //
            // set SmoothingMode
            //
            switch (_SmoothingQuality)
            {
            case SmoothingQualities.None:
                e.Graphics.SmoothingMode = SmoothingMode.Default;
                break;

            case SmoothingQualities.HighSpeed:
                e.Graphics.SmoothingMode = SmoothingMode.HighSpeed;
                break;

            case SmoothingQualities.AntiAlias:
                e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
                break;

            case SmoothingQualities.HighQuality:
                e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
                break;
            }

            SizeF textSize = e.Graphics.MeasureString(this.Text, base.Font);
            int   textX    = (int)(base.Size.Width / 2) - (int)(textSize.Width / 2);
            int   textY    = (int)(base.Size.Height / 2) - (int)(textSize.Height / 2);

            if (IsSelected)
            {
                _State = _States.Selected;
                DrawActiveButtonByState(e.Graphics, _State, ClientRectangle.X, ClientRectangle.Y);
                e.Graphics.DrawString(this.Text, base.Font, new SolidBrush(base.ForeColor), textX + 1, textY + 1);
            }
            else
            {
                if (_Active)
                {
                    DrawActiveButtonByState(e.Graphics, _State, ClientRectangle.X, ClientRectangle.Y);
                    e.Graphics.DrawString(this.Text, base.Font, new SolidBrush(base.ForeColor), textX + 1, textY + 1);
                }
                else
                {
                    DrawNotActiveButtonByState(e.Graphics, _State, ClientRectangle.X + 1, ClientRectangle.Y);
                    e.Graphics.DrawString(this.Text, base.Font, new SolidBrush(_NormalColorA), textX, textY);
                }
            }
        }
Example #8
0
        void DrawActiveButtonByState(Graphics g, _States state, int x, int y)
        {
            MemoryStream ms = new MemoryStream();

            switch (state)
            {
            case _States.Normal:
                CxViewerResources.PathButton.Save(ms, ImageFormat.Png);
                break;

            case _States.MouseOver:
                CxViewerResources.PathActiveButton.Save(ms, ImageFormat.Png);
                break;

            case _States.Clicked:
                CxViewerResources.PathActiveButton.Save(ms, ImageFormat.Png);
                break;

            case _States.Selected:
                CxViewerResources.PathSelectedButton.Save(ms, ImageFormat.Png);
                break;
            }
            System.Drawing.Image image = System.Drawing.Image.FromStream(ms);

            //flip the image around its center
            using (System.Drawing.Drawing2D.Matrix m = g.Transform)
            {
                using (System.Drawing.Drawing2D.Matrix saveM = m.Clone())
                {
                    float c = (float)y;

                    using (System.Drawing.Drawing2D.Matrix m2 = new System.Drawing.Drawing2D.Matrix(1, 0, 0, -1, 0, 2 * c))
                        m.Multiply(m2);

                    //g.Transform = m;
                    g.DrawImage(image, (float)(x), (float)(y), 200, 28);
                    g.Transform = saveM;
                }
            }
        }
Example #9
0
 void DrawNotActiveButtonByState(Graphics g, _States state, int x, int y)
 {
     DrawActiveButtonByState(g, state, x, y);
 }
Example #10
0
    //Changes the objects state (0=idle, 1=move, 2=attack)
    public void ChangeState(_States state)
    {
        switch (state)
        {
        case _States.IDLE:
            currentState           = _States.IDLE;
            amountOfTexturesPerDir = amountOfIdleTexturesPerDir;
            allTextures            = idleTextures;
            allNormals             = idleNormals;
            allEmissions           = idleEmissions;
            allMetallics           = idleMetallics;
            allOcclusions          = idleOcclusions;
            timeBetweenAnimFrames  = idleTimeBetweenAnimFrames;
            break;

        case _States.RUN:
            currentState           = _States.RUN;
            amountOfTexturesPerDir = amountOfMovementTexturesPerDir;
            allTextures            = movementTextures;
            allNormals             = movementNormals;
            allEmissions           = movementEmissions;
            allMetallics           = movementMetallics;
            allOcclusions          = movementOcclusions;
            timeBetweenAnimFrames  = movementTimeBetweenAnimFrames;
            break;

        case _States.HIT:
            currentState           = _States.HIT;
            amountOfTexturesPerDir = amountOfHitTexturesPerDir;
            allTextures            = hitTextures;
            allNormals             = hitNormals;
            allEmissions           = hitEmissions;
            allMetallics           = hitMetallics;
            allOcclusions          = hitOcclusions;
            timeBetweenAnimFrames  = hitTimeBetweenAnimFrames;
            break;

        case _States.DEATH:
            currentState           = _States.DEATH;
            amountOfTexturesPerDir = amountOfDeathTexturesPerDir;
            allTextures            = deathTextures;
            allNormals             = deathNormals;
            allEmissions           = deathEmissions;
            allMetallics           = deathMetallics;
            allOcclusions          = deathOcclusions;
            timeBetweenAnimFrames  = deathTimeBetweenAnimFrames;
            break;

        case _States.SHOOT:
            currentState           = _States.SHOOT;
            amountOfTexturesPerDir = amountOfShootTexturesPerDir;
            allTextures            = shootTextures;
            allNormals             = shootNormals;
            allEmissions           = shootEmissions;
            allMetallics           = shootMetallics;
            allOcclusions          = shootOcclusions;
            timeBetweenAnimFrames  = shootTimeBetweenAnimFrames;
            break;

        case _States.STUN:
            currentState           = _States.STUN;
            amountOfTexturesPerDir = amountOfStunTexturesPerDir;
            allTextures            = stunTextures;
            allNormals             = stunNormals;
            allEmissions           = stunEmissions;
            allMetallics           = stunMetallics;
            allOcclusions          = stunOcclusions;
            timeBetweenAnimFrames  = stunTimeBetweenAnimFrames;
            break;

        case _States.JUMP:
            currentState           = _States.JUMP;
            amountOfTexturesPerDir = amountOfJumpTexturesPerDir;
            allTextures            = jumpTextures;
            allNormals             = jumpNormals;
            allEmissions           = jumpEmissions;
            allMetallics           = jumpMetallics;
            allOcclusions          = jumpOcclusions;
            timeBetweenAnimFrames  = jumpTimeBetweenAnimFrames;
            break;

        case _States.SPECIAL:
            currentState           = _States.SPECIAL;
            amountOfTexturesPerDir = amountOfSpecialTexturesPerDir;
            allTextures            = specialTextures;
            allNormals             = specialNormals;
            allEmissions           = specialEmissions;
            allMetallics           = specialMetallics;
            allOcclusions          = specialOcclusions;
            timeBetweenAnimFrames  = specialTimeBetweenAnimFrames;
            break;
        }
        frame    = 0;
        counter  = 0;
        animDone = false;
    }
Example #11
0
 protected override void OnMouseUp(System.Windows.Forms.MouseEventArgs e)
 {
     if (_Active)
     {
         _State = _States.MouseOver;
         this.Invalidate();
         base.OnMouseUp(e);
     }
 }
Example #12
0
 protected override void OnMouseLeave(System.EventArgs e)
 {
     if (_Active)
     {
         _State = _States.Normal;
         this.Invalidate();
         base.OnMouseLeave(e);
     }
 }
Example #13
0
 protected override void OnMouseEnter(System.EventArgs e)
 {
     if (_Active)
     {
         _State = _States.MouseOver;
         this.Invalidate();
         base.OnMouseEnter(e);
         if( _toolTip != null )
         {
             _toolTip.Active = false;
             _toolTip.Active = true;
         }
     }
 }
Example #14
0
 protected override void OnEnter(System.EventArgs e)
 {
     if (_Active)
     {
         _State = _States.MouseOver;
         this.Invalidate();
         base.OnEnter(e);
     }
 }
Example #15
0
 ReferenceEquals(_States, other._States) &&
Example #16
0
 public void SetNormalState()
 {
     _State = _States.Normal;
 }
Example #17
0
    public static void ContainsNode(string path, Transform trans, _States _s)
    {
        Caching.CleanCache();

        XmlDocument xmldoc = new XmlDocument();

        xmldoc.Load(path);
        XmlNode     root     = xmldoc.SelectSingleNode("RobotPro");
        XmlNodeList nodelist = root.ChildNodes;

        for (int i = 0; i < nodelist.Count; i++)
        {
            //找到点击物体对应的xml节点
            if (nodelist[i].Attributes["name"].Value.Equals(trans.name))
            {
                IsFindNode = true;
            }
        }

        if (!IsFindNode)
        {
            XmlElement xe = xmldoc.CreateElement("Node");
            xe.SetAttribute("id", "0");
            xe.SetAttribute("info", "填充info信息........");
            xe.SetAttribute("name", trans.name);
            root.AppendChild(xe);
        }
        //RobotPro节点下的所有子节点
        if (nodelist.Count > 0)
        {
            for (int i = 0; i < nodelist.Count; i++)
            {
                //找到点击物体对应的xml节点
                if (nodelist[i].Attributes["name"].Value.Equals(trans.name))
                {
                    XmlNodeList childnode = nodelist[i].ChildNodes;
                    //遍历该节点下的子节点
                    if (childnode.Count > 0)
                    {
                        for (int j = 0; j < childnode.Count; j++)
                        {
                            Debug.Log(_s.ToString());
                            if (childnode[j].Attributes["name"].Value.Equals(_s.ToString()))
                            {
                                WriteDefult(_s, childnode[j], trans);
                                IsFindChildNode = true;
                            }
                        }
                        if (!IsFindChildNode)
                        {
                            XmlElement xe = xmldoc.CreateElement("childnode");
                            xe.SetAttribute("name", _s.ToString());
                            WriteDefult(_s, xe, trans);
                            nodelist[i].AppendChild(xe);
                            // root.AppendChild(nodelist[i]);
                        }
                    }
                    else
                    {
                        XmlElement xe = xmldoc.CreateElement("childnode");
                        xe.SetAttribute("name", _s.ToString());
                        WriteDefult(_s, xe, trans);
                        nodelist[i].AppendChild(xe);
                    }
                }
            }
        }
        else
        {
            Debug.Log(trans.position.ToString() + trans.position.x);

            XmlElement xx = xmldoc.CreateElement("Node");
            xx.SetAttribute("name", trans.name);
            XmlElement xe = xmldoc.CreateElement(_s.ToString());
            xe.InnerText = trans.position.ToString() + "/" + trans.localEulerAngles.ToString();
            xx.AppendChild(xe);
            root.AppendChild(xx);
        }
        xmldoc.Save(path);
        IsFindChildNode = false;
        IsFindNode      = false;
    }