Esempio n. 1
0
 public static HeroGroupInfo AreGrouped(HeroType type, short count, float maxRadius = 2000)
 {
     Vector3 pos;
     List<AIHeroClient> heros;
     var result = AreGrouped(type, count, out pos, out heros, maxRadius);
     return new HeroGroupInfo(result, type, pos, heros);
 }
Esempio n. 2
0
 internal HeroPropertiesModel(string name, HeroType type, HeroState state, decimal? price)
 {
     Name = name;
     Type = type;
     State = state;
     Price = price;
 }
Esempio n. 3
0
        void StartGameWithHeroType(HeroType type)
        {
            NSAnimationContext.CurrentContext.Duration = 2.0f;
            ((NSImageView)gameLogo.Animator).AlphaValue = 0.0f;
            ((NSButton)archerButton.Animator).AlphaValue = 0.0f;
            ((NSButton)warriorButton.Animator).AlphaValue = 0.0f;

            scene.DefaultPlayerHeroType = type;
            scene.StartLevel ();
        }
Esempio n. 4
0
		private void SetHero( HeroType newHero )
		{
			ResetForm();

			_curHero = newHero;

			var hero = _allheroData[ _curHero ];
			this.imgCurHero.Image = (Bitmap)Properties.Resources.ResourceManager.GetObject( hero.DisplayName.ToLower() );

			lblCurHeroName.Text = hero.DisplayName;

			ReinitializeMatrix(_heroThreatMatrices, hero.ThreatMatrix  );
			ReinitializeMatrix( _heroCompatibilityMatrices, hero.CompatibilityMatrix );
		}
Esempio n. 5
0
	    public void SubmitDraftAction( HeroType heroType )
	    {
			var actionType = _currentDraft.CurrentPhase <= DraftData.DraftPhase.SecondBan ? DraftActionType.Ban : DraftActionType.Pick;

		    var hType = _heroPool[ heroType ];
			
			if( OnHeroChosen != null )
			{
				OnHeroChosen( heroType );
			}

			_currentDraft.SubmitDraftAction( new DraftAction( TeamColor.Blue, actionType, hType ) );

		    PlayCpuTurn();
	    }
Esempio n. 6
0
        internal Hero(int snoID)
            : base(snoID, (int)ActorCategory.Player, (int)TeamType.Team)
        {
            string name = ((ActorName)snoID).ToString();

            switch (name.Split('_')[0].ToLower())
            {
                case "barbarian":
                    HeroType = HeroType.Barbarian; break;
                case "demonhunter":
                    HeroType = HeroType.DemonHunter; break;
                case "monk":
                    HeroType = HeroType.Monk; break;
                case "witchdoctor":
                    HeroType = HeroType.WitchDoctor; break;
                case "wizard":
                    HeroType = HeroType.Wizard; break;
            }
        }
Esempio n. 7
0
 protected int AssignCharacterDefense(HeroType heroType)
 {
     int defense = 0;
     switch (heroType)
     {
         case HeroType.Mage:
             defense = 50;
             break;
         case HeroType.Warrior:
             defense = 100;
             break;
         case HeroType.Healer:
             defense = 50;
             break;
         default:
             break;
     }
     return defense;
 }
Esempio n. 8
0
 private static List<GameObject> GetHeroes(HeroType heroType)
 {
     var temp = new List<GameObject>();
     switch (heroType)
     {
         case HeroType.Ally:
             temp.AddRange(EntityManager.Heroes.Allies.Select(ally => new PlayerGameObject(ally)));
             break;
         case HeroType.Enemy:
             temp.AddRange(EntityManager.Heroes.Enemies.Select(enemy => new PlayerGameObject(enemy)));
             break;
         case HeroType.All:
             temp.AddRange(EntityManager.Heroes.AllHeroes.Select(all => new PlayerGameObject(all)));
             break;
         case HeroType.Debug:
             temp.AddRange(DebugPosistions.Select(pos => new DebugGameObject(pos)));
             break;
         default:
             throw new ArgumentOutOfRangeException("HeroType", heroType, null);
     }
     return temp;
 }
