public void SetArchetype(Archetype archetype)
 {
     CurrentArchetype = archetype;
     Tag = archetype;
     UpdateFormTitle();
     UpdateControls();
 }
Esempio n. 2
0
 private void GetPreviewSlots(Archetype archetype)
 {
     foreach (var slot in archetype.PreviewSlots)
     {
         PreviewSlots.Add(new BCMSlot(slot));
     }
     Bin.Add("PreviewSlots", PreviewSlots);
 }
Esempio n. 3
0
 private void GetBaseSlots(Archetype archetype)
 {
     foreach (var slot in archetype.BaseSlots)
     {
         BaseSlots.Add(new BCMSlot(slot));
     }
     Bin.Add("BaseSlots", BaseSlots);
 }
Esempio n. 4
0
        /// <summary>
        /// Add an adjacent room in the specified direction
        /// </summary>
        /// <param name="dir"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public Section AddAdjRoom(AdjDirection dir, Archetype type = Archetype.normal)
        {
            Vector2 direction = CalcDirection(dir, flipped);
            Section adj       = Create((Vector2)transform.position + direction, !flipped, type);

            SetAdjRoom(dir, adj);
            return(adj);
        }
        private Card _getPendulumMonsterCard(Archetype archetype, string type)
        {
            var pendulumMonsterCard = _getMonsterCard(archetype, type);

            pendulumMonsterCard.MonsterCard.PendulumMonsterCard = _helper.GetPendulumMonsterCard(pendulumMonsterCard.MonsterCard);

            return(pendulumMonsterCard);
        }
        public async Task <Archetype> Add(Archetype archetype)
        {
            await _dbContext.Archetype.AddAsync(archetype);

            await _dbContext.SaveChangesAsync();

            return(archetype);
        }
        public async Task <Archetype> Update(Archetype archetype)
        {
            _dbContext.Archetype.Update(archetype);

            await _dbContext.SaveChangesAsync();

            return(archetype);
        }
Esempio n. 8
0
        // Constructors
        ///////////////////////////

        public EntityIndex()
        {
            root       = new Archetype(new EntityType());
            archetypes = new List <Archetype>();
            index      = SparseEntitySet <Record>();
            dataTypes  = SparseEntitySet <Type>();
            archetypes.Add(root);
        }
Esempio n. 9
0
        private void AddArchetypeButton_Click(object sender, EventArgs e)
        {
            var archetype = new Archetype("Untitled Archetype");

            EditingProject.Archetypes.Add(archetype);
            EditingProject.MarkDirty();
            RefreshArchetypeControls(archetype);
        }
Esempio n. 10
0
        /// <summary>
        /// Add an adjacent room in the specified direction
        /// </summary>
        /// <param name="dir"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public Section addAdjRoom(AdjDirection dir, Archetype type = Archetype.normal)
        {
            Vector2 direction = getDirection(dir);
            Section adj       = create((Vector2)transform.position + direction, type);

            setAdjRoom(dir, adj);
            return(adj);
        }
Esempio n. 11
0
        public static Section create(Region set, Vector2 position, Archetype type = Archetype.normal)
        {
            Section r = create(position, type);

            r.set = set;
            r.transform.SetParent(set.transform, true);
            return(r);
        }
Esempio n. 12
0
 private void GetDna(Archetype archetype)
 {
     foreach (var dna in archetype.Dna.Names)
     {
         Dna.Add(dna, Math.Round(archetype.Dna.GetValue(dna), 3));
     }
     Bin.Add("Dna", Dna);
 }
Esempio n. 13
0
        public void FillPrimaryCombo(Archetype selectedArchetype)
        {
            List <IPowerset> powersets = Array.FindAll(DatabaseAPI.Database.Powersets, p => p.SetType == Enums.ePowerSetType.Primary && p.ATClass.Equals(selectedArchetype.ClassName)).ToList();

            cbPrimary.DisplayMember = "DisplayName";
            cbPrimary.ValueMember   = null;
            cbPrimary.DataSource    = powersets;
            cbPrimary.SelectedIndex = 0;
        }
Esempio n. 14
0
        [TestMethod] public void IsSameContentTest()
        {
            var x = Period.Random();
            var y = Period.Random();
            var z = Archetype.Clone(x);

            Assert.IsFalse(x.IsSameContent(y));
            Assert.IsTrue(x.IsSameContent(z));
        }
Esempio n. 15
0
        /// <summary>
        /// Creates an item from an Archetype and a tag.
        /// The item to be created is random, as long as it shares the correct tag.
        /// </summary>
        /// <param name="archetype"></param>
        /// <param name="tag"></param>
        /// <param name="itemID">The id of the chosen item</param>
        /// <returns></returns>
        public MapItem CreateItem(Archetype archetype, string tag,out int itemID)
        {
            int id = DatabaseHandling.GetItemIdFromTag(archetype, tag);

            itemID = id;

            //Now get the actual item
            return this.CreateItem(archetype.ToString().ToLower(), id);
        }
