コード例 #1
0
ファイル: DUIFont.cs プロジェクト: windygu/EricYou.DirectUI
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="titleNode">字体定义节点</param>
        public DUIFont(XmlNode fontNode)
        {
            if (fontNode != null)
            {
                //读取基础属性
                _name      = XMLConfigReader.ReadString("name", fontNode.Attributes["name"]);
                _backColor = XMLConfigReader.ReadColor(fontNode.Name, "backColor", fontNode.Attributes["backColor"]);
                _foreColor = XMLConfigReader.ReadColor(fontNode.Name, "foreColor", fontNode.Attributes["foreColor"]);

                string _fontFamily    = XMLConfigReader.ReadString("fontFamily", fontNode.Attributes["fontFamily"]);
                int    _fontSize      = XMLConfigReader.ReadInt(fontNode.Name, "fontSize", fontNode.Attributes["fontSize"]);
                bool   _fontBold      = XMLConfigReader.ReadBoolean(fontNode.Name, "fontBold", fontNode.Attributes["fontBold"]);
                bool   _fontItalic    = XMLConfigReader.ReadBoolean(fontNode.Name, "fontItalic", fontNode.Attributes["fontItalic"]);
                bool   _fontUnderline = XMLConfigReader.ReadBoolean(fontNode.Name, "fontUnderline", fontNode.Attributes["fontUnderline"]);
                bool   _fontStrikeout = XMLConfigReader.ReadBoolean(fontNode.Name, "fontStrikeout", fontNode.Attributes["fontStrikeout"]);

                //构造组合属性
                try
                {
                    FontFamily fontFamily = new FontFamily(_fontFamily);
                    FontStyle  fontStyle  = FontStyle.Regular;
                    fontStyle = _fontBold ? (fontStyle | FontStyle.Bold) : fontStyle;
                    fontStyle = _fontItalic ? (fontStyle | FontStyle.Italic) : fontStyle;
                    fontStyle = _fontUnderline ? (fontStyle | FontStyle.Underline) : fontStyle;
                    fontStyle = _fontStrikeout ? (fontStyle | FontStyle.Strikeout) : fontStyle;

                    _font = new Font(fontFamily, _fontSize, fontStyle);
                }
                catch
                {
                    _font = null;
                }
            }
        }
コード例 #2
0
        private string _fontName;   //字体名

        #endregion

        public LabelDUIStyle(XmlNode styleNode)
            : base(styleNode)
        {
            if (styleNode == null)
            {
                throw new Exception("传入了空的XmlNode对象,无法初始化LabelDUIStyle对象!");
            }

            _fontName = XMLConfigReader.ReadString("fontName", styleNode.Attributes["fontName"]);
        }
コード例 #3
0
        private FlatStyle _flatStyle; //按钮点击外观样式

        #endregion

        public ButtonDUIStyle(XmlNode styleNode)
            :base(styleNode)
        {
            if (styleNode == null)
            {
                throw new Exception("传入了空的XmlNode对象,无法初始化LabelDUIStyle对象!");
            }

            //读取基础属性
            _fontName = XMLConfigReader.ReadString("fontName", styleNode.Attributes["fontName"]);
            _flatStyle = XMLConfigReader.ReadFlatStyle(styleNode.Name, "flatStyle", styleNode.Attributes["flatStyle"]);
        }