Esempio n. 9
0
        public static bool IsHeroType(this Obj_AI_Base obj, HeroType type)
        {
            switch (type)
            {
                case HeroType.Ad:
                    return obj.IsValid<Obj_AI_Hero>() && Ad.Contains(obj.BaseSkinName.ToLowerInvariant());

                case HeroType.Ap:
                    return obj.IsValid<Obj_AI_Hero>() && Ap.Contains(obj.BaseSkinName.ToLowerInvariant());

                case HeroType.Bruiser:
                    return obj.IsValid<Obj_AI_Hero>() && Bruiser.Contains(obj.BaseSkinName.ToLowerInvariant());

                case HeroType.Support:
                    return obj.IsValid<Obj_AI_Hero>() && Sup.Contains(obj.BaseSkinName.ToLowerInvariant());

                case HeroType.Tank:
                    return obj.IsValid<Obj_AI_Hero>() && Tank.Contains(obj.BaseSkinName.ToLowerInvariant());
            }

            return false;
        }
Esempio n. 10
0
        public static bool AreGrouped(HeroType type, short count, out Vector3 posistion, out List<AIHeroClient> outHeros, float maxRadius = 2000)
        {
            var heros = type == HeroType.Ally ? Ally.Heroes : Enemy.Heroes.Where(x => x.IsHPBarRendered).ToList();
            foreach (var hero in heros)
            {
                var herosNear = new List<AIHeroClient>();
                foreach (var hero2 in heros)
                {
                    var heroRegion = hero2.Position.InWhatRegion();
                    if(heroRegion == hero.Position.InWhatRegion()) herosNear.Add(hero2);
                    else if (hero.IsInRange(hero2.Position, maxRadius)) herosNear.Add(hero2);

                    if (herosNear.Count < count) continue;
                    //Hero has at least the selected amount of people around him, return values
                    posistion = herosNear.AverageLocation();
                    outHeros = heros;
                    return true;
                }
            }
            posistion = Vector3.Zero;
            outHeros = null;
            return false;
        }
Esempio n. 11
0
    public static void SelectIcon(HeroType ht)
    {
        if (ht == HeroType.CONCRETE || ht == HeroType.NONE)
        {
            return;
        }

        foreach (Transform t in content.transform)
        {
            Destroy(t.gameObject);
        }

        dict.Clear();

        foreach (DLCType dt in Enum.GetValues(typeof(DLCType)).Cast <DLCType>())
        {
            GameObject item = GameObject.Instantiate(ShopManager.item, new Vector3(0f, 0f, 1f), Quaternion.identity, content.transform);
            string     ds   = (string)ContentManager.data.GetType().GetField(ht.ToString().ToLower()).GetValue(ContentManager.data);
            DLCType?   main = TypeUtils.getDType(ds);

            foreach (Transform child in item.transform)
            {
                if (child.name == "Icon")
                {
                    child.GetComponent <Image>().sprite = Board.rs.sprites[new KeyValuePair <HeroType, DLCType>(ht, dt)];
                }

                if (child.name == "Price")
                {
                    if (dt == DLCType.NONE)
                    {
                        child.gameObject.SetActive(false);
                    }
                    else
                    {
                        child.GetComponent <Text>().text = getPrice(dt) + " Монет";
                    }
                }

                if (child.name == "Takeoff" && main != null && main == dt)
                {
                    child.gameObject.SetActive(true);
                }

                if (child.name == "Buy" && (ContentManager.data.purchases.Contains(ht.ToString() + ":" + dt.ToString()) || dt == DLCType.NONE || ContentManager.data.coins < getPrice(dt)))
                {
                    child.gameObject.SetActive(false);
                }

                if (child.name == "NotEnoughMoney" && (ContentManager.data.purchases.Contains(ht.ToString() + ":" + dt.ToString()) || dt == DLCType.NONE || ContentManager.data.coins >= getPrice(dt)))
                {
                    child.gameObject.SetActive(false);
                }

                if (child.name == "Puton" && ((ContentManager.data.purchases.Contains(ht.ToString() + ":" + dt.ToString()) && !(main != null && main == dt)) || (dt == DLCType.NONE && ds != "")))
                {
                    child.gameObject.SetActive(true);
                }
            }

            dict.Add(dt, item);
        }

        foreach (Transform child in GameObject.FindGameObjectWithTag("ShopIcons").transform)
        {
            if (child.name == TypeUtils.getName(ht).Replace(" ", ""))
            {
                child.GetComponent <Image>().material = null;
            }
            else
            {
                child.GetComponent <Image>().material = outline;
            }
        }

        selected = ht;
    }