Esempio n. 16
0
        [TestMethod] public void IsSameContentStaticTest()
        {
            var x = Period.Random();
            var y = Period.Random();
            var z = Archetype.Clone(x);

            Assert.IsFalse(Common.IsSameContent(x, y));
            Assert.IsTrue(Common.IsSameContent(x, z));
        }
Esempio n. 17
0
        public override bool ValidValue(object aValue)
        {
            Check.Require(aValue != null, string.Format(CommonStrings.XMustNotBeNull, "aValue"));

            CComplexObject rootDefinition = AmFactory.GetRootDefinition(this);

            CObject cObjAtTargetPath = Archetype.GetCObjectAtTargetPath(rootDefinition, this.TargetPath);

            return(cObjAtTargetPath.ValidValue(aValue));
        }
 /// <inheritdoc />
 public ConcreteArchetypeDTO Convert(Archetype archetype)
 {
     return(new ConcreteArchetypeDTO(
                id: archetype.Id,
                name: archetype.Name,
                isPureArchetype: archetype.IsPureArchetype,
                cardsInArchetype: _decksFactory.CreateDeckDto(archetype.Cards),
                statistics: Convert(archetype.Statistics)
                ));
 }
        private void _addToDecklistSpellAndTrapMonster(Archetype archetype, Decklist decklist)
        {
            decklist.MainDeck.Add(
                _helper.GetCard(archetype, "Spell Card")
                );

            decklist.MainDeck.Add(
                _helper.GetCard(archetype, "Trap Card")
                );
        }
Esempio n. 20
0
        public static Dictionary<int, List<string>> GetDatabase(Archetype archetype)
        {
            //Get's a particular archetype's worth of data
            if (!dictionary.Keys.Contains(archetype))
            {
                ReadTableIntoMemory(archetype);
            }

            return dictionary[archetype];
        }
Esempio n. 21
0
 public RaycastSystem(Engine engine)
 {
     meshManager = engine.meshManager;
     colliders   = engine.EntityManager.NewArchetype()
                   .WithComponentData <Collider>()
                   //.WithComponentData<RenderEnabledBit>()
                   .WithComponentData <MeshRenderer>()
                   .WithComponentData <LocalToWorld>()
                   .WithComponentData <WorldMeshBounds>();
 }
 public static ArchetypeSearchOutputModel From(Archetype entity)
 {
     return(new ArchetypeSearchOutputModel
     {
         Id = entity.Id,
         Name = entity.Name,
         ThumbnailUrl = GetThumbnailUrl(entity.Id),
         Updated = entity.Updated
     });
 }
Esempio n. 23
0
        protected void ValidateArchetype(Archetype archetype)
        {
            this.Validate((AuthoredResource)archetype);

            Invariant(archetype.ArchetypeId != null, string.Format(
                          CommonStrings.XMustNotBeNull, "Archetype.ArchetypeId"));
            this.Validate(archetype.ArchetypeId);

            Invariant(archetype.Ontology.HasTermCode(archetype.Definition.NodeId),
                      AmValidationStrings.OntologyMissingDefinitionTerm);
            Invariant(archetype.Uid == null || !string.IsNullOrEmpty(archetype.Uid.Value),
                      string.Format(CommonStrings.IfXIsNotNullMustBeEmpty, "Archetype.Uid"));
            if (archetype.Uid != null)
            {
                this.Validate(archetype.Uid);
            }

            Invariant(!string.IsNullOrEmpty(archetype.Concept),
                      string.Format(CommonStrings.XMustNotBeNullOrEmpty, "Archetype.Concept"));

            if (archetype.ParentArchetypeId != null)
            {
                this.Validate(archetype.ParentArchetypeId);
            }

            Invariant(archetype.Version() != null, string.Format(CommonStrings.XMustNotBeNull, "Archetype.Version()"));
            Invariant(archetype.Version() == archetype.ArchetypeId.VersionId, AmValidationStrings.ArchetypeVersionNotEqual);

            Invariant(archetype.OriginalLanguage != null,
                      string.Format(CommonStrings.XMustNotBeNull, "Archetype.OriginalLanguage"));
            this.Validate(archetype.OriginalLanguage);

            Invariant(archetype.Description != null,
                      string.Format(CommonStrings.XMustNotBeNull, "Archetype.Description"));

            Invariant(archetype.Definition != null,
                      string.Format(CommonStrings.XMustNotBeNull, "Archetype.Definition"));
            this.Validate(archetype.Definition);

            Invariant(archetype.Ontology != null, "Archetype.Ontology must not be null.");
            this.Validate(archetype.Ontology);

            Invariant(!archetype.IsSpecialised() ^ (archetype.IsSpecialised() && archetype.SpecialisationDepth() > 0),
                      AmValidationStrings.ArchetypeSpecialisationInvariantFail);

            Invariant(archetype.Invariants == null || !archetype.Invariants.IsEmpty(),
                      string.Format(CommonStrings.IfXIsNotNullMustBeEmpty, "Archetype.Invariants"));
            if (archetype.Invariants != null)
            {
                foreach (Assertion eachInvariant in archetype.Invariants)
                {
                    this.Validate(eachInvariant);
                }
            }
        }
