コード例 #1
0
 public float GetAttacdamage(Player pl)
 {
     if (pl != null && pl.Upgrades.Count() > 0)
     {
         UnitUpgrade upgrade = pl.Upgrades.Where(x => x.Upgrade == AttacType).FirstOrDefault();
         if (upgrade != null)
         {
             return(_Attacdamage + (AttacUpgradeModifier * upgrade.Level));
         }
     }
     return(_Attacdamage);
 }
コード例 #2
0
 public float GetShieldArmor(Player pl)
 {
     if (pl != null && pl.Upgrades.Count() > 0)
     {
         UnitUpgrade upgrade = pl.Upgrades.Where(x => x.Upgrade == UnitUpgrades.ShieldArmor).FirstOrDefault();
         if (upgrade != null)
         {
             return(_Shieldarmor + (ShieldArmorUpgradeModifier * upgrade.Level));
         }
     }
     return(_Shieldarmor);
 }
コード例 #3
0
        public void SetString(string build, Player pl)
        {
            if (build == null || build == "")
            {
                return;
            }

            pl.SoftReset();

            var ents = build.Split(",");

            foreach (var ent in ents)
            {
                if (ent.Count(x => x == '|') > 1)
                {
                    var  unitents = ent.Split('|');
                    Unit unit     = UnitPool.Units.SingleOrDefault(x => x.ID == int.Parse(unitents[0]));
                    if (unit != null)
                    {
                        Unit myunit = unit.DeepCopy();
                        myunit.PlacePos = new Vector2(float.Parse(unitents[2]), float.Parse(unitents[1]));
                        UnitService.NewUnit(pl, myunit);
                        pl.Units.Add(myunit);
                        pl.MineralsCurrent += myunit.Cost;
                    }
                }
                else if (ent.Count(x => x == '|') == 1)
                {
                    var         upgradeents = ent.Split('|');
                    UnitUpgrade upgrade     = new UnitUpgrade();
                    upgrade.Upgrade     = (UnitUpgrades)int.Parse(upgradeents[0]);
                    upgrade.Level       = int.Parse(upgradeents[1]);
                    pl.MineralsCurrent += UnitService.UpgradeUnit(upgrade.Upgrade, pl);
                }
                else
                {
                    int ua = -1;
                    if (int.TryParse(ent, out ua))
                    {
                        UnitAbility myability = AbilityPool.Abilities.SingleOrDefault(x => x.Ability == (UnitAbilities)ua).DeepCopy();
                        pl.MineralsCurrent += UnitService.AbilityUpgradeUnit(myability, pl);
                    }
                }
            }
        }