Esempio n. 12
0
 public Hero(string name, bool canFly, HeroType heroType = HeroType.Other) : base(name)
 {
     CanFly   = canFly;
     HeroType = heroType;
 }
Esempio n. 13
0
 protected HeroAnyValue(HeroType Type)
 {
     this.Type = Type;
 }
Esempio n. 14
0
 public HeroBool(bool value = false)
 {
     Type     = new HeroType(HeroTypes.Boolean);
     hasValue = true;
     Value    = value;
 }
Esempio n. 15
0
 public HeroInt(long value = 0L)
 {
     Type     = new HeroType(HeroTypes.Integer);
     hasValue = true;
     Value    = value;
 }
Esempio n. 16
0
 public HeroVoid()
 {
     Type = new HeroType(HeroTypes.None);
 }
Esempio n. 17
0
 public void Insert(HeroType item)
 {
     throw new NotImplementedException();
 }
Esempio n. 18
0
 public Hero(HeroType heroType, EventHandler eventHandler)
 {
     lastMove          = TimeSpan.Zero;
     this.eventHandler = eventHandler;
     SetHeroType(heroType);
 }
Esempio n. 19
0
        private static IEnumerable <Tactic> TacticsToEvaluate(Unit hero)
        {
            HeroType heroType = hero.HeroType;

            yield return(Tactic.AttackSafely);

            yield return(Tactic.AttackHero);

            yield return(Tactic.Retreat);

#pragma warning disable 0162
            if (!World.EnableSpells)
            {
                yield break;
            }

            if (heroType == HeroType.Deadpool)
            {
                if (hero.StealthCooldown == 0 && hero.Mana >= World.StealthCost)
                {
                    yield return(Tactic.Stealth);
                }
                if (hero.WireCooldown == 0 && hero.Mana >= World.WireCost)
                {
                    yield return(Tactic.Wire);
                }
                if (hero.CounterCooldown == 0 && hero.Mana >= World.CounterCost)
                {
                    yield return(Tactic.Counter);
                }
            }
            else if (heroType == HeroType.DoctorStrange)
            {
                if (hero.AoeHealCooldown == 0 && hero.Mana >= World.AoeHealCost)
                {
                    yield return(Tactic.AoeHeal);
                }
                if (hero.ShieldCooldown == 0 && hero.Mana >= World.ShieldCost)
                {
                    yield return(Tactic.Shield);
                }
                if (hero.PullCooldown == 0 && hero.Mana >= World.PullCost)
                {
                    yield return(Tactic.Pull);
                }
            }
            else if (heroType == HeroType.Hulk)
            {
                if (hero.BashCooldown == 0 && hero.Mana >= World.BashCost)
                {
                    yield return(Tactic.Bash);
                }
                if (hero.ChargeCooldown == 0 && hero.Mana >= World.ChargeCost)
                {
                    yield return(Tactic.Charge);
                }
                if (hero.ExplosiveShieldCooldown == 0 && hero.Mana >= World.ExplosiveShieldCost)
                {
                    yield return(Tactic.ExplosiveShield);
                }
            }
            else if (heroType == HeroType.Ironman)
            {
                if (hero.FireballCooldown == 0 && hero.Mana >= World.FireballCost)
                {
                    yield return(Tactic.Fireball);
                }
                if (hero.BurningCooldown == 0 && hero.Mana >= World.BurningCost)
                {
                    yield return(Tactic.Burning);
                }
                if (hero.BlinkCooldown == 0 && hero.Mana >= World.BlinkCost)
                {
                    yield return(Tactic.Blink);
                }
            }
            else if (heroType == HeroType.Valkyrie)
            {
                if (hero.JumpCooldown == 0 && hero.Mana >= World.JumpCost)
                {
                    yield return(Tactic.Jump);
                }
                if (hero.SpearFlipCooldown == 0 && hero.Mana >= World.SpearFlipCost)
                {
                    yield return(Tactic.SpearFlip);
                }
                if (hero.PowerupCooldown == 0 && hero.Mana >= World.PowerupCost)
                {
                    yield return(Tactic.Powerup);
                }
            }
#pragma warning restore 0162
        }
