Esempio n. 1
0
    protected void CheckNavalColorIndex()
    {
        string value = Amplitude.Unity.Framework.Application.Registry.GetValue <string>("Settings/UI/EmpireColorPalette", "Standard");
        IDatabase <Palette> database = Databases.GetDatabase <Palette>(false);
        Palette             palette  = null;

        if (database != null)
        {
            database.TryGetValue(value, out palette);
        }
        if (palette != null)
        {
            StaticString      tag = "NavalEmpire";
            XmlColorReference xmlColorReference = palette.Colors.FirstOrDefault((XmlColorReference iterator) => iterator.Tags != null && iterator.Tags.Contains(tag));
            if (xmlColorReference != null)
            {
                this.ColorIndex = Array.IndexOf <XmlColorReference>(palette.Colors, xmlColorReference);
            }
        }
    }
Esempio n. 2
0
    public override void ReadXml(XmlReader reader)
    {
        string attribute = reader.GetAttribute("FactionDescriptor");

        this.Faction = Faction.Decode(attribute);
        Faction faction;

        if (Databases.GetDatabase <Faction>(false).TryGetValue(this.Faction.Name, out faction))
        {
            MinorFaction minorFaction = faction as MinorFaction;
            if (minorFaction != null)
            {
                this.Faction = (MinorFaction)minorFaction.Clone();
            }
            NavalFaction navalFaction = faction as NavalFaction;
            if (navalFaction != null)
            {
                this.Faction = (NavalFaction)navalFaction.Clone();
            }
            KaijuFaction kaijuFaction = faction as KaijuFaction;
            if (kaijuFaction != null)
            {
                this.Faction = (KaijuFaction)kaijuFaction.Clone();
            }
        }
        this.ColorIndex = reader.GetAttribute <int>("ColorIndex");
        if (!(this is MajorEmpire))
        {
            string value = Amplitude.Unity.Framework.Application.Registry.GetValue <string>("Settings/UI/EmpireColorPalette", "Standard");
            IDatabase <Palette> database = Databases.GetDatabase <Palette>(false);
            Palette             palette  = null;
            if (database != null)
            {
                database.TryGetValue(value, out palette);
            }
            if (palette != null && palette.Colors != null)
            {
                XmlColorReference xmlColorReference = null;
                if (this is MinorEmpire || this is KaijuEmpire)
                {
                    xmlColorReference = palette.Colors.FirstOrDefault((XmlColorReference iterator) => iterator.Tags != null && iterator.Tags.Contains("MinorFaction"));
                }
                else if (this is NavalEmpire)
                {
                    xmlColorReference = palette.Colors.FirstOrDefault((XmlColorReference iterator) => iterator.Tags != null && iterator.Tags.Contains("NavalEmpire"));
                }
                else if (this is LesserEmpire)
                {
                    xmlColorReference = palette.Colors.FirstOrDefault((XmlColorReference iterator) => iterator.Tags != null && iterator.Tags.Contains("LesserEmpire"));
                }
                if (xmlColorReference != null)
                {
                    this.ColorIndex = Array.IndexOf <XmlColorReference>(palette.Colors, xmlColorReference);
                }
            }
        }
        base.ReadXml(reader);
        IDatabase <SimulationDescriptor> database2 = Databases.GetDatabase <SimulationDescriptor>(true);
        List <FactionTrait>  list = new List <FactionTrait>(Faction.EnumerableTraits(this.Faction));
        SimulationDescriptor simulationDescriptor;

        Predicate <SimulationDescriptorHolder> < > 9__3;
        for (int i = 0; i < list.Count; i++)
        {
            FactionTrait factionTrait = list[i];
            if (factionTrait != null && factionTrait.SimulationDescriptorReferences != null)
            {
                for (int j = 0; j < factionTrait.SimulationDescriptorReferences.Length; j++)
                {
                    if (database2.TryGetValue(factionTrait.SimulationDescriptorReferences[j], out simulationDescriptor))
                    {
                        List <SimulationDescriptorHolder>      descriptorHolders = base.SimulationObject.DescriptorHolders;
                        Predicate <SimulationDescriptorHolder> match2;
                        if ((match2 = < > 9__3) == null)
                        {
                            match2 = (< > 9__3 = ((SimulationDescriptorHolder match) => match.Descriptor.Name == simulationDescriptor.Name));
                        }
                        if (!descriptorHolders.Exists(match2))
                        {
                            base.SimulationObject.AddDescriptor(simulationDescriptor);
                        }
                    }
                }
            }
        }
    }