Esempio n. 24
0
        public async Task Given_An_Archetype_Should_Invoke_Add_Method_Once()
        {
            // Arrange
            var archetype = new Archetype();

            // Act
            await _sut.Add(archetype);

            // Assert
            await _archetypeRepository.Received(1).Add(Arg.Is(archetype));
        }
Esempio n. 25
0
 /// <summary>
 /// Saves an archetype to the archetype repository. An existing archetype will not be updated, you should save the archetype as a new version.
 /// </summary>
 /// <param name="archetype">The object form of the archetype.</param>
 public void Save(Archetype archetype)
 {
     if (!_archetypeRepository.Contains(archetype))
     {
         _archetypeRepository.Save(archetype);
     }
     else
     {
         throw new ArgumentException(string.Format("Archetype with id '{0}' already exist. Provide another version for this archetype.", archetype.Id), "archetype");
     }
 }
        private Decklist _getDecklistWithCards()
        {
            var archetype = new Archetype("ValidArchetype", false);
            var decklist  = _helper.GetValidDecklistWithStatistics(archetype);

            _addToDecklistSpellAndTrapMonster(archetype, decklist);
            _addToDecklistNonPendulumOrLinkMonsters(archetype, decklist);
            _addToDecklistPendulumMonsters(archetype, decklist);

            return(decklist);
        }
Esempio n. 27
0
 public static Good FindGoodByArchetype(Archetype ship_arch)
 {
     foreach (Good good in Goods.Values)
     {
         if (good.EquipmentOrShipArch == ship_arch)
         {
             return(good);
         }
     }
     return(null);
 }
Esempio n. 28
0
 public IEnumerable <string> GetPreferredMaterials()
 {
     foreach (var material in Archetype.GetPreferredMaterials())
     {
         yield return(material);
     }
     foreach (var material in Domains.SelectMany(d => d.GetPreferredMaterials()))
     {
         yield return(material);
     }
 }
Esempio n. 29
0
// Internal methods
///////////////////////////

    static ComponentArray GetDataSet(this Archetype a, EntityId component, Type dataType)
    {
        if (a.data.Has(component))
        {
            return(a.data.Get(component));
        }
        var arrayType      = typeof(ComponentArray <>).MakeGenericType(new Type[] { dataType });
        var componentArray = (ComponentArray)Activator.CreateInstance(arrayType);

        a.data.Add(component, componentArray);
        return(componentArray);
    }
Esempio n. 30
0
    public void OnEvent(IEvent e)
    {
        switch (e)
        {
        case WentDownStairs down:
            if (!FavorPerTeam.ContainsKey(down.Agent.Team))
            {
                FavorPerTeam[down.Agent.Team] = 0;
            }
            FavorPerTeam[down.Agent.Team] -= 5;
            break;

        case UsedItem used:
            foreach (var material in GetPreferredMaterials())
            {
                var wasGood = used.PreviousItem?.MadeOf == material;
                var good    = used.Item?.MadeOf == material;
                if (good && !wasGood)
                {
                    Like(e.Level, used.Agent, $"your {material} {used.Item.DisplayName}");
                }
                else if (!good && wasGood)
                {
                    Dislike(e.Level, used.Agent, $"your non-{material} {used.Item.DisplayName}");
                }
            }
            break;
        }

        Archetype.OnEvent(this, e);
        foreach (var domain in Domains)
        {
            domain.OnEvent(this, e);
        }

        if (e is NextTurn turn)
        {
            if (FavorPerTeam[turn.Player.Team] < 0)
            {
                if (Globals.Random.Next(200) < -FavorPerTeam[turn.Player.Team])
                {
                    FavorCheck(e.Level, turn.Player);
                }
            }
            else
            {
                if (Globals.Random.Next(200) < FavorPerTeam[turn.Player.Team])
                {
                    FavorCheck(e.Level, turn.Player);
                }
            }
        }
    }