Esempio n. 20
0
 private GameObject LoadHero(HeroType heroType)
 {
     return(Resources.Load <GameObject>(String.Format(Helps.HeroesPath + heroType.ToString())));
 }
Esempio n. 21
0
 public HeroTimer()
 {
     Type = new HeroType(HeroTypes.Timer);
 }
Esempio n. 22
0
 public HeroString(string str = null)
 {
     Type     = new HeroType(HeroTypes.String);
     Text     = str;
     hasValue = Text != null;
 }
 public WaitAi(HeroType heroType)
     : base(heroType)
 {
 }
Esempio n. 24
0
        private void InitSelectArrayTypeWord(int nMatchId)
        {
            if (allSelectArrayTipPageTable == null || !allSelectArrayTipPageTable.ContainsKey(nMatchId))
            {
                return;
            }

            SSchemeSelectArrayTipConfig sConfig = allSelectArrayTipPageTable[nMatchId] as SSchemeSelectArrayTipConfig;

            dicTypeInitInfo.Clear();
            string UpWord     = "";
            string DownWord   = "";
            int    nUpCount   = 0;
            int    nDownCount = 0;

            for (int nTipTypeIndex = (int)HeroType.HEROTYPE_ASSASSIN; nTipTypeIndex < (int)HeroType.HEROTYPE_ALL; nTipTypeIndex++)
            {
                SelectTeamLimitInfo LimitInfo = new SelectTeamLimitInfo();
                HeroType            nHeroType = (HeroType)nTipTypeIndex;
                switch (nHeroType)
                {
                case HeroType.HEROTYPE_ASSASSIN:
                {
                    DownWord   = "坦克英雄不足";
                    UpWord     = "坦克英雄过多";
                    nUpCount   = sConfig.nAssassinUp;
                    nDownCount = sConfig.nAssassinDown;
                }
                break;

                case HeroType.HEROTYPE_SOLDIER:
                {
                    DownWord   = "战士英雄不足";
                    UpWord     = "战士英雄过多";
                    nUpCount   = sConfig.nSoldier_limitUp;
                    nDownCount = sConfig.nSoldier_limitDown;
                }
                break;

                case HeroType.HEROTYPE_MAGIC:
                {
                    DownWord   = "法师英雄不足";
                    UpWord     = "法师英雄过多";
                    nUpCount   = sConfig.nMagicUp;
                    nDownCount = sConfig.nMagicDown;
                }
                break; break;

                case HeroType.HEROTYPE_ADC:
                {
                    DownWord   = "射手英雄不足";
                    UpWord     = "射手英雄过多";
                    nUpCount   = sConfig.nAdcUp;
                    nDownCount = sConfig.nAdcDown;
                }
                break;

                case HeroType.HEROTYPE_SUPPORT:
                {
                    DownWord   = "辅助英雄不足";
                    UpWord     = "辅助英雄过多";
                    nUpCount   = sConfig.nSupportUp;
                    nDownCount = sConfig.nSupportDown;
                }
                break;

                default:
                    break;
                }

                LimitInfo.sTypeLimitWord[(int)LimitType.LIMITTYPE_UP]    = UpWord;
                LimitInfo.sTypeLimitWord[(int)LimitType.LIMITTYPE_DOWN]  = DownWord;
                LimitInfo.nTypeLimitCount[(int)LimitType.LIMITTYPE_UP]   = nUpCount;
                LimitInfo.nTypeLimitCount[(int)LimitType.LIMITTYPE_DOWN] = nDownCount;
                dicTypeInitInfo[nHeroType] = LimitInfo;
            }
        }
