Esempio n. 1
0
 private void PrepareText(EpizodeXML epizode)
 {            
     this.txtBlock.Text = epizode.ID + "\n" + epizode.Text;            
 }
Esempio n. 2
0
 private void PrepareBattle(EpizodeXML epizode)
 {
     var choices = epizode.Choices.Battles;
     foreach (var choice in choices)
     {
         this.CreateBattleButton(choice);
     }
 }
Esempio n. 3
0
        private void PrepareChances(EpizodeXML epizode)
        {
            if (epizode.Choices != null)
            {
                Random rand = new Random(DateTime.Now.Second);
                var r = rand.NextDouble();
                var chances = epizode.Choices.Chances;

                var cnt = chances.Count();
                double tillNow = 0;

                foreach (var chance in chances)
                {
                    tillNow += chance.Probability;//double.Parse(chance.Attribute(Probability).Value, System.Globalization.NumberStyles.AllowDecimalPoint);
                    if (r < tillNow)
                    {
                        this.CreateButton(chance);
                        break;
                    }
                }
            }
        }
Esempio n. 4
0
 private void PrepareDecisions(EpizodeXML epizode)
 {
     if (epizode.Choices != null)
     {
         var choices = epizode.Choices.Decisions;
         foreach (var choice in choices)
         {
             this.CreateButton(choice);
         }
     }
 }
Esempio n. 5
0
        private void PrepareInventory(EpizodeXML epizode)
        {
            var InventoryConditions = epizode.Choices.InventoryConditions;
            foreach (var invent in InventoryConditions)
            {
                var name = invent.Name;
                bool aval = invent.IsAvailable;

                if (aval == true)
                {
                    int qty = invent.Quantity;

                    var inv = this.Game.lstInventory.Find(i => i.Name == name);
                    if (inv != null)
                    {
                        if (inv.Quantity >= qty)
                        {
                            this.CreateButton(invent);
                        }
                    }
                }
                else
                {
                    var inv = this.Game.lstInventory.Find(i => i.Name == name);
                    if (inv == null || inv.Quantity == 0)
                    {
                        this.CreateButton(invent);
                    }
                }
            }
        }
Esempio n. 6
0
        private void PrepareConditions(EpizodeXML epizode)
        {
            var conditions = epizode.Choices.Conditions;
            foreach (var cond in conditions)
            {
                var predicates = cond.Predicates;
                var pass = true;
                foreach (var pred in predicates)
                {
                    var type = pred.Type;
                    if (type == PredicateTypes.eInventory)
                    {
                        var name = pred.Name;

                        bool aval = pred.IsAvailable;

                        if (aval == true)
                        {
                            int qty = pred.Quantity;

                            var inv = this.Game.lstInventory.Find(i => i.Name == name);
                            if (inv == null || inv.Quantity < qty)
                            {
                                pass = false;
                            }
                        }
                        else
                        {
                            var inv = this.Game.lstInventory.Find(i => i.Name == name);
                            if (inv != null && inv.Quantity != 0)
                            {
                                pass = false;
                            }
                        }
                    }
                }
                if (pass)
                {
                    this.CreateButton(cond);
                    break;
                }
            }
        }
Esempio n. 7
0
        private void PrepareChoices(EpizodeXML epizode)
        {
            this.spButtons.Children.Clear();

            this.PrepareDecisions(epizode);
            this.PrepareChances(epizode);
            this.PrepareBattle(epizode);
            this.PrepareInventory(epizode);
            this.PrepareConditions(epizode);
        }
Esempio n. 8
0
 private void AddRemoveItems(EpizodeXML epizode)
 {
     var invs = epizode.Inventories;
     foreach (var inv in invs)
     {
         var name = inv.Name;
         int qty = inv.Quantity;
         if (inv.Action == true)
         {
             AddInventoryItem(name, qty);
         }
         else
         {
             RemoveInventoryItem(name, qty);
         }
     }
 }
Esempio n. 9
0
        private void AddRemoveStats(EpizodeXML epizode)
        {
            var stats = epizode.Stats;
            foreach (var stat in stats)
            {
                var name = stat.Name;
                int qty = stat.Quantity;

                if (stat.Reset == true)
                {
                    int resetqty = Game.lstStats.Find(s => s.Name == "Initial" + stat.Name).Value;

                    this.ResetStat(stat.Name, resetqty);
                }
                else
                {
                    if (stat.Action == true)
                    {
                        this.AddStat(name, qty);
                    }
                    else
                    {
                        this.RemoveStat(name, qty);
                    }
                }
            }
        }