Esempio n. 1
0
        public object Convert(object value, Type targetType,
                              object parameter, System.Globalization.CultureInfo culture)
        {
            StructureSelector V = value as StructureSelector;

            return(string.Format("{0} (Label={1})", V.EclipseStructure.Id, V.EclipseStructure.LabelName));
        }
Esempio n. 2
0
        public object Convert(object[] value, Type targetType,
                              object parameter, System.Globalization.CultureInfo culture)
        {
            StructureSelector SS = (value[0] as StructureSelector);
            ObservableCollection <Ctr.EclipseStructure> AvailableStructures = value[1] as ObservableCollection <Ctr.EclipseStructure>;

            if (SS == null)
            {
                return(AvailableStructures.OrderBy(x => x.Id));
            }
            if (SS.GetAliases().Contains("PTV56"))
            {
                var debugme = "hi";
            }
            if (AvailableStructures.Count != 0)
            {
                double[] LD = new double[AvailableStructures.Count];
                for (int i = 0; i < AvailableStructures.Count; i++)
                {
                    LD[i] = double.PositiveInfinity;
                }
                int c = 0;
                foreach (string S in AvailableStructures.Select(x => x.Id))
                {
                    var CurrentId   = SS.EclipseStructure.Id.ToUpper();
                    var stripString = S.Replace(@"B_", @"").Replace(@"_", @"").ToUpper();
                    if (CurrentId == "") // if not assigned, use first alias
                    {
                        foreach (string Alias in SS.GetAliases())
                        {
                            var    CompString = Alias.Replace(@"B_", @"").Replace(@"_", @"").ToUpper();
                            double LDist      = LevenshteinDistance.Compute(stripString, CompString);
                            if (stripString.ToUpper().Contains(CompString) && stripString != "" && CompString != "")
                            {
                                LDist = Math.Min(LDist, 1.5);
                            }
                            LD[c] = Math.Min(LD[c], LDist);
                        }
                    }
                    else
                    {
                        var    CompString = CurrentId.Replace(@"B_", @"").Replace(@"_", @"").ToUpper();
                        double LDist      = LevenshteinDistance.Compute(stripString, CompString);
                        if (stripString.ToUpper().Contains(CompString) && stripString != "" && CompString != "")
                        {
                            LDist = Math.Min(LDist, 1.5);
                        }
                        LD[c] = LDist;
                    }
                    c++;
                }
                var temp = new ObservableCollection <Ctr.EclipseStructure>(AvailableStructures.Zip(LD, (s, l) => new { key = s, LD = l }).OrderBy(x => x.LD).Select(x => x.key).ToList());
                return(temp);
            }
            else
            {
                return(AvailableStructures);
            }
        }
Esempio n. 3
0
        public object ConvertBack(object value, Type targetTypes,
                                  object parameter, System.Globalization.CultureInfo culture)
        {
            StructureSelector SS = value as StructureSelector;

            if (SS != null)
            {
                return(SS);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 4
0
        public object Convert(object value, Type targetType,
                              object parameter, System.Globalization.CultureInfo culture)
        {
            StructureSelector V = value as StructureSelector;

            if (V != null)
            {
                return(Visibility.Visible);
            }
            else
            {
                return(Visibility.Hidden);
            }
        }
Esempio n. 5
0
    private void ProgressBarUpdate()
    {
        progCounter += Time.deltaTime * 0.5f;
        if (progCounter > progTime)
        {
            progCounter = 0;

            ProgressBar.GetComponent <UISlider>().value += (float)(Time.deltaTime / buildingTime);                                      //update progress bars values

            ProgressBar.GetComponent <UISlider>().value =
                Mathf.Clamp(ProgressBar.GetComponent <UISlider>().value, 0, 1);

            remainingTime = (int)(buildingTime * (1 - ((UISlider)ProgressBar.GetComponent("UISlider")).value));

            UpdatePrice(remainingTime);
            UpdateTimeCounter(remainingTime);

            if (((UISlider)ProgressBar.GetComponent("UISlider")).value == 1)                                    //building finished - the progress bar has reached 1
            {
                ((SoundFX)soundFX).BuildingFinished();

                if (!battleMap)                                                                                                                                 //if this building is not finished on a battle map
                {
                    //xml order: Forge Generator Vault Barrel Summon Tatami
                    ((Stats)stats).occupiedDobbits--;                                                                                           //the dobbit previously assigned becomes available

                    if (structureType == "Toolhouse")                                                                                           //increases total storage in Stats
                    {
                        ((Stats)stats).dobbits += 1;
                    }
                    else if (structureType == "Tatami")                                                                                         //increases total storage in Stats
                    {
                        ((Stats)stats).maxHousing += storageAdd;
                    }
                    else if (structureType == "Forge")
                    {
                        isProductionBuilding = true;                                            //((Stats)stats).maxGold += storageAdd;
                    }
                    else if (structureType == "Generator")
                    {
                        isProductionBuilding = true;                                            //((Stats)stats).maxMana += storageAdd;
                    }

                    else if (structureType == "Barrel")                                                                                         //increases total storage in Stats
                    {
                        ((Stats)stats).maxMana += storageAdd;
                    }
                    else if (structureType == "Vault")
                    {
                        ((Stats)stats).maxGold += storageAdd;
                    }

                    ((Stats)stats).UpdateUI();
                }

                foreach (Transform child in transform)                         //parenting and destruction of components no longer needed
                {
                    if (child.gameObject.tag == "Structure")                   //structureType
                    {
                        child.gameObject.SetActive(true);

                        StructureSelector structureSelector = ((StructureSelector)child.gameObject.GetComponent("StructureSelector"));
                        structureSelector.inConstruction = false;

                        if (battleMap)
                        {
                            structureSelector.battleMap = true;
                        }
                        else if (isProductionBuilding)
                        {
                            structureSelector.structureType        = structureType;
                            structureSelector.isProductionBuilding = true;

                            structureSelector.LateRegisterAsProductionBuilding();                             //0.5f

                            if (finishedOffLine)
                            {
                                structureSelector.LateCalculateElapsedProduction(elapsedTime);                                 //1.0f
                            }



                            /*
                             * MessageNotification m = child.GetComponent<MessageNotification> ();
                             * m.structureIndex = constructionIndex;
                             * (ResourceGenerator.InstanceResourceGenerator.RegisterMessageNotification (m);
                             */
                        }
                        foreach (Transform childx in transform)
                        {
                            if (childx.gameObject.tag == "Grass")
                            {
                                childx.gameObject.transform.parent = child.gameObject.transform;
                                child.gameObject.transform.parent  = ParentGroup.transform;

                                break;
                            }
                        }
                        break;
                    }
                }

                Destroy(this.gameObject);
                inConstruction = false;
            }
        }
    }