예제 #1
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            if (resultCode == Result.Ok)
            {
                var changedWeaponIndex     = data.Extras.GetInt("SelectedWeaponIndex");
                var changedWeaponName      = data.Extras.GetString("ResultWeaponName");
                var changedWeaponDamageSet = new DamageSet(JsonConvert.DeserializeObject <List <DamageSet.Dice> >(data.Extras.GetString("ResultDamageDice")), data.Extras.GetInt("ResultDamageModifier"));
                var changedAcriStone       = DamageSet.DecodeAcriSymbol(data.Extras.GetString("ResultAcriStone"));

                if (requestCode == 100)
                {
                    Weapons[changedWeaponIndex] = new Weapon(changedWeaponDamageSet, changedWeaponName);
                    Weapons[changedWeaponIndex].ChangeAcriStones(changedAcriStone);
                }
                else if (requestCode == 101)
                {
                    Weapons.Add(new Weapon(changedWeaponDamageSet, changedWeaponName));
                    Weapons[Weapons.Count - 1].ChangeAcriStones(changedAcriStone);
                }
            }

            else if (resultCode == Result.FirstUser)
            {
                Weapons.Remove(Weapons[data.Extras.GetInt("SelectedWeaponIndex")]);
            }

            ViewAdapter.NotifyDataSetChanged();
        }
예제 #2
0
        public DamageSet ModifyDamage(AcriStone stone)
        {
            int minDiceValue = (int)Enum.GetValues(typeof(Dice)).Cast <Dice>().First();
            int maxDiceValue = (int)Enum.GetValues(typeof(Dice)).Cast <Dice>().Last();

            var newDamageSet     = new DamageSet();
            var newDiceList      = new List <Dice>(DamageDice);
            int lowestDamageDice = (int)newDiceList.Min();
            int stoneValue       = (int)stone;
            int extraDamage      = stoneValue % 2 == 0 ? 0 : 1;

            if ((maxDiceValue + minDiceValue) - lowestDamageDice <= stoneValue)
            {
                newDiceList[newDiceList.IndexOf(newDiceList.Min())] = Dice.d12;
                newDiceList.Insert(newDiceList.Count, (Dice)((stoneValue - extraDamage) - (maxDiceValue - lowestDamageDice)));
            }
            else if (maxDiceValue - lowestDamageDice < stoneValue && stoneValue - (maxDiceValue - lowestDamageDice) < minDiceValue)
            {
                newDiceList[newDiceList.IndexOf(newDiceList.Min())] = Dice.d12;
                extraDamage = stoneValue - (maxDiceValue - lowestDamageDice);
            }
            else
            {
                newDiceList[newDiceList.IndexOf(newDiceList.Min())] = (Dice)(lowestDamageDice + stoneValue - extraDamage);
            }

            newDamageSet.DamageDice  = newDiceList;
            newDamageSet.DamageBonus = DamageBonus + extraDamage;

            return(newDamageSet);
        }
예제 #3
0
        private void WeaponList_ItemLongClick(object sender, AdapterView.ItemLongClickEventArgs e)
        {
            var intent = new Intent(this, typeof(CreateWeaponActivity));

            intent.PutExtra("WeaponIndex", e.Position);
            intent.PutExtra("WeaponName", Weapons[e.Position].WeaponName);
            intent.PutExtra("BaseDamage", JsonConvert.SerializeObject(Weapons[e.Position].BaseDamage));
            intent.PutExtra("Stone", DamageSet.EncodeAcriSymbol(Weapons[e.Position].UpgradeStone));

            StartActivityForResult(intent, 100);
        }
예제 #4
0
 public Weapon(DamageSet damage, string name)
 {
     BaseDamage   = damage;
     UpgradeStone = DamageSet.AcriStone.None;
     WeaponName   = name;
 }