Esempio n. 25
0
 public override void Deserialize(IUnmanagedMemoryReader reader)
 {
     base.Deserialize(reader);
     Type = reader.ReadByte();
 }
Esempio n. 26
0
 public Pawn(HeroType type)
 {
     this.type = type;
 }
Esempio n. 27
0
 protected int AssignCharacterRange(HeroType heroType)
 {
     int range = 0;
     switch (heroType)
     {
         case HeroType.Mage:
             range = 5;
             break;
         case HeroType.Warrior:
             range = 2;
             break;
         case HeroType.Healer:
             range = 6;
             break;
         default:
             break;
     }
     return range;
 }
Esempio n. 28
0
 public void CreateHero(HeroType TinkerType, string NamaHero)
 {
     TinkerHeroList.Add(new Hero(TinkerType));
     TinkerHeroList[TinkerHeroList.Count - 1].ID   = TinkerHeroList.Count - 1;
     TinkerHeroList[TinkerHeroList.Count - 1].NAMA = NamaHero;
 }
Esempio n. 29
0
        public void Serialize()
        {
            variables = new VariableList();
            if (!isProto)
            {
                Decompress();
                int    startIndex = version != 1 ? 40 : 36;
                uint   num1       = BitConverter.ToUInt32(Data, startIndex);
                ushort num2       = BitConverter.ToUInt16(Data, startIndex + 4);
                serializedData = new byte[num1];
                Array.Copy(Data, num2, serializedData, 0L, num1);
                _2A         = BitConverter.ToUInt16(Data, startIndex + 6);
                streamStyle = Data[startIndex + 8];
                _2D         = (byte)(Data[startIndex + 9] & 3U);
            }
            if (serializedData.Length == 0)
            {
                return;
            }
            byte[] bytes = Encoding.ASCII.GetBytes("azalie");
            byte   num   = 0;

            for (int index = 0; index < serializedData.Length; ++index)
            {
                if (bytes[num] == serializedData[index] || bytes[num] == serializedData[index] + 97 - 65)
                {
                    ++num;
                    if (num == bytes.Length)
                    {
                        Console.WriteLine(Name);
                        break;
                    }
                }
                else
                {
                    num = 0;
                }
            }
            var stream           = new PackedStream2(streamStyle, serializedData);
            var deserializeClass = new DeserializeClass(stream, 1);

            for (uint index = 0U; index < deserializeClass.Count; ++index)
            {
                uint  type1      = 0U;
                int   variableId = 0;
                ulong fieldId;
                int   d;
                deserializeClass.ReadFieldData(out fieldId, ref type1, ref variableId, out d);
                if (d != 2)
                {
                    var type2 = new HeroType((HeroTypes)type1);
                    var field = new DefinitionId(fieldId);
                    if (field.Definition != null)
                    {
                        type2 = (field.Definition as HeroFieldDef).FieldType;
                    }
                    HeroAnyValue heroAnyValue = HeroAnyValue.Create(type2);
                    heroAnyValue.Deserialize(stream);
                    Variables.Add(new Variable(field, variableId, heroAnyValue));
                }
            }
        }
Esempio n. 30
0
 public Unit(int unitId, int team, UnitType unitType, Vec pos, int attackRange, int health, int maxHealth, int shield, int attackDamage, int movementSpeed, int stunDuration, int goldValue, int countDown1, int countDown2, int countDown3, int mana, int maxMana, int manaRegeneration, HeroType heroType, int isVisible, int itemsOwned)
 {
     UnitId           = unitId;
     Team             = team;
     UnitType         = unitType;
     Pos              = pos;
     AttackRange      = attackRange;
     Health           = health;
     MaxHealth        = maxHealth;
     Shield           = shield;
     AttackDamage     = attackDamage;
     MovementSpeed    = movementSpeed;
     StunDuration     = stunDuration;
     GoldValue        = goldValue;
     CountDown1       = countDown1;
     CountDown2       = countDown2;
     CountDown3       = countDown3;
     Mana             = mana;
     MaxMana          = maxMana;
     ManaRegeneration = manaRegeneration;
     HeroType         = heroType;
     IsVisible        = isVisible;
     ItemsOwned       = itemsOwned;
 }
