示例#1
0
    static int ToString(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        IM.Number obj = (IM.Number)LuaScriptMgr.GetNetObjectSelf(L, 1, "IM.Number");
        string    o   = obj.ToString();

        LuaScriptMgr.Push(L, o);
        return(1);
    }
示例#2
0
    public bool Save(XmlDocument pDoc, XmlElement pSolution)
    {
        XmlNode pNodeInit            = pDoc.CreateElement("init");
        XmlNode pNodePosition        = pDoc.CreateElement("position");
        XmlNode pNodeVelocity        = pDoc.CreateElement("velocity");
        XmlNode pNodeBounceRim       = pDoc.CreateElement("bounce_rim");
        XmlNode pNodeBounceBackboard = pDoc.CreateElement("bounce_backboard");

        pSolution.AppendChild(pNodeInit);
        pNodeInit.AppendChild(pNodePosition);
        pNodeInit.AppendChild(pNodeVelocity);
        pNodeInit.AppendChild(pNodeBounceRim);
        pNodeInit.AppendChild(pNodeBounceBackboard);

        string text = string.Format("{0:f3} {1:f3} {2:f3}", m_vInitPos.x, m_vInitPos.y, m_vInitPos.z);

        pNodePosition.AppendChild(pDoc.CreateTextNode(text));
        text = string.Format("{0:f3} {1:f3} {2:f3}", m_vInitVel.x, m_vInitVel.y, m_vInitVel.z);
        pNodeVelocity.AppendChild(pDoc.CreateTextNode(text));
        text = string.Format("{0:f3} {1:f3} {2:f3}", m_vBounceRimAdjustment.x, m_vBounceRimAdjustment.y, m_vBounceRimAdjustment.z);
        pNodeBounceRim.AppendChild(pDoc.CreateTextNode(text));
        text = string.Format("{0:f3}", m_fBounceBackboard);
        pNodeBounceBackboard.AppendChild(pDoc.CreateTextNode(text));

        XmlNode pNodeTime = pDoc.CreateElement("time");

        pSolution.AppendChild(pNodeTime);
        pNodeTime.AppendChild(pDoc.CreateTextNode(m_fTime.ToString()));
        XmlNode pNodeCleanShot = pDoc.CreateElement("clean_shot");

        pSolution.AppendChild(pNodeCleanShot);
        pNodeCleanShot.AppendChild(pDoc.CreateTextNode(m_bCleanShot.ToString()));
        XmlNode pNodeType = pDoc.CreateElement("type");

        pSolution.AppendChild(pNodeType);
        pNodeType.AppendChild(pDoc.CreateTextNode(((int)m_type).ToString()));
        XmlNode pNodeMaxHeight = pDoc.CreateElement("max_height");

        pSolution.AppendChild(pNodeMaxHeight);
        IM.Number fMaxHeight = m_ShootCurveList[m_ShootCurveList.Count - 1].GetHighestPosition().y;
        pNodeMaxHeight.AppendChild(pDoc.CreateTextNode(fMaxHeight.ToString()));

        //for editor, don't save the last one.
        XmlNode pNodeCurve;

        for (int idx = 0; idx != m_ShootCurveList.Count; idx++)
        {
            ShootSolution.SShootCurve curve = m_ShootCurveList[idx];
            string value = string.Format("{0:f3} {1:f3} {2:f3} {3:f3} {4:f3} {5:f3} {6:f3} {7:f3} {8:f3} {9:f3}",
                                         curve.fTime, curve.fX_a, curve.fX_b, curve.fX_c,
                                         curve.fY_a, curve.fY_b, curve.fY_c,
                                         curve.fZ_a, curve.fZ_b, curve.fZ_c);

            pNodeCurve = pDoc.CreateElement("curve");
            pSolution.AppendChild(pNodeCurve);
            pNodeCurve.AppendChild(pDoc.CreateTextNode(value));
        }

        XmlNode pNodeFin = pDoc.CreateElement("fin");

        pNodePosition = pDoc.CreateElement("position");
        pNodeVelocity = pDoc.CreateElement("velocity");

        pSolution.AppendChild(pNodeFin);
        pNodeFin.AppendChild(pNodePosition);
        pNodeFin.AppendChild(pNodeVelocity);

        text = string.Format("{0:f3} {1:f3} {2:f3}", m_vFinPos.x, m_vFinPos.y, m_vFinPos.z);
        pNodePosition.AppendChild(pDoc.CreateTextNode(text));

        text = string.Format("{0:f3} {1:f3} {2:f3}", m_vFinVel.x, m_vFinVel.y, m_vFinVel.z);
        pNodeVelocity.AppendChild(pDoc.CreateTextNode(text));

        XmlNode animationClip  = pDoc.CreateElement("animationType");
        XmlNode animationTime  = pDoc.CreateElement("playTime");
        XmlNode animationSpeed = pDoc.CreateElement("playSpeed");
        XmlNode reductionIndex = pDoc.CreateElement("redunctionIndex");
        XmlNode isLock         = pDoc.CreateElement("isLock");

        pSolution.AppendChild(animationClip);
        animationClip.AppendChild(pDoc.CreateTextNode(((int)m_animationType).ToString()));

        pSolution.AppendChild(animationTime);
        animationTime.AppendChild(pDoc.CreateTextNode(m_playTime.ToString()));

        pSolution.AppendChild(animationSpeed);
        animationSpeed.AppendChild(pDoc.CreateTextNode(m_playSpeed.ToString()));

        pSolution.AppendChild(reductionIndex);
        reductionIndex.AppendChild(pDoc.CreateTextNode(m_reductionIndex.ToString()));

        pSolution.AppendChild(isLock);
        isLock.AppendChild(pDoc.CreateTextNode(m_isLock.ToString()));


        return(true);
    }