示例#1
0
        async public void Load(string fileName)
        {
            Persistent.SakuraContext context = new Persistent.SakuraContext(fileName);
            context.Database.EnsureCreated();
            var items = await context.Items.ToListAsync();

            var morphs = await context.Morphs.ToListAsync();

            var messages = await context.Messages.ToListAsync();

            Items.Clear();
            Morphs.Clear();
            Messages.Clear();

            morphs.ForEach(x => {
                var model = new MorphModel();
                Migrate(x, model);
                Morphs.Add(model);
            });


            items.ForEach(x => {
                var model = new ItemModel();
                Migrate(x, model);
                Items.Add(model);
            });

            messages.ForEach(x => {
                var model = new MessageModel();
                Migrate(x, model);
                Messages.Add(model);
            });
        }
示例#2
0
        public GroupMorphProvider(PMXModel model, IMorphManager morph)
        {
            this.morphManager = morph;
            int i = 0;

            foreach (MorphData morphData in model.Model.MorphList.Morphes)
            {
                if (morphData.type == MorphType.Group)
                {
                    Morphs.Add(morphData.MorphName, new GroupMorphData(morphData));
                }
                morphNameList.Add(i, morphData.MorphName);
                i++;
            }
        }
示例#3
0
        private void createEntity(EntityItem entity)
        {
            Line        line;
            float       w, h;
            Collectable collectable;
            Box         box;

            EntityItem next = null;

            if (!GroupedEntities.ContainsKey(entity.Group))
            {
                GroupedEntities.Add(entity.Group, new List <EntityItem>());
            }
            GroupedEntities[entity.Group].Add(entity);

            Vector4 color   = new Vector4(1.0f, 1.0f, 0.0f, 0.2f);
            float   boxSize = 0;

            collectable = null;

            if (entity.NextID != 0 && Data.Entities.ContainsKey(entity.NextID))
            {
                next = Data.Entities.GetValue(entity.NextID);
            }

            switch (entity.GameType)
            {
            case EntityItem.EntityType.WaypointAmmo:
            case EntityItem.EntityType.WaypointFuel:
            case EntityItem.EntityType.WaypointShield:
            case EntityItem.EntityType.WaypointShortcut:
            case EntityItem.EntityType.WaypointSpecial1:
            case EntityItem.EntityType.WaypointSpecial2:
            case EntityItem.EntityType.WaypointSpecial3:
            case EntityItem.EntityType.WaypointFast:
            case EntityItem.EntityType.WaypointSlow:
                color = new Vector4(0.1f, 0.1f, 1.0f, 1.0f);
                //boxSize = 0.04f;
                if (next != null)
                {
                    line      = new Line(entity.Center, next.Center, color);
                    line.Name = "Waypoint line " + entity.ID + " to " + next.ID;
                    WaypointLines.AddNode(line);
                }
                break;

            case EntityItem.EntityType.WallSegment:
                color = new Vector4(1.0f, 0.0f, 0.0f, 1.0f);
                if (next != null)
                {
                    line      = new Line(entity.Center + Vector3.UnitY, next.Center + Vector3.UnitY, color);
                    line.Name = "Wall segment line " + entity.ID + " to " + next.ID;
                    WallLines.AddNode(line);
                }
                break;

            case EntityItem.EntityType.TriggerCraft:
            case EntityItem.EntityType.TriggerRocket:
                w            = entity.OffsetX + 1f;
                h            = entity.OffsetY + 1f;
                box          = new Box(0, 0, 0, w, 2, h, new Vector4(0.9f, 0.3f, 0.6f, 0.5f));
                box.Position = entity.Pos + Vector3.UnitY * 0.01f;
                Entities.AddNode(box);
                break;

            case EntityItem.EntityType.TriggerTimed:
                Billboard timer = new Billboard("images/stopwatch.png", 0.4f, 0.4f);
                timer.Position = entity.Center;
                Entities.AddNode(timer);
                break;


            case EntityItem.EntityType.MorphOnce:
            case EntityItem.EntityType.MorphPermanent:
                w = entity.OffsetX + 1f;
                h = entity.OffsetY + 1f;
                //box = new Box(0, 0, 0, w, 1, h, new Vector4(0.1f, 0.3f, 0.9f, 0.5f));
                //box.Position = entity.Pos + Vector3.UnitY * 0.01f;
                //AddNode(box);

                EntityItem source = Data.Entities.GetValue(entity.NextID);

                // morph for this entity and its linked source
                List <Column> targetColumns = ColumnsInRange((int)entity.Pos.X, (int)entity.Pos.Z, w, h);
                List <Column> sourceColumns = ColumnsInRange((int)source.Pos.X, (int)source.Pos.Z, w, h);

                // regular morph
                if (targetColumns.Count == sourceColumns.Count)
                {
                    for (int i = 0; i < targetColumns.Count; i++)
                    {
                        targetColumns[i].MorphSource = sourceColumns[i];
                        sourceColumns[i].MorphSource = targetColumns[i];
                    }
                }
                else
                {
                    // permanent morphs dont destroy buildings, instead they morph the column based on terrain height
                    if (entity.GameType == EntityItem.EntityType.MorphPermanent)
                    {
                        // we need to update surrounding columns too because they could be affected (one side of them)
                        // (problem comes from not using terrain height for all columns in realtime)
                        targetColumns = ColumnsInRange((int)entity.Pos.X - 1, (int)entity.Pos.Z - 1, w + 1, h + 1);

                        // create dummy morph source columns at source position
                        foreach (Column column in targetColumns)
                        {
                            Vector3 colPos = new Vector3(source.Pos.X + (column.Position.X - entity.Pos.X), 0, source.Pos.Z + (column.Position.Z - entity.Pos.Z));
                            column.MorphSource = new Column(column.Definition, colPos, Data, Atlas);
                        }

                        sourceColumns.Clear();
                    }
                    else
                    {
                        // in this case (MorphOnce) there are no target columns and
                        // (target and source areas are swapped from game perspective)
                        // and buildings have to be destroyed as soon as the morph starts
                        foreach (Column column in sourceColumns)
                        {
                            column.DestroyOnMorph = true;
                        }
                        foreach (Column column in targetColumns)
                        {
                            column.DestroyOnMorph = true;
                        }
                    }
                }

                // create and collect morph instances
                Morph morph = new Morph(source, entity, (int)w, (int)h, entity.GameType == EntityItem.EntityType.MorphPermanent);
                morph.Columns.AddRange(targetColumns);
                Morphs.Add(morph);

                // source
                morph = new Morph(entity, source, (int)w, (int)h, entity.GameType == EntityItem.EntityType.MorphPermanent);
                morph.Columns.AddRange(sourceColumns);
                Morphs.Add(morph);
                break;

            case EntityItem.EntityType.MorphSource1:
            case EntityItem.EntityType.MorphSource2:
                // no need to display morph sources since they are handled above by their targets
                break;

            case EntityItem.EntityType.RecoveryTruck:
                Craft recov = new Craft("RECOV0-0", entity.Center + Vector3.UnitY * 6f);
                Entities.AddNode(recov);
                break;

            case EntityItem.EntityType.Cone:
                Cone cone = new Cone(entity.X + 0.5f, entity.Y + 0.104f, entity.Z + 0.5f);
                Entities.AddNode(cone);
                break;

            case EntityItem.EntityType.Checkpoint:
                color     = new Vector4(1.0f, 0.0f, 1.0f, 1.0f);
                line      = new Line(entity.Center, entity.Center + new Vector3(entity.OffsetX, 0, entity.OffsetY), color);
                line.Name = "Checkpoint line " + entity.ID;
                Entities.AddNode(line);
                break;

            case EntityItem.EntityType.Explosion:
                BillboardAnimation explosion = new BillboardAnimation("images/tmaps/explosion.png", 1f, 1f, 88, 74, 10);

                explosion.Position = entity.Center;
                Entities.AddNode(explosion);
                break;

            case EntityItem.EntityType.ExtraFuel:
                collectable = new Collectable(29);
                break;

            case EntityItem.EntityType.FuelFull:
                collectable = new Collectable(30);
                break;

            case EntityItem.EntityType.DoubleFuel:
                collectable = new Collectable(31);
                break;

            case EntityItem.EntityType.ExtraAmmo:
                collectable = new Collectable(32);
                break;

            case EntityItem.EntityType.AmmoFull:
                collectable = new Collectable(33);
                break;

            case EntityItem.EntityType.DoubleAmmo:
                collectable = new Collectable(34);
                break;

            case EntityItem.EntityType.ExtraShield:
                collectable = new Collectable(35);
                break;

            case EntityItem.EntityType.ShieldFull:
                collectable = new Collectable(36);
                break;

            case EntityItem.EntityType.DoubleShield:
                collectable = new Collectable(37);
                break;

            case EntityItem.EntityType.BoosterUpgrade:
                collectable = new Collectable(40);
                break;

            case EntityItem.EntityType.MissileUpgrade:
                collectable = new Collectable(39);
                break;

            case EntityItem.EntityType.MinigunUpgrade:
                collectable = new Collectable(38);
                break;

            case EntityItem.EntityType.UnknownShieldItem:
                collectable = new Collectable(41);
                break;

            case EntityItem.EntityType.UnknownItem:
            case EntityItem.EntityType.Unknown:
                collectable = new Collectable(50);
                break;

            default:
                boxSize = 0.98f;
                break;
            }

            if (collectable != null)
            {
                collectable.Position = entity.Center;
                Entities.AddNode(collectable);
            }

            if (boxSize > 0f)
            {
                box = new Box(boxSize, entity.Center - 0.5f * boxSize * Vector3.One, color);
                Entities.AddNode(box);
            }
        }