Esempio n. 31
0
        public bool IsArchetype(Archetype archetype)
        {
            foreach (var type in archetype.types)
            {
                if (!components.ContainsKey(type))
                {
                    return(false);
                }
            }

            return(true);
        }
 public GameObject(Archetype arch, ResourceManager res, bool draw = true, bool staticpos = false)
 {
     isstatic = staticpos;
     if (arch is Archs.Sun)
     {
         RenderComponent = new SunRenderer((Archs.Sun)arch);
     }
     else
     {
         InitWithDrawable(arch.ModelFile.LoadFile(res), res, draw, staticpos);
     }
 }
Esempio n. 33
0
        /// <summary>
        /// Gets the id of an item randomly belonging to a particular archetype and having the right tag
        /// If unable to find anything, will throw an exception
        /// </summary>
        /// <param name="archetype">The archetype to search in</param>
        /// <param name="tag">The tag to look for</param>
        /// <returns></returns>
        public static int GetItemIdFromTag(Archetype archetype, string tag)
        {
            //Get all the data belonging to the archetype

            if (!dictionary.Keys.Contains(archetype))
            {
                ReadTableIntoMemory(archetype);
            }

            //Now go through the values of the dictionary and pick out those who have that tag
            //Tags will be the last one
            int[] items = null;

            if (archetype == Archetype.MUNDANEITEMS)
            {
                //Multiply by the amount of graphics they have. If they have more than one graphic, they must appear multiple times
                items = dictionary[archetype].Values.Where(v => v[v.Count - 1].ToLower().Split(',').Contains(tag.ToLower())).SelectMany(v => Enumerable.Repeat(Int32.Parse(v[0]),v[3].Split(',').Length > 0 ? v[3].Split(',').Length : 1)).ToArray();
            }
            else if (archetype == Archetype.ENEMIES)
            {
                items = dictionary[archetype].Values.Where(v => v[5].ToLower().Split(',').Contains(tag.ToLower())).Select(v => Int32.Parse(v[0])).ToArray();
            }
            else if (archetype == Archetype.INVENTORYITEMS)
            {
                items = dictionary[archetype].Values.Where(v => v[9].ToLower().Split(',').Contains(tag.ToLower())).Select(v => Int32.Parse(v[0])).ToArray();
            }
            else if (archetype == Archetype.ANIMALS)
            {
                items = dictionary[archetype].Values.Where(v => v[2].ToLower().Split(',').Contains(tag.ToLower())).Select(v => Int32.Parse(v[0])).ToArray();
            }
            else
            {
                items = dictionary[archetype].Values.Where(v => v[v.Count - 1].ToLower().Split(',').Contains(tag.ToLower())).Select(v => Int32.Parse(v[0])).ToArray();
            }

            //do we have at least one?
            if (items.Length == 0)
            {
                throw new Exception("No item with the selected tag was found");
            }

            //do we have one?
            if (items.Length == 1)
            {
                return items[0];
            }

            //otherwise pick one at random to return
            int id = _random.Next(items.Length);

            return items[id];
        }