Esempio n. 31
0
 public HeroFloat(float value = 0.0f)
 {
     Type     = new HeroType(HeroTypes.Float);
     hasValue = true;
     Value    = value;
 }
Esempio n. 32
0
        private GameObject InstantiateHero(HeroType currentHeroType)
        {
            var heroPrefab = Resources.Load <GameObject>(Helps.HeroesPath + currentHeroType);

            return(Instantiate(heroPrefab));
        }
Esempio n. 33
0
 public Hero(string name, HeroType type)
 {
     Name = name;
     Type = type;
 }
Esempio n. 34
0
 public HeroList(HeroType type = null)
 {
     this.Type        = new HeroType(HeroTypes.List);
     this.Type.Values = type;
     this.nextId      = 0;
 }
Esempio n. 35
0
 // Methods
 public bool IsDropForbidden(ShardTypeId typeId, HeroType hero) => default;
Esempio n. 36
0
 public HeroGroupInfo(bool result, HeroType type, Vector3 averagePosistion, List<AIHeroClient> heros)
 {
     Result = result;
     Type = type;
     AveragePosistion = averagePosistion;
     Heros = heros;
 }
Esempio n. 37
0
 public HeroAnyValue()
 {
     this.hasValue = false;
     this.Type     = new HeroType();
 }
Esempio n. 38
0
 public Hero(HeroType type)
 {
     setHeroType(type);
     initiateHero();
 }
Esempio n. 39
0
 public Hero(string name, string altName, HeroType heroType)
 {
     Name     = name;
     AltName  = altName;
     HeroType = heroType;
 }
Esempio n. 40
0
		private void SubmitAction( HeroType heroType )
		{
			_draftManager.SubmitDraftAction( heroType );
		}
Esempio n. 41
0
 public Wizard(Tile location, Direction facing, int ws, int bs, int s, int t, int w, HeroType type)
     : base(location, facing, ws, bs, s, t, w, type)
 {
     this.spellAffectAllRemaining = 2;
     this.spellExplodeRemaining = 2;
 }
Esempio n. 42
0
 public Card(String name, CardType type, HeroType hero, CardFunctions behavior)
 {
 }
Esempio n. 43
0
 protected int AssignCharacterHealth(HeroType heroType)
 {
     int health = 0;
     switch (heroType)
     {
         case HeroType.Mage:
             health = 150;
             break;
         case HeroType.Warrior:
             health = 200;
             break;
         case HeroType.Healer:
             health = 75;
             break;
         default:
             break;
     }
     return health;
 }
Esempio n. 44
0
 void StartGameWithHeroType(HeroType type)
 {
     HideUIElements (true, true);
     scene.DefaultPlayerHeroType = type;
     scene.StartLevel ();
 }
Esempio n. 45
0
    public void Initialize(HeroCfg cfg)
    {
        name = cfg.name;
        heroType = cfg.heroType;
        baseStrength = cfg.baseStrength;
        baseDexterity = cfg.baseDexterity;
        baseIntellect = cfg.baseIntellect;

        strengthGrowth = cfg.strengthGrowth;
        dexterityGrowth = cfg.dexterityGrowth;
        intellectGrowth = cfg.intellectGrowth;
        baseDamage = cfg.baseDamage;
        baseArmor = cfg.baseArmor;
        BAT = cfg.BAT;

        baseVitality = cfg.baseVitality;
        baseMana = cfg.baseMana;
        damageInteval = cfg.damageInteval;

        OnLevelChange(1);
        ResetHp();
    }
        HeroCharacter CreateHeroBy(HeroType type, CGPoint position, Player player)
        {
            switch (type) {
            case HeroType.Archer:
                return new Archer (position, player);

            case HeroType.Warrior:
                return new Warrior (position, player);

            default:
                throw new NotImplementedException ();
            }
        }