コード例 #4
0
ファイル: TankControl.cs プロジェクト: zfscgy/NewTankNetwork
    void Start()
    {
        thisRigidbody = GetComponent <Rigidbody>();
        manager       = GameObject.Find("DNTD_WholeGameManager").GetComponent <WholeGameManager>();
        //Self Initilization
        tankName.text = photonView.owner.NickName;
        tankHealth    = GetComponentInChildren <TankHealth>();
        //Read data from "TankConfig.xml"
        TankConfigReader = new XMLConfigReader();
        TankConfigReader.SetTankControl("Assets\\Scripts\\TankConfig.xml", "TankControl", this,
                                        manager.tankModelNumber);
        //Get flag from PhotonPlayer's cache
        playerID = (int)photonView.owner.CustomProperties["index"];
        flag     = (Flag)(playerID / Global.MAX_NUMBER_EACH_SIDE);
        //Display 3DText name and Radar Point
        tankName.GetComponent <Renderer>().material.color = (flag == Flag.Red) ? Color.red : Color.blue;
        radarPoint.GetComponent <SpriteRenderer>().color  = (flag == Flag.Red) ? Color.red : Color.blue;

        GameObject mainController = GameObject.Find("GameController");

        //Register in GameController
        mainController.GetComponent <MainGameController>().AllPlayers.Add(this);
        //Register in the RadarController Dictionary
        mainController.GetComponent <RadarControl>().tankDict.Add(photonView.ownerId, this);
        if (!photonView.isMine)
        {
            GetComponent <Rigidbody>().isKinematic = true;
            //Only local player can have camera
            Flag masterFlag = (Flag)(manager.PlayerID / 5);
            if (flag == masterFlag)
            {
                mainController.GetComponent <RadarControl>().FriendObjects.Add(transform);
            }
            else
            {
                mainController.GetComponent <RadarControl>().TrackedObjects.Add(transform);
            }
            myCamera.GetComponent <Camera>().enabled = false;
            //GetComponent<Rigidbody>().isKinematic = true;
        }
        else
        {
            //Disactive the display object
            tankName.gameObject.SetActive(false);
            //Register in GameController
            mainController.GetComponent <MainGameController>().localPlayer = this;
            mainController.GetComponent <RadarControl>().radar             = transform;

            counterText = GameObject.Find("Canvas/UpperTexts/CounterText").GetComponent <Text>();
            enteredTime = Time.time;
        }
    }
コード例 #5
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="titleNode">布局标题区定义节</param>
 public DUILayoutTitleInfo(XmlNode titleNode)
 {
     if (titleNode != null)
     {
         //读取基础属性
         _iconSourceName  = XMLConfigReader.ReadString("iconSourceName", titleNode.Attributes["iconSourceName"]);
         _showIcon        = XMLConfigReader.ReadBoolean(titleNode.Name, "showIcon", titleNode.Attributes["showIcon"]);
         _text            = XMLConfigReader.ReadString("text", titleNode.Attributes["text"]);
         _titleAreaHeight = XMLConfigReader.ReadInt(titleNode.Name, "titleAreaHeight", titleNode.Attributes["titleAreaHeight"]);
         _titleAreaOffset = XMLConfigReader.ReadInt(titleNode.Name, "titleAreaOffset", titleNode.Attributes["titleAreaOffset"]);
         _fontName        = XMLConfigReader.ReadString("fontName", titleNode.Attributes["fontName"]);
     }
 }
コード例 #6
0
 // Use this for initialization
 void Start()
 {
     //Read data from "TankConfig.xml"
     weaponConfigReader = new XMLConfigReader();
     weaponConfigReader.SetTankWeapons("Assets\\Scripts\\TankConfig.xml", "TankWeapons", this,
                                       GameObject.Find("DNTD_WholeGameManager").GetComponent <WholeGameManager>().tankModelNumber);
     //Find UI elements
     for (int i = 0; i < weaponNum; i++)
     {
         WeaponTexts[i] = GameObject.Find("Canvas/Panel/TextPanel1/WeaponText" + i.ToString()).GetComponent <Text>();
     }
     OutputText = GameObject.Find("Canvas/Panel/TextPanel1/OutputText").GetComponent <Text>();
     UpdateWeaponText();
 }
コード例 #7
0
ファイル: TankHealth.cs プロジェクト: zfscgy/NewTankNetwork
    // Use this for initialization
    void Start()
    {
        //Read data from "TankConfig.xml"
        tankHeathConfigReader = new XMLConfigReader();
        tankHeathConfigReader.SetTankHealth("Assets\\Scripts\\TankConfig.xml", "TankHealth", this,
                                            GameObject.Find("DNTD_WholeGameManager").GetComponent <WholeGameManager>().tankModelNumber);
        if (!photonView.isMine)
        {
            enabled = false;
        }

        //For UI initilization
        healthText       = GameObject.Find("Canvas/Panel/TextPanel1/HealthText").GetComponent <Text>();
        turretHealthText = GameObject.Find("Canvas/Panel/TextPanel1/TurretHealthText").GetComponent <Text>();
        bottomHealthText = GameObject.Find("Canvas/Panel/TextPanel1/BottomHealthText").GetComponent <Text>();
        UpdateHealthText();
    }