Esempio n. 34
0
File: Obj.cs Progetto: sglasby/HRAOS
    public Obj(Archetype _arch_, string _tag_, int _ID_)
    {
        // Null archetype is uncommon, but valid -- verify this is still true, is there a reasonable use for an Obj with null archetype?
        // Null tag is common, and valid (tag.get returns implicit composed tag...)
        register(_ID_);
        archetype = _arch_;
        tag       = _tag_;
        autotag   = String.Format("{0}-{1}", "OBJ", ID);  // Likely move this into the autotag.get block...performance/memory to do it on demand versus here???

        ObjectRegistrar.All.register_tag(autotag, ID);
        if (tag != null) {
            ObjectRegistrar.All.register_tag(tag, ID);
        }

        fields = new Dictionary<string, IObjField>();  // Starts with zero fields
    }
    void Initialize(Archetype arch, Weapons wep)
    {
        //sets up player based on chosen class
        initialized = true;
        equippedWeapon = wep;
        playerArchetype = arch;

        switch (playerArchetype) {

        case Archetype.VIN :
            name = "Vin Tekiel";
            className = "The Street Urchin";

            mHealth = 85f; //baseline 100
            mStamina = 100f; //baseline 100

            weight = 50f; //baseline 75
            skill = 100f; //baseline 100
            strength = 70f;
            ability = 90f;
            break;

        case Archetype.VIN2 :
            name = "Vin Venture";
            className = "The Shard of Preservation";

            mHealth = 50f; //baseline 100
            mStamina = 150f; //baseline 100

            weight = 60f; //baseline 75
            skill = 110f; //baseline 100
            strength = 80f;
            ability = 120f;

            break;
        case Archetype.KELSIER :
            name = "Kelsier";
            className = "The Survivor of Hathsin";

            mHealth = 110f; //baseline 100
            mStamina = 75f; //baseline 100

            weight = 75f; //baseline 75
            skill = 110f; //baseline 100
            strength = 100f;
            ability = 100f;
            break;

        case Archetype.WAX :
            break;
        case Archetype.INQUISITOR :
            name = "Steel Inquisitor";
            className = "The Harbinger of Ruin";

            mHealth = 150f; //baseline 100
            mStamina = 50f; //baseline 100

            weight = 100f; //baseline 75
            skill = 65f; //baseline 100
            strength = 110f;
            ability = 100f;
            break;

        }
        switch (equippedWeapon)
        {
        case Weapons.DAGGERS:
            weaponName = "Obsidian Daggers";
            range = 1f;
            attackSpeed = 4.5f;
            baseDamage = 5f;
            critChance = 2f;
            bleedChance = 5f;
            minRange = 0f;
            break;
        case Weapons.CANE:
            weaponName = "Dueling Cane";
            range = 2f;
            attackSpeed = 2.75f;
            baseDamage = 7.5f;
            critChance = 2f;
            bleedChance = 1f;
            minRange = 0f;
            break;
        case Weapons.SPEAR:
            weaponName = "Obsidian Spear";
            range = 3f;
            attackSpeed = 2.25f;
            baseDamage = 10f;
            critChance = 3.5f;
            bleedChance = 5f;
            minRange = 1f;
            break;
        case Weapons.VINDICATION:
            weaponName = "Vindication Revolver";
            range = 10f;
            attackSpeed = 1.5f;
            baseDamage = 20f;
            critChance = 10f;
            bleedChance = 75f;
            minRange = 2f;
            break;
        case Weapons.STERRION:
            weaponName = "Sterrion Revolvers";
            range = 6.5f;
            attackSpeed = 2f;
            baseDamage = 10f;
            critChance = 2.5f;
            bleedChance = 5f;
            minRange = 1f;
            break;

        }
        health = mHealth;
        stamina = mStamina;
        initialized = true;
        Debug.Log (className + " is initialized!");
    }