Esempio n. 47
0
 internal HeroTypeViewModel(HeroType heroType, ICryptographyService cryptographyService)
 {
     Id = cryptographyService.Encrypt(heroType.Id);
     Name = heroType.Name;
 }
Esempio n. 48
0
 public void setHeroType(HeroType type)
 {
     myHero = type;
     initiateHero();
 }
Esempio n. 49
0
        public Hero CreateHero(string name, HeroType type, ISession session)
        {
            Random r = new Random();
            try
            {

                Price price = Recruit.GetPrice(TroopType.Nobleman, 1);
                int heroCount = this.Village.Player.Heroes.Count + 1;
                

                int clay = price.Clay * heroCount, wood = price.Wood * heroCount, iron = price.Iron * heroCount;
                this.Village[ResourcesType.Wood] -= wood;
                this.Village[ResourcesType.Clay] -= clay;
                this.Village[ResourcesType.Iron] -= iron;

                if (this.Village[ResourcesType.Wood] < wood || this.Village[ResourcesType.Clay] < clay || this.Village[ResourcesType.Iron] < iron)
                    throw new TribalWarsException("Không đủ tài nguyên");

                if ((this.Village.Population + price.Population) > this.Village.MaxPopulation)
                    throw new TribalWarsException("Không đủ farm xây dựng hero");

                if (this.Village[BuildingType.Academy] < heroCount)
                    throw new TribalWarsException("Số hero không được vượt quá công trình academy");

                Hero hero = new Hero();
                hero.Type = type;
                hero.Name = name;
                hero.Biography = "";
                hero.Avatar = false;
                switch (type)
                {
                    case HeroType.Intelligent:
                        hero.Intelligent = 15 + r.Next(10);
                        hero.Attack = 10 + r.Next(10);
                        hero.Defense = 10 + r.Next(10);
                        break;
                    case HeroType.Attack:
                        hero.Attack = 15 + r.Next(10);
                        hero.Intelligent = 10 + r.Next(10);
                        hero.Defense = 10 + r.Next(10);
                        break;
                    case HeroType.Defense:
                        hero.Defense = 15 + r.Next(10);
                        hero.Attack = 10 + r.Next(10);
                        hero.Intelligent = 10 + r.Next(10);
                        break;
                    default:
                        break;
                }

                

                this.Village.Heroes.Add(hero);
                this.Village.Player.Heroes.Add(hero);
                
                hero.InVillage = this.Village;
                hero.Owner = this.Village.Player;
                hero.IsRecruiting = true;
                hero.IsDead = true;

                RecruitHero recruit = new RecruitHero();
                recruit.IsResurrection = false;
                recruit.Hero = hero;
                recruit.Owner = this.Village.Player;
                recruit.StartingTime = DateTime.Now;
                recruit.FinishTime = recruit.StartingTime.AddMilliseconds(Recruit.GetPrice(TroopType.Nobleman, this.Village[BuildingType.Academy]).BuildTime);

                
                session.Save(hero);
                session.Save(recruit);
                session.Update(this.Village);
                session.Update(this.Village.Player);

                return hero;
            }
            catch (TribalWarsException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                ServicesList.LogService.LogException(ex);
                throw ex;
            }
        }
Esempio n. 50
0
 public Hero(Tile location, Direction facing, int ws, int bs, int s, int t, int w, HeroType type)
     : base(location, facing, ws, bs, s, t, w)
 {
     this.type = type;
     UpdateImageRef();
 }
