Exemplo n.º 1
0
        /// <summary>
        /// 技能准备或释放过程中打断等
        /// </summary>
        private void OnRecvSpellFailed(MessageReceivedEvent e)
        {
            S2C_SpellFailed ret = MarshalConversion.PtrToStruct <S2C_SpellFailed>(e.MessagePtr);

            if (ret.CasterId == GameEngine.EngineInstance.LocalPlayer.CharacterID)
            {
                GameEngine.EngineInstance.LocalPlayer.OnSpellFailed(ret);

                // 隐藏进度条
                if (currentProgressBarSpellID == ret.SpellId)
                {
                    prepareProgressBar.Hide();
                }
            }
            else
            {
                RemoteCharacterController rcc = GameEngine.EngineInstance.FindCharacterController(ret.CasterId);
                if (rcc != null)
                {
                    rcc.OnSpellFailed(ret);
                }
                else
                {
                    NLogger.Instance.WriteString(LogType.Warning, string.Format("S2C_SpellFailed can not find controller UintID=[{0}]", ret.CasterId));
                }
            }
        }
Exemplo n.º 2
0
        public bool LoadFrame()
        {
            GameHelper.LoadUIForm(GUISystem.Instance.RootWindow, "content", "/ui/form/SpellPrepareForm.nui");

            prepareProgressBar = GUISystem.Instance.RootWindow.FindChild("PBSpellPrep", true) as UIProgressBar;
            prepareProgressBar.Hide();

            return(true);
        }
        private void OnAfterStop()
        {
            _startButton.Show();
            _searchGhostNodesButton.Show();
            _brokenNodesLabel.Show();
            _searchDisconnectedPtStopsButton.Show();
            _searchShortSegmentsButton.Show();
            _searchDisconnectedBuildingsButton.Show();

            _progressBar.Hide();
        }
 private void SetPos(UILabel title, UIProgressBar bar, float x, float y, bool visible)
 {
     bar.relativePosition   = new Vector3(x + 120, y - 3);
     title.relativePosition = new Vector3(x, y);
     if (visible)
     {
         bar.Show();
         title.Show();
     }
     else
     {
         bar.Hide();
         title.Hide();
     }
 }
        private void UpdateBuildingInfo(ushort buildingId, Building building)
        {
            var      levelUpHelper = LevelUpHelper3.instance;
            var      info          = building.Info;
            var      zone          = info.m_class.GetZone();
            Building data          = Singleton <BuildingManager> .instance.m_buildings.m_buffer[(int)buildingId];

            ushort[] array;
            int      num;

            Singleton <ImmaterialResourceManager> .instance.CheckLocalResources(data.m_position, out array, out num);

            double totalFactor         = 0;
            double totalNegativeFactor = 0;

            foreach (var resBar in this.resourceBars)
            {
                if (levelUpHelper.GetFactor(zone, resBar.Key) > 0)
                {
                    totalFactor += levelUpHelper.GetFactor(zone, resBar.Key);
                }
                else
                {
                    totalNegativeFactor -= levelUpHelper.GetFactor(zone, resBar.Key);
                }
            }
            totalNegativeFactor -= levelUpHelper.GetPollutionFactor(zone);

            var x         = 14f;
            var negativeX = 14f;

            foreach (var resBar in this.resourceBars)
            {
                var label  = this.resourceLabels[resBar.Key];
                var factor = levelUpHelper.GetFactor(zone, resBar.Key);
                if (factor == 0)
                {
                    label.Hide();
                    resBar.Value.Hide();
                }
                else
                {
                    label.Show();
                    resBar.Value.Show();
                    int max   = 0;
                    int raw   = 0;
                    var value = levelUpHelper.GetServiceScore(resBar.Key, zone, array, num, ref raw, ref max);

                    if (factor > 0)
                    {
                        resBar.Value.size             = new Vector2((float)(barWidth * factor / totalFactor), 16);
                        label.relativePosition        = new Vector3(x, 10);
                        resBar.Value.relativePosition = new Vector3(x, 20);
                        x += resBar.Value.size.x;
                    }
                    else
                    {
                        resBar.Value.size             = new Vector2((float)(barWidth * -factor / totalNegativeFactor), 16);
                        label.relativePosition        = new Vector3(negativeX, 56);
                        resBar.Value.relativePosition = new Vector3(negativeX, 36);
                        negativeX += resBar.Value.size.x;
                        resBar.Value.progressColor = Color.red;
                    }
                    SetProgress(resBar.Value, (float)value, 0, 100, raw, max);
                }
            }

            if (levelUpHelper.GetPollutionFactor(zone) < 0)
            {
                var value  = levelUpHelper.GetPollutionScore(data, zone);
                var factor = levelUpHelper.GetPollutionFactor(zone);

                pollutionBar.size = new Vector2((float)(barWidth * -factor / totalNegativeFactor), 16);
                pollutionLabel.relativePosition = new Vector3(negativeX, 56);
                SetProgress(pollutionBar, (float)value, 0, 100);
                pollutionBar.relativePosition = new Vector3(negativeX, 36);
                negativeX += pollutionBar.size.x;

                pollutionBar.Show();
                pollutionLabel.Show();
            }
            else
            {
                pollutionBar.Hide();
                pollutionLabel.Hide();
            }

            x = 14f;
            float y = 70f;

            SetProgress(serviceBar, levelUpHelper.GetProperServiceScore(buildingId), levelUpHelper.GetServiceThreshhold((ItemClass.Level)(Math.Max(-1, (int)data.Info.m_class.m_level - 1)), zone), levelUpHelper.GetServiceThreshhold(data.Info.m_class.m_level, zone));
            SetPos(serviceLabel, serviceBar, x, y, true);

            if (zone == ItemClass.Zone.ResidentialHigh || zone == ItemClass.Zone.ResidentialLow || zone == ItemClass.Zone.CommercialHigh || zone == ItemClass.Zone.CommercialLow)
            {
                serviceLabel.text = Localization.Get(LocalizationCategory.BuildingInfo, "LandValueProgress");
            }
            else
            {
                serviceLabel.text = Localization.Get(LocalizationCategory.BuildingInfo, "Service");
            }
            y += vertPadding;

            float education;
            float happy;
            float commute;

            levelUpHelper.GetEducationHappyScore(buildingId, out education, out happy, out commute);

            SetProgress(educationBar, education, levelUpHelper.GetEducationThreshhold((ItemClass.Level)(Math.Max(-1, (int)data.Info.m_class.m_level - 1)), zone), levelUpHelper.GetEducationThreshhold(data.Info.m_class.m_level, zone));
            SetPos(educationLabel, educationBar, x, y, true);
            y += vertPadding;


            if (zone == ItemClass.Zone.CommercialHigh || zone == ItemClass.Zone.CommercialLow)
            {
                educationLabel.text = Localization.Get(LocalizationCategory.BuildingInfo, "Wealth");
            }
            else
            {
                educationLabel.text = Localization.Get(LocalizationCategory.BuildingInfo, "Education");
            }

            SetProgress(happyBar, happy, 0, 100);
            SetPos(happyLabel, happyBar, x, y, true);
            y += vertPadding;

            descriptionButton.relativePosition = new Vector3(this.width / 2 - 40, y - 10);
            y += 12;

            if (this.baseBuildingWindow != null)
            {
                if (buildingName == null)
                {
                    this.buildingName           = this.baseBuildingWindow.Find <UITextField>("BuildingName");
                    this.buildingName.maxLength = 50;
                    this.buildingName.textScale = 0.87f;
                }
                if (buildingName != null)
                {
                    var bName = this.buildingName.text;
                    if (showName)
                    {
                        if ((data.m_flags & Building.Flags.CustomName) == Building.Flags.None && !this.buildingName.hasFocus)
                        {
                            bName = GetName(buildingId, zone, data.Info.m_class.m_subService);
                            this.buildingName.text = bName;
                        }
                    }

                    if (showDescription)
                    {
                        var desc = GetDescription(bName, buildingId, zone, data.Info.m_class.m_subService);
                        descriptionLabel.text = desc;
                        descriptionLabel.Show();
                        descriptionLabel.relativePosition = new Vector3(x, y);
                        y += descriptionLabel.height + 10;
                    }
                    else
                    {
                        descriptionLabel.Hide();
                    }
                }
            }
            height = y;
        }
 private void SetPos(UILabel title, UIProgressBar bar, float x, float y, bool visible)
 {
     bar.relativePosition = new Vector3(x + 120, y - 3);
     title.relativePosition = new Vector3(x, y);
     if (visible)
     {
         bar.Show();
         title.Show();
     }
     else
     {
         bar.Hide();
         title.Hide();
     }
 }