Esempio n. 36
0
    void OnShown(object sender, EventArgs ee)
    {
        // Note: Events are fired in the order (Load, Activated, Shown),
        //     It is said that using a MessageBox() can perturb the order of these events,
        //     causing Shown to occur before Load.
        //     http://stackoverflow.com/questions/3070163/order-of-form-load-form-shown-and-form-activated-events
        //     It is also said that "depending on the order of events fired" is undesirable / bad style;
        //     so perhaps once I understand what the idiomatic alternative would be,
        //     this should be changed.
        //
        // To call any GL methods (such as setting the GL Viewport, or loading textures)
        // the OpenGL system must be initialized, which occurs upon the 'Load' event
        // firing for a Form which contains a GLControl.
        //     http://www.opentk.com/doc/chapter/2/glcontrol
        //     See also, regarding OpenTK.Graphics.GraphicsContext:
        //         http://www.opentk.com/book/export/html/140
        //
        // For this reason, the GL setup, and GL texture loading (via TileSheet constructor calls)
        // code has been moved here, in a method we set up to be called upon the 'Shown' event
        // (which is fired upon the first display of this Form).

        ts = new TileSheet(16, 16, NEW_OBJID,
            @"media/tiles/U4.B_enhanced-32x32.png");

        f1234 = new TileSheet(4, 9, 32, 32, 1, 1, 1, 1, NEW_OBJID,
            @"media/tiles/example_all_facings.4_frames.intra_1.png");

        f1234_stack = new TileSheet(1, 9, 32, 32, 1, 1, 1, 1, NEW_OBJID,
            @"media/tiles/example_all_facings.stacked/example_all_facings.intra_1.frame_1.png",
            @"media/tiles/example_all_facings.stacked/example_all_facings.intra_1.frame_2.png",
            @"media/tiles/example_all_facings.stacked/example_all_facings.intra_1.frame_3.png",
            @"media/tiles/example_all_facings.stacked/example_all_facings.intra_1.frame_4.png");

        wp_ts = new TileSheet(4, 1, NEW_OBJID,
            @"media/tiles/whirlpool_bright.png");

        wp_stack_ts = new TileSheet(1, 1, NEW_OBJID,
            @"media/tiles/whirlpool.stacked/whirlpool_1.png",
            @"media/tiles/whirlpool.stacked/whirlpool_2.png",
            @"media/tiles/whirlpool.stacked/whirlpool_3.png",
            @"media/tiles/whirlpool.stacked/whirlpool_4.png");

        creatures_stack = new TileSheet(4, 7, NEW_OBJID,
            @"media/tiles/creatures.stacked/creatures.frame_1.png",
            @"media/tiles/creatures.stacked/creatures.frame_2.png",
            @"media/tiles/creatures.stacked/creatures.frame_3.png",
            @"media/tiles/creatures.stacked/creatures.frame_4.png");

        //string[] empty_file_names_list = { };
        //TileSheet null_filenames_ts       = new TileSheet(4, 4, NEW_OBJID, null                 );  // Will throw an exception
        //TileSheet empty_filenames_list_ts = new TileSheet(4, 4, NEW_OBJID, empty_file_names_list);  // Will throw an exception

        TileSprite anim_blue_wiz = new TileSprite(ts, NEW_OBJID, 32, 33);
        TileSprite anim_red_wiz  = new TileSprite(ts, NEW_OBJID, 224, 225, 226, 227);

        // Counters for 3 frames (A,B,C) and for 4 frames (1,2,3,4)
        // This illustrates why the master frame cycle need be the Least Common Multiple of (3,4)
        // (or whatever other set of ITileSprite.num_frames values).
        TileSprite count_ABC     = new TileSprite(ts, NEW_OBJID, 96, 97, 98);  //ts[0, 6], ts[1, 6], ts[2, 6]);
        TileSprite count_1234    = new TileSprite(f1234_stack, NEW_OBJID, 0, 9 + 0, 18 + 0, 27 + 0);  // Same as count_1234, but frames from 4 files

        // TileSprite whirlpool = new TileSprite(wp_ts, NEW_OBJID, 0, 1, 2, 3);
        TileSprite whirlpool = new TileSprite(wp_stack_ts, NEW_OBJID, 0, 1, 2, 3);  // Save as from wp_ts, but using 4 image files in a stack

        TileSprite bat       = new TileSprite(creatures_stack, NEW_OBJID, (0 * 28) + 1, (1 * 28) + 1, (2 * 28) + 1, (3 * 28) + 1);
        TileSprite skel_mage = new TileSprite(creatures_stack, NEW_OBJID, (0 * 28) + 21, (1 * 28) + 21, (2 * 28) + 21, (3 * 28) + 21);

        LF = new TileSheet(8, 1, NEW_OBJID,
            @"media/tiles/lava.wave_down.speed_4.frames_8.png");  // LF == LavaFlow
        TileSprite lava_flow = new TileSprite(LF, NEW_OBJID, 0, 1, 2, 3, 4, 5, 6, 7);

        // TODO: Support some manner of ITileSprite for "wave" sprites
        // TileSheet TW = new TileSheet(1, 9, NEW_OBJID, @"media/tiles/example_wave_test.intra_1.png");  // Will need WaveTileSprite to support this...

        TileSprite grass   = new TileSprite(ts, NEW_OBJID, 4);
        TileSprite trees   = new TileSprite(ts, NEW_OBJID, 6);
        TileSprite boulder = new TileSprite(ts, NEW_OBJID, 57);
        int[] path_rect_5x4 = new int[]
            { // 5 = grass, 7 = trees, 58 = boulder
               boulder.ID, grass.ID, grass.ID, trees.ID, grass.ID,
               grass.ID,   grass.ID, grass.ID, trees.ID, trees.ID,
               trees.ID,   trees.ID, trees.ID, trees.ID, 0,         // 0 is a "hole in the map" for blitting / map composition purposes
               grass.ID,   grass.ID, trees.ID, grass.ID, grass.ID,
            };

        DenseGrid map_16x64 = new DenseGrid(16, 64, lava_flow.ID);

        // Blit a non-square grid onto the map, demonstrating the various possible rotations and flips:
        DenseGrid flip_none = new DenseGrid(5, 4, path_rect_5x4);
        DenseGrid flip_we   = flip_none.Flip_WE();
        DenseGrid flip_ns   = flip_none.Flip_NS();
        DenseGrid flip_wens = flip_we.Flip_NS();

        DenseGrid.BlitFromAOntoB(flip_none, map_16x64, 1, 1);
        DenseGrid.BlitFromAOntoB(flip_we, map_16x64, 7, 1);
        DenseGrid.BlitFromAOntoB(flip_ns, map_16x64, 1, 7);
        DenseGrid.BlitFromAOntoB(flip_wens, map_16x64, 7, 7);

        DenseGrid flip_none_rot090 = flip_none.Rotate090();
        DenseGrid flip_we_rot090   = flip_we.Rotate090();
        DenseGrid flip_ns_rot090   = flip_ns.Rotate090();
        DenseGrid flip_wens_rot090 = flip_wens.Rotate090();

        DenseGrid.BlitFromAOntoB(flip_none_rot090, map_16x64, 1, 52);
        DenseGrid.BlitFromAOntoB(flip_we_rot090, map_16x64, 7, 52);
        DenseGrid.BlitFromAOntoB(flip_ns_rot090, map_16x64, 1, 58);
        DenseGrid.BlitFromAOntoB(flip_wens_rot090, map_16x64, 7, 58);

        map = new SimpleMapV1(16, 64);
        map.AddTerrainRegion(map_16x64, 0, 0);

        tvpc.scroll_constraint = ScrollConstraint.CenterTile;
        tvpc.set_center(map, 2, 2);

        // Add some elements to the Beings layer of the Map:
        // BUG: (in demo data)
        // The below are bare integers which do not correspond
        // to a constructed TileSprite; those display wrongly (confusion between object ID and OpenGL texture ID or somesuch?)
        // The fix is merely to create TileSprite objects and use their .ID
        // (This fossil is due to the TileSheet + TileSprite refactor;
        //  the sprites are no longer implicitly created and stored within the TileSheet)

        /*
        map.layers[MapLayers.Beings].set_contents_at_XY( 8,  7, 256+21);  // Horse
        map.layers[MapLayers.Beings].set_contents_at_XY( 4, 15, 256+21);  // Horse
        map.layers[MapLayers.Beings].set_contents_at_XY( 8, 20, 33);  // Wizard
        map.layers[MapLayers.Beings].set_contents_at_XY( 3, 25, 70);  // Force field
        map.layers[MapLayers.Beings].set_contents_at_XY(10, 30, 29);  // Stair down
        map.layers[MapLayers.Beings].set_contents_at_XY( 9, 35, 30);  // Ruin
        map.layers[MapLayers.Beings].set_contents_at_XY( 6, 40, 45);  // Archer
        map.layers[MapLayers.Beings].set_contents_at_XY(12, 45, 23);  // Purple tiles
        map.layers[MapLayers.Beings].set_contents_at_XY( 5, 50, 19);  // Ship
        */

        map.layers[MapLayers.Beings].set_contents_at_XY(2, 1, anim_blue_wiz.ID);  // Blue Wizard, animated (2 frames)
        map.layers[MapLayers.Beings].set_contents_at_XY(3, 3, anim_red_wiz.ID);   // Red  Wizard, animated (4 frames)

        map.layers[MapLayers.Beings].set_contents_at_XY(4, 1, count_ABC.ID);   // 3 frames (A,B,C)
        map.layers[MapLayers.Beings].set_contents_at_XY(5, 1, count_1234.ID);  // 4 frames (1,2,3,4)

        map.layers[MapLayers.Beings].set_contents_at_XY(6, 6, bat.ID);
        map.layers[MapLayers.Beings].set_contents_at_XY(4, 7, skel_mage.ID);

        map.layers[MapLayers.Beings].set_contents_at_XY(0, 0, whirlpool.ID);

        // Add some elements to the UI_elements layer of the TileViewPort:

        // Over-sized cursor
        // Drawback: outside of tile bounds
        // is off-viewport for edge-of-viewport sides of cursor on edge-of-viewport tiles.
        // Also, the "quanta" animation rate for the cursor blinking is too fast, as in "pokemon epilepsy warning" too-fast.
        // (Blinking at "frame" rate seems OK...may want a modestly faster rate.)
        //
        // This cursor _does_ look a lot better, other than for edge-of-viewport tiles.
        // One possible solution to that issue would be for the "rest" state of the viewport
        // to have an n-pixel border along all edges, showing partial tiles.
        // Will need to coordinate all this with smooth-scrolling, too...
        ts_cursor_blink_40x40 = new TileSheet(1, 1, 40, 40, 0, 0, 0, 0, NEW_OBJID,
            @"media/cursors/cursor_40x40_blink.stacked/cursor_40x40.frame_1.png",
            @"media/cursors/cursor_40x40_blink.stacked/cursor_40x40.frame_2.png");
        TileSprite large_cursor = new TileSprite(ts_cursor_blink_40x40, NEW_OBJID, 0, 1);
        int LC = large_cursor.ID;

        tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(tvpc.center_x, tvpc.center_y, LC);  // Center
        tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(0, 0, LC);  // NW
        tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(tvpc.max_x, 0, LC);  // NE
        tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(0, tvpc.max_y, LC);  // SW
        tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(tvpc.max_x, tvpc.max_y, LC);  // SE

        // // "Marquee" cursor
        // // Drawback: cursor itself is entirely within tile bounds, thus clips edge pixels of the under-cursor tile...
        // //
        //reticle_single_file_ts = new TileSheet(4, 1, NEW_OBJID, @"media/tiles/bright_marquee.frame_1234.png");
        reticle_four_files_ts = new TileSheet(4, 4, NEW_OBJID,
                        @"media/tiles/bright_marquee.frame_1.png",
                        @"media/tiles/bright_marquee.frame_2.png",
                        @"media/tiles/bright_marquee.frame_3.png",
                        @"media/tiles/bright_marquee.frame_4.png");  // Also used in Form1.OnPaint()
        //TileSprite anim_reticle = new TileSprite(reticle_four_files_ts, 15, 31, 47, 63);  // Bottom right tile in each image file
        //int reticle = anim_reticle.ID;
        //tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(tvpc.center_x, tvpc.center_y, reticle);  // Center
        //tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(0,             0,             reticle);  // NW
        //tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(tvpc.max_x,    0,             reticle);  // NE
        //tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(0,             tvpc.max_y,    reticle);  // SW
        //tvpc.layers[ViewPortLayers.UI_Elements].set_contents_at_XY(tvpc.max_x,    tvpc.max_y,    reticle);  // SE

        // A few method calls to demonstrate that Archetype and Obj are working:
        Archetype aa = new Archetype("first_test_archetype", 0);
        aa.add_field("int_2a",     FieldType.INT);
        aa.add_field("string_2a",  FieldType.STRING);
        aa.add_field("decimal_2a", FieldType.DECIMAL);
        aa.add_field("ID_2a",      FieldType.ID);

        aa.add_field("int_list",     FieldType.LIST_INT);
        aa.add_field("string_list",  FieldType.LIST_STRING);
        aa.add_field("decimal_list", FieldType.LIST_DECIMAL);
        aa.add_field("ID_list",      FieldType.LIST_ID);

        Obj obj1 = new Obj(aa, "first_test_obj", 0);

        stdout.print("archetype.serialize()\n");
        stdout.print("{0}",   aa.serialize() );
        stdout.print("\n");

        stdout.print("obj.serialize()\n");
        stdout.print("{0}", obj1.serialize() );
        stdout.print("\n");
    }
