public void ParseParticipateRewards(XmlNode node)
        {
            int i = 0;

            foreach (XmlNode itemNode in node.SelectNodes("item"))
            {
                if (i >= 3)
                {
                    return;
                }

                if (itemNode.Attributes.Count == 0) // No present for this tier
                {
                    i++;
                    continue;
                }

                PresentType type = (PresentType)int.Parse(itemNode.Attributes["category_id"].Value);
                switch (type)
                {
                case Entities.PresentType.CAR:
                    ParticipatePresents[i] = EventPresent.FromCar(itemNode.Attributes["f_name"].Value);
                    break;

                case Entities.PresentType.PAINT:
                    ParticipatePresents[i] = EventPresent.FromPaint(int.Parse(itemNode.Attributes["argument1"].Value));
                    break;
                }

                i++;
            }
        }
Example #2
0
    //initializes stats based off of the stats stored in carstats
    void Start()
    {
        //Adds an entry to the dictionary for each present type with a value starting at 0
        foreach (PresentType present in PresentType.GetValues(typeof(PresentType)))
        {
            gifts.Add(present, 0);
            //Debug.Log(present);
        }

        //PrintGifts();

        /*
         * cs = GameObject.FindObjectOfType<CarStats>();
         * stats = cs.stats;
         * cs.SpawnEquippedAbilities(this.gameObject);
         */
    }
 public Present Get(PresentType presentType)
 {
     switch (presentType)
     {
         case PresentType.Kozunak:
             return new Present(PresentType.Kozunak, (int)PresentType.Kozunak, RecipeConstants.Recipes[PresentType.Kozunak]);
         case PresentType.ChocoEgg:
             return new Present(PresentType.ChocoEgg, (int)PresentType.ChocoEgg, RecipeConstants.Recipes[PresentType.ChocoEgg]);
         case PresentType.Cookie:
             return new Present(PresentType.Cookie, (int)PresentType.Cookie, RecipeConstants.Recipes[PresentType.Cookie]);
         case PresentType.ChocoRabbit:
             return new Present(PresentType.ChocoRabbit, (int)PresentType.ChocoRabbit, RecipeConstants.Recipes[PresentType.ChocoRabbit]);
         case PresentType.RabbitWithRibbon:
             return new Present(PresentType.RabbitWithRibbon, (int)PresentType.RabbitWithRibbon, RecipeConstants.Recipes[PresentType.RabbitWithRibbon]);
         default:
             throw new InvalidOperationException(InvalidPresentTypeExcMsg);
     }
 }
Example #4
0
        public void MakePresent(PresentType presentType, PresentFactory presentFactory)
        {
            foreach (var ingredient in RecipeConstants.Recipes[presentType])
            {
                var item = this.GetFromInventoryByType(ingredient.Key);
                if (item != null)
                {
                    this.SubtractFromInventoryItem(item, ingredient.Value);
                }
                else
                {
                    throw new InsufficientAmmountException(ingredient.Key.ToString());
                }
            }

            var present = presentFactory.Get(presentType);

            this.AddToInventory(present);
        }
Example #5
0
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("CarPart"))
        {
            carParts += other.GetComponent <CarPart>().GetValue();

            carPartAcquired.Invoke();

            Destroy(other.gameObject);
        }

        if (other.CompareTag("PresentBox"))
        {
            PresentType present = other.GetComponent <PresentBox>().GetPresentType();

            gifts[present]++;

            giftAcquired.Invoke();

            Destroy(other.gameObject);
            //PrintGifts();
        }
    }
Example #6
0
        public Present Get(PresentType presentType)
        {
            switch (presentType)
            {
            case PresentType.Kozunak:
                return(new Present(PresentType.Kozunak, (int)PresentType.Kozunak, RecipeConstants.Recipes[PresentType.Kozunak]));

            case PresentType.ChocoEgg:
                return(new Present(PresentType.ChocoEgg, (int)PresentType.ChocoEgg, RecipeConstants.Recipes[PresentType.ChocoEgg]));

            case PresentType.Cookie:
                return(new Present(PresentType.Cookie, (int)PresentType.Cookie, RecipeConstants.Recipes[PresentType.Cookie]));

            case PresentType.ChocoRabbit:
                return(new Present(PresentType.ChocoRabbit, (int)PresentType.ChocoRabbit, RecipeConstants.Recipes[PresentType.ChocoRabbit]));

            case PresentType.RabbitWithRibbon:
                return(new Present(PresentType.RabbitWithRibbon, (int)PresentType.RabbitWithRibbon, RecipeConstants.Recipes[PresentType.RabbitWithRibbon]));

            default:
                throw new InvalidOperationException(InvalidPresentTypeExcMsg);
            }
        }
