Esempio n. 1
0
 public static CCFactory <TFactory, TProduction> Get()
 {
     if (Instance == null)
     {
         Instance = new CCFactory <TFactory, TProduction>();
     }
     return(Instance);
 }
Esempio n. 2
0
        public override bool ReadFromINI(FileFormats.Text.INI iniFile)
        {
            if (!base.ReadFromINI(iniFile))
            {
                return(false);
            }

            iniFile.GetInteger(ID, "Spread", ref Spread);
            iniFile.GetDouble(ID, "SpreadPercentage", ref SpreadPercentage);
            iniFile.GetInteger(ID, "Growth", ref Growth);
            iniFile.GetDouble(ID, "GrowthPercentage", ref GrowthPercentage);

            iniFile.GetInteger(ID, "Value", ref Value);
            iniFile.GetInteger(ID, "Power", ref Power);

            var ImageIndex = -1;

            iniFile.GetInteger(ID, "Image", ref ImageIndex);

            var lst = CCFactory <OverlayTypeClass, OverlayClass> .Get().FactoryItems;

            switch (ImageIndex)
            {
            case -1:
                break;

            case 2:
                ImageOverlay = new Helpers.WeakRef <OverlayTypeClass>(lst[0x1B]);
                NumFrames    = NumImages = 12;
                break;

            case 3:
                ImageOverlay   = new Helpers.WeakRef <OverlayTypeClass>(lst[0x7F]);
                NumFrames      = NumImages = 12;
                NumExtraImages = 8;
                break;

            case 4:
                ImageOverlay   = new Helpers.WeakRef <OverlayTypeClass>(lst[0x93]);
                NumFrames      = NumImages = 12;
                NumExtraImages = 8;
                break;

            case 0:
            case 1:
            default:
                ImageOverlay   = new Helpers.WeakRef <OverlayTypeClass>(lst[0x66]);
                NumFrames      = NumImages = 12;
                NumExtraImages = 8;
                break;
            }

            return(true);
        }
Esempio n. 3
0
        public override void Draw(Helpers.ZBufferedTexture Texture)
        {
            var Type = GetObjectType() as OverlayTypeClass;

            if (Type.Voxel)
            {
            }
            else
            {
                var image = Type.SHPImage.Value;
                if (image != null)
                {
                    var adjust = OverlayTypeClass.PositionAdjustment(Type.ArrayIndex);

                    var cell = GetCell();

                    var h = 2 + TacticalClass.Adjust2DYTo3DZ(Location.Z);

                    var TL = TacticalClass.Instance.Position2DOnScreen(Location);// +new CellStruct(0, 30 - TacticalClass.From3DZTo2DY(Location.Z));// +adjust;

//                    Debug.WriteLine("Drawing overlay @ {0}, {1}", TL.X, TL.Y);
                    if (Type.Tiberium)
                    {
                        var ix = OverlayToTiberium(Type.ArrayIndex);
                        if (ix != -1)
                        {
                            var OTypes = CCFactory <OverlayTypeClass, OverlayClass> .Get().FactoryItems;

                            var tib = TiberiumClass.All[ix];
                            OverlayTypeClass tOverlay;
                            if (cell.Slope != 0)
                            {
                                tOverlay = OTypes[tib.NumImages + tib.NumExtraImages / 4 * (cell.Slope - 1) + tib.Overlay.ArrayIndex];
                            }
                            else
                            {
                                tOverlay = OTypes[tib.Overlay.ArrayIndex + cell.X * cell.Y % tib.NumImages];
                            }
                            tOverlay.SHPImage.Value.DrawIntoTextureBL(Texture, TL, (uint)cell.OverlayState, MapTheater.TemperatePAL, h);
                        }
                    }
                    else if (Type.Wall)
                    {
                        var tp = cell.TacticalPosition;
//                        Debug.WriteLine("Drawing overlay @ {0},{1}", tp.X, tp.Y);
                        image.DrawIntoTextureBL(Texture, TL, (uint)cell.OverlayState, MapTheater.unitPAL, h);
                    }
                    else
                    {
                        image.DrawIntoTextureBL(Texture, TL, 0, MapTheater.isoPAL, h);
                    }
                }
            }
        }
Esempio n. 4
0
        public static void LoadListFromINI(FileFormats.Text.INI iniFile)
        {
            var All = CCFactory <OverlayTypeClass, OverlayClass> .Get();

            All.FactoryItems.Clear();

            if (iniFile.SectionExists("OverlayTypes"))
            {
                foreach (var entry in iniFile.Sections["OverlayTypes"].Entries)
                {
                    var ident = entry.Value.Value;
                    All.FindOrAllocate(ident);
                }
            }
        }
Esempio n. 5
0
        internal static CellStruct PositionAdjustment(int OverlayTypeIndex)
        {
            var All = CCFactory <OverlayTypeClass, OverlayClass> .Get();

            var t = All.FactoryItems[OverlayTypeIndex];

            var xy = new CellStruct(0, 0);

            if (t.Tiberium || t.Wall || t.ArrayIndex == 126 || t.Crate)
            {
                xy.Y = -12;
            }
            if (OverlayTypeIndex == 126)
            {
                --xy.Y;
            }

            return(xy);
        }
Esempio n. 6
0
        public static int OverlayToTiberium(int OverlayTypeIndex)
        {
            if (OverlayTypeIndex == -1)
            {
                return(-1);
            }

            var over = CCFactory <OverlayTypeClass, OverlayClass> .Get().FactoryItems[OverlayTypeIndex];

            if (!over.Tiberium)
            {
                return(0);
            }

            foreach (var t in TiberiumClass.All)
            {
                var im = t.ImageOverlay.Value.ArrayIndex;
                if (OverlayTypeIndex >= im && OverlayTypeIndex < im + t.NumImages + t.NumExtraImages)
                {
                    return(t.ArrayIndex);
                }
            }
            return(0);
        }