コード例 #8
0
        /// <summary>
        /// 从XML配置文件加载按钮信息,形成分组和按钮对象
        /// </summary>
        /// <param name="xmlDoc"></param>
        public void LoadButtonFromXml(XmlDocument xmlDoc)
        {
            if (xmlDoc == null)
            {
                throw new Exception("加载布局" + this._ownerLayout.Name + "中的背景按钮时,文档对象为空!");
            }
            XmlElement layoutElement = xmlDoc.DocumentElement;

            foreach (XmlNode childNode in layoutElement.ChildNodes)
            {
                if (childNode.Name == "buttons")
                {
                    foreach (XmlNode buttonNode in childNode.ChildNodes)
                    {
                        if (buttonNode.Name == "button")
                        {
                            if (buttonNode.Attributes["name"] != null &&
                                buttonNode.Attributes["position"] != null &&
                                buttonNode.Attributes["enable"] != null &&
                                buttonNode.Attributes["normalSourceName"] != null &&
                                buttonNode.Attributes["hoverSourceName"] != null &&
                                buttonNode.Attributes["downSourceName"] != null)
                            {
                                //enble属性为false,或者该属性不存在或非法值时,不加载该按钮
                                string enableString = buttonNode.Attributes["enable"].Value;
                                if (string.IsNullOrEmpty(enableString) ||
                                    (enableString.ToLower() != "true" && enableString.ToLower() != "false"))
                                {
                                    continue;
                                }
                                bool enble = Convert.ToBoolean(enableString);
                                if (enble == false)
                                {
                                    continue;
                                }

                                //创建按钮对象
                                DUIButton newButton = new DUIButton();
                                newButton.Name             = buttonNode.Attributes["name"].Value;
                                newButton.Position         = ConvertStringToPoint(newButton.Name, buttonNode.Attributes["position"].Value);
                                newButton.NormalSourceName = buttonNode.Attributes["normalSourceName"].Value;
                                newButton.HoverSourceName  = buttonNode.Attributes["hoverSourceName"].Value;
                                newButton.DownSourceName   = buttonNode.Attributes["downSourceName"].Value;
                                newButton.Status           = ButtonStatus.Normal;
                                newButton.HoldDown         = false;
                                newButton.Visible          = true;

                                //新加属性
                                newButton.Text           = XMLConfigReader.ReadString("text", buttonNode.Attributes["text"]);
                                newButton.TextAlignment  = XMLConfigReader.ReadEnumTypeConfig <ContentAlignment>(buttonNode.Name, "textAlignment", buttonNode.Attributes["textAlignment"]);
                                newButton.TextOffsetX    = XMLConfigReader.ReadInt(buttonNode.Name, "textOffsetX", buttonNode.Attributes["textOffsetX"]);
                                newButton.TextOffsetY    = XMLConfigReader.ReadInt(buttonNode.Name, "textOffsetY", buttonNode.Attributes["textOffsetY"]);
                                newButton.NormalFontName = XMLConfigReader.ReadString("normalFontName", buttonNode.Attributes["normalFontName"]);
                                newButton.HoverFontName  = XMLConfigReader.ReadString("hoverFontName", buttonNode.Attributes["hoverFontName"]);
                                newButton.DownFontName   = XMLConfigReader.ReadString("downFontName", buttonNode.Attributes["downFontName"]);

                                string buttonGroupName = buttonNode.Attributes["group"] == null ? string.Empty : buttonNode.Attributes["group"].Value;
                                if (buttonGroupName == string.Empty)
                                {
                                    buttonGroupName = DUIButtonGroup.NormalGroupName;
                                }
                                if (!this._buttonGroupDict.ContainsKey(buttonGroupName))
                                {
                                    DUIButtonGroup newButtonGroup = new DUIButtonGroup(buttonGroupName, this);
                                    this._buttonGroupDict.Add(buttonGroupName, newButtonGroup);
                                    this._buttonGroupList.Add(newButtonGroup);
                                }

                                DUIButtonGroup buttonGroup = this._buttonGroupDict[buttonGroupName];
                                newButton.OwnerGroup = buttonGroup;
                                buttonGroup.AddButton(newButton.Name, newButton);
                            }
                        }
                    }
                }
            }
        }
 public ConfigReaderTest()
 {
     this.reader = new XMLConfigReader(configFilePath);
 }
コード例 #10
0
 public FactoryTest()
 {
     InitFactoryForTest();
     this.reader = new XMLConfigReader(ConfigReaderTest.configFilePath);
 }