Esempio n. 51
0
		private void OnHeroChosen( HeroType heroType )
		{
			PictureBox selectedImage = null;
			switch( _draftManager.CurrentDraftPhase )
			{
				case DraftData.DraftPhase.FirstBan:
					selectedImage = imgBlueBan;
					imgBlueTeamBanOverlay.Visible = true;
					break;

				case DraftData.DraftPhase.SecondBan:
					selectedImage = imgRedBan;
					imgRedTeamBanOverlay.Visible = true;
					break;

				case DraftData.DraftPhase.BluePick1:
					selectedImage = imgBluePick1;
					break;

				case DraftData.DraftPhase.BluePick2:
					selectedImage = imgBluePick2;
					break;

				case DraftData.DraftPhase.BluePick3:
					selectedImage = imgBluePick3;
					break;

				case DraftData.DraftPhase.RedPick1:
					selectedImage = imgRedPick1;
					break;

				case DraftData.DraftPhase.RedPick2:
					selectedImage = imgRedPick2;
					break;

				case DraftData.DraftPhase.RedPick3:
					selectedImage = imgRedPick3;
					this.btnNextDraft.Visible = true;
					break;

				default:
					return;
			}

			var imgBox = _heroToButtonLoookup[ heroType ];
			imgBox.Image = Properties.Resources.GrayOutOverlay;
			selectedImage.Image = imgBox.BackgroundImage;

			this.lblCurrentPhase.Text = (_draftManager.CurrentDraftPhase + 1).ToString();
		}
Esempio n. 52
0
        private PolicyCandidate GeneratePolicyCandidate(Policy currentPolicy, Policy incumbent, Rollout[] starters, HeroType chosenHero)
        {
            List <Episode> trainingSet = GenerateTrainingSet(incumbent, currentPolicy, starters, chosenHero);
            Policy         newPolicy   = FitPolicy(currentPolicy, trainingSet);

            return(EvaluatePolicy(newPolicy, incumbent));
        }
Esempio n. 53
0
 public AttackCharacter(string id, int x, int y, int healthPoints, int defensePoints, Team team, int range, HeroType heroType)
     : base(id, x, y, healthPoints, defensePoints, team, range)
 {
     this.Type = heroType;
     this.AttackPoints = SetAttackPoints();
 }
Esempio n. 54
0
        private List <Episode> GenerateTrainingSet(Policy incumbent, Policy currentPolicy, Rollout[] starters, HeroType chosenHero)
        {
            List <Episode> trainingSet = new List <Episode>();
            int            generated   = trainingSet.Count;
            int            nextMessage = NextStatusInterval(generated, StatusInterval);

            Stopwatch generatingStopwatch = Stopwatch.StartNew();

            Console.WriteLine(string.Format("Generating up to {0} replays", ReplaysPerIteration));
            Console.Write("> ");
            trainingSet.AddRange(
                Enumerable.Range(0, ReplaysPerIteration)
                .AsParallel()
                .SelectMany(_ => {
                Random random = _threadContext.Value.Random;

                while (true)
                {
                    Rollout rollout    = starters[random.Next(starters.Length)];
                    World initialWorld = rollout.Ticks[random.Next(rollout.Ticks.Count)].World;
                    Unit hero          = initialWorld.Units.FirstOrDefault(u => u.Team == 0 && u.UnitType == UnitType.Hero && u.HeroType == chosenHero);
                    if (hero == null)
                    {
                        continue;
                    }

                    List <Episode> episodes = Replayer.GenerateRollout(initialWorld, hero.UnitId, currentPolicy, incumbent);

                    int nowGenerated = Interlocked.Add(ref generated, episodes.Count);
                    int nowMessage   = nextMessage;
                    int newMessage   = NextStatusInterval(nowGenerated, StatusInterval);
                    if (nowGenerated >= nowMessage &&
                        Interlocked.CompareExchange(ref nextMessage, newMessage, nowMessage) == nowMessage)
                    {
                        Console.Write(nowMessage + " ");
                    }
                    return(episodes);
                }
            })
                .WhereNotNull());
            Console.WriteLine();
            Console.WriteLine(string.Format("{0} episodes generated in {1:F1} seconds", trainingSet.Count, generatingStopwatch.Elapsed.TotalSeconds));
            return(trainingSet);
        }