Esempio n. 37
0
        /// <summary>
        /// Read an entire table into memory
        /// </summary>s
        /// <param name="archetype"></param>
        /// <param name="itemID"></param>
        public static void ReadTableIntoMemory(Archetype archetype)
        {
            //Lazily load the entire table
            using (SqlCeConnection conn = new SqlCeConnection("Data Source=items.sdf;Max Database Size=256;Persist Security Info=False;"))
            {
                conn.Open();
                string tableName = archetype.ToString().ToLower();
                string firstChar = tableName.Substring(0, 1);
                tableName = firstChar.ToUpper() + tableName.Substring(1);

                SqlCeCommand com = new SqlCeCommand("SELECT * from " + tableName, conn);

                SqlCeDataReader reader = com.ExecuteReader();
                Dictionary<int, List<string>> values = new Dictionary<int, List<string>>();

                while (reader.Read())
                {
                    List<string> data = new List<string>();
                    for (int i = 0; i < reader.VisibleFieldCount; i++)
                    {
                        data.Add(reader.GetValue(i).ToString());
                    }

                    //the first one will be an int, with the id
                    values.Add(reader.GetInt32(0), data);
                }

                dictionary.Add(archetype, values);
            }
        }
Esempio n. 38
0
        public static List<string> GetItemProperties(Archetype archetype, int itemID)
        {
            if (!dictionary.Keys.Contains(archetype))
            {
                ReadTableIntoMemory(archetype);
            }

               return dictionary[archetype][itemID];
        }
Esempio n. 39
0
            private void SetupArchetype(Board board)
            {
                if (isPaladinSecret(board))
                    _archetypeFriendly = Archetype.PaladinSecret;
                else if (isZoo(board))
                    _archetypeFriendly = Archetype.Zoo;
                else if (isMechWarrior(board))
                    _archetypeFriendly = Archetype.MechWarrior;
                else if (isMechMage(board))
                    _archetypeFriendly = Archetype.MechMage;
                else if (isFaceWarrior(board))
                    _archetypeFriendly = Archetype.FaceWarrior;
                else if (isPriestControl(board))
                    _archetypeFriendly = Archetype.PriestControl;
                else if (isMidHunter(board))
                    _archetypeFriendly = Archetype.MidHunter;
                else if (isWorgenOtk(board))
                    _archetypeFriendly = Archetype.WorgenOtk;
                else if (isTempoMage(board))
                    _archetypeFriendly = Archetype.TempoMage;

                if (isHandLock(board))
                    _archetypeEnemy = Archetype.Handlock;
                else if (isFreezeMage(board))
                    _archetypeEnemy = Archetype.FreezeMage;

                _archetypeSetup = true;
            }