public bool Deserialize(JSON_ConceptCardTrustRewardItemParam json)
 {
     this.reward_type = (eRewardType)json.reward_type;
     this.iname       = json.reward_iname;
     this.reward_num  = json.reward_num;
     return(true);
 }
Example #2
0
        public Reward(eRewardType reward, Point position)
        {
            this.RewardType = reward;
            base.location   = position;

            Random random = new Random(DateTime.Now.Millisecond);

            this.verticalMovement = CONST_VERTICAL_MOVEMENT + random.Next(4);

            string path = ConfigurationManager.AppSettings["pathImages"];

            switch (reward)
            {
            case eRewardType.WidePad:       base.image = Image.FromFile(path + "Reward_WidePad.png", false); break;

            case eRewardType.FirePad:       base.image = Image.FromFile(path + "Reward_FirePad.png", false); break;

            case eRewardType.SlowBall:      base.image = Image.FromFile(path + "Reward_SlowBall.png", false); break;

            case eRewardType.DemolitionBall: base.image = Image.FromFile(path + "Reward_DemolitionBall.png", false); break;

            case eRewardType.DoubleBall:    base.image = Image.FromFile(path + "Reward_DoubleBall.png", false); break;

            case eRewardType.TripleBall:    base.image = Image.FromFile(path + "Reward_TipleBall.png", false); break;

            case eRewardType.WinLevel:      base.image = Image.FromFile(path + "Reward_WinLevel.png", false); break;
            }

            CollisionsSystem.RegisterItemForCollision(this);
        }
Example #3
0
    private void OnItemRequested(GameEvents.RequestItemSpawnEvent e)
    {
        // TODO get these from somewhere global
        Enums.eLevelTheme currentTheme = Enums.eLevelTheme.Forest;
        Enums.eDifficulty difficulty = Enums.eDifficulty.Easy;

        int[] sourceProbabilities = null;
        switch (e.ItemSource)
        {
            case Enums.eItemSource.Crate:
                sourceProbabilities = m_ItemTypeCrateProbabilities[(int)e.CrateType].Values;
                break;

            case Enums.eItemSource.Enemy:
                sourceProbabilities = m_ItemTypeEnemyProbabilities[(int)e.EnemyType].Values;
                break;
        }

        // determine reward
        eRewardType reward = eRewardType.Nothing;

        int[] probabilities = new int[sourceProbabilities.Length];
        for (int i = 0; i < sourceProbabilities.Length; i++)
        {
            probabilities[i] = sourceProbabilities[i];
        }
        reward = (eRewardType)Utils.WeightedRandom(probabilities);

        switch (reward)
        {
            case eRewardType.Money:
                RewardMoney(difficulty, e.ItemSource, e.CrateType, e.EnemyType, e.SpawnPosition);
                break;

            case eRewardType.Item:
                RewardItem(currentTheme, difficulty, e.ItemSource, e.CrateType, e.EnemyType, e.SpawnPosition);
                break;

            default:
            case eRewardType.Nothing:
                break;
        }
    }