Example #7
0
 public Present(PresentType presentType, int price, Dictionary <Enum, int> ingredients)
 {
     this.Type        = presentType;
     this.Price       = price;
     this.ingredients = new Dictionary <Enum, int>(ingredients);
 }
        public void WriteToXml(XmlWriter xml)
        {
            xml.WriteStartElement("reward");
            {
                xml.WriteElementBool("is_once", IsOnce);

                xml.WriteElementInt("percent_at_pp100", PercentAtPP100);
                xml.WriteElementInt("pp_base", PPBase);
                xml.WriteElementValue("present_type", PresentType.ToString());
                xml.WriteElementBool("prize_type", GivesAllTrophyRewards);
                xml.WriteElementInt("special_reward_code", 0);

                xml.WriteStartElement("point_table");
                if (PointTable.Any(e => e != 0))
                {
                    for (int i = 0; i < PointTable.Length; i++)
                    {
                        if (MoneyPrizes[i] == -1)
                        {
                            xml.WriteElementInt("point", 0);
                        }
                        else
                        {
                            xml.WriteElementInt("point", PointTable[i]);
                        }
                    }
                }
                xml.WriteEndElement();

                xml.WriteStartElement("prize_table");
                if (MoneyPrizes.Any(e => e != 0))
                {
                    for (int i = 0; i < MoneyPrizes.Length; i++)
                    {
                        if (MoneyPrizes[i] == -1)
                        {
                            xml.WriteElementInt("prize", 0);
                        }
                        else
                        {
                            xml.WriteElementInt("prize", MoneyPrizes[i]);
                        }
                    }
                }
                xml.WriteEndElement();

                xml.WriteStartElement("star_table");
                if (Stars >= 1)
                {
                    xml.WriteElementValue("star", "RANK_1");
                    if (Stars == 3)
                    {
                        xml.WriteElementValue("star", "RANK_3");
                        xml.WriteElementValue("star", "COMPLETE");
                    }
                }
                xml.WriteEndElement();

                if (RewardPresents.Any(e => e != null))
                {
                    xml.WriteElementValue("present_type", PresentType.ToString());
                    xml.WriteStartElement("present");
                    foreach (var present in RewardPresents)
                    {
                        if (present is null)
                        {
                            xml.WriteEmptyElement("item");
                        }
                        else
                        {
                            present.WriteToXml(xml);
                        }
                    }
                    xml.WriteEndElement();
                }

                if (ParticipatePresents.Any(e => e != null))
                {
                    xml.WriteElementValue("entry_present_type", ParticipationPresentType.ToString());
                    xml.WriteStartElement("entry_present");
                    foreach (var present in ParticipatePresents)
                    {
                        if (present is null)
                        {
                            xml.WriteEmptyElement("item");
                        }
                        else
                        {
                            present.WriteToXml(xml);
                        }
                    }
                    xml.WriteEndElement();
                }
            }
            xml.WriteEndElement();
        }
Example #9
0
 public int GetGiftCount(PresentType present)
 {
     return(gifts[present]);
 }
        public void MakePresent(PresentType presentType, PresentFactory presentFactory)
        {
            foreach (var ingredient in RecipeConstants.Recipes[presentType])
            {
                var item = this.GetFromInventoryByType(ingredient.Key);
                if (item != null)
                {
                    this.SubtractFromInventoryItem(item, ingredient.Value);
                }
                else
                {
                    throw new InsufficientAmmountException(ingredient.Key.ToString());
                }
            }

            var present = presentFactory.Get(presentType);
            this.AddToInventory(present);
        }
Example #11
0
 // Start is called before the first frame update
 void Start()
 {
     myPresentType = (PresentType)Random.Range(0, numberOfPresentTypes);
     Debug.Log(myPresentType);
 }