//Private Methods private void NormalAttack(BtlCtrlCharacter currentSlcCharacter, BtlCtrlParty[] parties, BattleController.TeamTypes teamType, Action <long, int, List <long> > onMove) { Divine.Moniker moniker; int partyIndex = teamType == BattleController.TeamTypes.Player ? 0 : 1; List <BtlCtrlCharacter> chs = parties[partyIndex].GetCharacters(); List <BtlCtrlCharacter> availableCh = new List <BtlCtrlCharacter>(); for (int i = 0; i < chs.Count; i++) { if (chs[i].isActive && !chs[i].isDead) { availableCh.Add(chs[i]); } } int rnd = UnityEngine.Random.Range(0, availableCh.Count); moniker = availableCh[rnd].moniker; NormalAttack(currentSlcCharacter, parties, moniker, onMove); }
private void NormalAttack(BtlCtrlCharacter currentSlcCharacter, BtlCtrlParty[] parties, Divine.Moniker targetMoniker, Action <long, int, List <long> > onMove, int spellIndex = 0) { int indexOfSpell = spellIndex; BtlCtrlCharacter target = null; List <BtlCtrlCharacter> playerCharacters = parties[0].GetCharacters(); foreach (BtlCtrlCharacter ch in playerCharacters) { if (ch.hp > 0 && ch.moniker == targetMoniker) { target = ch; break; } } if (onMove != null) { onMove(currentSlcCharacter.id, indexOfSpell, new List <long> { target.id }); } }
public void MakeAndAddSpellEffect(BtlCtrlCharacter target, SpellEffectOnChar effectOnChar, BtlCtrlCharacter.ChangeStatInfo changeStatInfo) { var statChanges = new List <SpellSingleStatChangeInfo>(); if (Mathf.Abs(changeStatInfo.shieldChangeAmount) > 0) { statChanges.Add(new SpellSingleStatChangeInfo( SpellSingleStatChangeType.curShieldValChange, changeStatInfo.shieldChangeAmount)); } if (Mathf.Abs(changeStatInfo.hpChangeAmount) > 0) { statChanges.Add(new SpellSingleStatChangeInfo( SpellSingleStatChangeType.curHPValChange, changeStatInfo.hpChangeAmount)); } var stat = new BattleObjStats(target.hp, target.maxHp, damage, target.shield, target.maxShield); var effectInfo = new SpellEffectInfo( statChanges, target.id, effectOnChar, stat); _spellEffectInfoes.Add(effectInfo); }
private int FindNextTurnCharacterID() { int count = 0; bool found = false; BtlCtrlCharacter character = null; while (!found) { count++; _currentTurnIndex++; if (count > _turnOrders.Count) { DivineDebug.Log("BattleController cant find any live character.", DivineLogType.Error); break; } if (_currentTurnIndex >= _turnOrders.Count) { _currentTurnIndex = 0; } int selectedID = (int)_turnOrders[_currentTurnIndex]; character = GetCharacter(selectedID); if (character.hp > 0 && character.isActive) { found = true; } } return(character.id); }
public void DestoryBattle() { UnlistenToPartiesAndCharactersEvents(); _fakeServer.Event_OnMove -= OnMove; _fakeServer.Event_OnReadyCome -= OnReadyCome; _secretController.Event_ActionGenerated -= OnActionGenerated; TimeManager.instance.Event_OneSecTick -= OnTick; for (int i = 0; i < _parties.Length; i++) { _parties[i].DestroyIt(); } _fakeServer = null; _turnOrders = null; _battleLogic = null; _currentActiveSpells = null; _currentSlcCharacter = null; _currentActionsStack = null; _externalLogic.DestroyIt(); _externalLogic = null; _parties[0] = null; _parties[1] = null; _parties = null; }
public void Init(List <BtlCtrlCharacter> characters, BattleController.TeamTypes teamType, string partyName) { _characters = new Dictionary <int, BtlCtrlCharacter>(); _teamType = teamType; _name = partyName; for (int i = 0; i < characters.Count; i++) { BtlCtrlCharacter.Type ty = characters[i].type; if (ty == BtlCtrlCharacter.Type.Hero) { _hero = characters[i]; } else if (ty == BtlCtrlCharacter.Type.Chakra) { _chakra = characters[i]; } characters[i].SetRelatedParty(this); _characters.Add(characters[i].id, characters[i]); } }
public void MoveDone(BtlCtrlCharacter btlCtrlCharacter) { if (!_firstAttack && btlCtrlCharacter.moniker == Divine.Moniker.Archer) { _firstAttack = true; _tutorialCtrl.FirstAttackDone(); } }
private BtlCtrlCharacter MakeTutCharacter(Moniker moniker, int id, int level, bool isActive) { BtlCtrlCharacter character = _dataFiller.FillCharacterData(moniker, level, BattleControllerType.Tutorial_Zahak); character.id = id; character.isActive = isActive; return(character); }
private static CharInfo MakeCharatcerInfo(BtlCtrlCharacter character, bool isHero) { BattleObjStats stats = new BattleObjStats(character.hp, character.maxHp, character.spells[0].damage, character.shield, character.maxShield); var spellInfoList = new List <SpellInfo>(); for (int i = 0; i < AppearanceConfigData.instance.GetUnitMagicsCount(character.moniker); i++) { if (i >= character.spells.Count) { break; } var appearance = AppearanceConfigData.instance.GetMagicWithIndex(character.moniker, i); SpellInfo spInf = new SpellInfo( i, appearance._isInstant, appearance._dontShowToUser, appearance._needTargetToComeNear, appearance._spellName, appearance._cost, appearance._prefabName, appearance._spellType, appearance._damageType, appearance._spellImpact, null); spInf.SetSpellParams(character.spells[i].spellParams); spellInfoList.Add(spInf); } if (isHero) { HeroInfo heroInf = new HeroInfo( character.moniker, stats, spellInfoList, Dexterity.MIDDLE, 0, character.level, character.id, 0, 0, new NextUpgradeStats(), character.isActive); return(heroInf); } else { var troop = new CharInfo( character.moniker, stats, spellInfoList, Dexterity.MIDDLE, 0, character.level, character.id, 0, 0, new NextUpgradeStats(), Divine.Moniker.Unknown, character.isActive); return(troop); } }
//Public Methods public void CastSecret(BtlCtrlCharacter owner, Divine.Secret type, List <BtlCtrlCharacter> targets, Action <BtlCtrlSpell> onCastFinish) { BtlCtrlSpell_SecretRevive revive = new BtlCtrlSpell_SecretRevive(); revive.Init(SpellEffectOnChar.Appear, 0, 0, ""); revive.SetOwnerAndIndex(owner, -1); revive.Event_ActionGenerated += OnActionGenerated; revive.StartSpell(targets, onCastFinish); }
public void DestroyIt() { foreach (var ch in _characters.Values) { ch.DestoryCharacter(); } _hero = null; _chakra = null; _characters.Clear(); _characters = null; }
public void MakeDecision(BtlCtrlCharacter currentSlcCharacter, BtlCtrlParty[] parties, Action <long, int, List <long> > onMove, Action <long, Divine.Secret, List <long> > onSecret) { //Player turn and we should wait till movement if (parties[0].HasCharacter(currentSlcCharacter)) { //Player Logic if (tutorialCtrl.GetTutorialState() == Tutorial_ZahakBattle.State.SecondFight_Fereydoun_WaitTillReavilling) { onSecret(currentSlcCharacter.id, Divine.Secret.Revival, new List <long> { 1, 2 }); } return; } DivineDebug.Log(tutorialCtrl.GetTutorialState().ToString()); switch (tutorialCtrl.GetTutorialState()) { case Tutorial_ZahakBattle.State.SecondFight_WaitZahaakFirstAttack: NormalAttack(currentSlcCharacter, parties, Divine.Moniker.Hanzo, onMove); break; case Tutorial_ZahakBattle.State.SecondFight_ZahakSpecialAttack: NormalAttack(currentSlcCharacter, parties, Divine.Moniker.Archer, onMove, 1); break; case Tutorial_ZahakBattle.State.SecondFight_ZahakAttackToChakra: NormalAttack(currentSlcCharacter, parties, Divine.Moniker.FereydounChakra, onMove); break; case Tutorial_ZahakBattle.State.SecondFight_ZahakKillChakra: NormalAttack(currentSlcCharacter, parties, Divine.Moniker.FereydounChakra, onMove, 1); break; } }
private void StartNextTurn(int nextCharacterID, bool justStarted) { _currentState = States.TurnLoop_WaitTillNextCharSelected; _currentActionsStack.Clear(); _currentSlcCharacter = GetCharacter(nextCharacterID); if (Event_OnNextTurnStarted != null) { Event_OnNextTurnStarted(_currentSlcCharacter); } _battleLogic.FakeServer_StartNextTurn(nextCharacterID, _currentSlcCharacter.GetEligibleSpells(), _currentGeneratedAP); _currentGeneratedAP = 0; if (turnTime > 0) { StartTimer(); } DivineDebug.Log(_currentSlcCharacter.moniker.ToString()); }
//Public Methods public void SetOwnerAndIndex(BtlCtrlCharacter owner, int index) { _owner = owner; _index = index; }
public void MakeDecision(BtlCtrlCharacter currentSlcCharacter, BtlCtrlParty[] parties, Action <long, int, List <long> > onMove, Action <long, Divine.Secret, List <long> > onSecret) { //Player turn and we should wait till movement if (parties[0].HasCharacter(currentSlcCharacter)) { //Player Logic if (tutorialCtrl.GetTutorialState() == Tutorial_EntranceBattle.State.FirstFight_Fereydoun_WaitTillReavilling) { onSecret(currentSlcCharacter.id, Divine.Secret.Revival, new List <long> { 1, 2 }); } return; } DivineDebug.Log("Make Decision, ExternalLogic: " + tutorialCtrl.GetTutorialState().ToString()); switch (tutorialCtrl.GetTutorialState()) { case Tutorial_EntranceBattle.State.FirstFight_SkullWizardFight_Creating: case Tutorial_EntranceBattle.State.FirstFight_SkullWizard_Brag: case Tutorial_EntranceBattle.State.FirstFight_FereydounEasyyy: case Tutorial_EntranceBattle.State.FirstFight_SkullWDialogBefore3Skulls: case Tutorial_EntranceBattle.State.FirstFight_FeriDialogBeforeAllies: _battleController.Pause(); break; case Tutorial_EntranceBattle.State.FirstFight_SkullWizard_WaitTillReavillingSkull: onSecret(currentSlcCharacter.id, Divine.Secret.Revival, new List <long> { 5 }); break; case Tutorial_EntranceBattle.State.FirstFight_SkullWFirstAttack: NormalAttack(currentSlcCharacter, parties, Divine.Moniker.Fereydoun, onMove); break; case Tutorial_EntranceBattle.State.FirstFight_WaitForSkullWSecondAttack: NormalAttack(currentSlcCharacter, parties, Divine.Moniker.Fereydoun, onMove); break; case Tutorial_EntranceBattle.State.FirstFight_SkullWizard_WaitTillReavillingSkull2: onSecret(currentSlcCharacter.id, Divine.Secret.Revival, new List <long> { 6, 7, 8 }); break; case Tutorial_EntranceBattle.State.FirstFight_WaitForSkull1_1stGroupAttack: NormalAttack(currentSlcCharacter, parties, Divine.Moniker.Archer, onMove); break; case Tutorial_EntranceBattle.State.FirstFight_WaitForSkull2_1stGroupAttack: NormalAttack(currentSlcCharacter, parties, Divine.Moniker.Hanzo, onMove); break; case Tutorial_EntranceBattle.State.FirstFight_WaitForSkull3_1stGroupAttack: NormalAttack(currentSlcCharacter, parties, Divine.Moniker.Archer, onMove); break; case Tutorial_EntranceBattle.State.FirstFight_WaitForSkullW_1stGroupAttack: NormalAttack(currentSlcCharacter, parties, Divine.Moniker.Hanzo, onMove); break; case Tutorial_EntranceBattle.State.FirstFight_WaitForSkull1_2ndGroupAttack: NormalAttack(currentSlcCharacter, parties, Divine.Moniker.Archer, onMove); break; case Tutorial_EntranceBattle.State.FirstFight_WaitForSkull2_2ndGroupAttack: NormalAttack(currentSlcCharacter, parties, Divine.Moniker.Hanzo, onMove); break; case Tutorial_EntranceBattle.State.FirstFight_WaitForSkull3_2ndGroupAttack: NormalAttack(currentSlcCharacter, parties, Divine.Moniker.Archer, onMove); break; case Tutorial_EntranceBattle.State.FirstFight_WaitForSkullW_2ndGroupAttack: NormalAttack(currentSlcCharacter, parties, Divine.Moniker.Hanzo, onMove); break; case Tutorial_EntranceBattle.State.FirstFight_ShieldIntro: _battleController.Pause(); break; case Tutorial_EntranceBattle.State.FirstFight_WaitTillLittleShiledAmount: if ((Math.Abs(currentSlcCharacter.spells[0].damage)) >= parties[0].hero.shield) { _battleController.Pause(); _tutorialCtrl.ShieldWillCrushed(); } else { NormalAttack(currentSlcCharacter, parties, Divine.Moniker.Fereydoun, onMove); } break; case Tutorial_EntranceBattle.State.FirstFight_DoDamageToBecomeChakra: NormalAttack(currentSlcCharacter, parties, Divine.Moniker.Fereydoun, onMove); break; case Tutorial_EntranceBattle.State.FirstFight_WaitTillChakraTurn: NormalAttack(currentSlcCharacter, parties, Divine.Moniker.FereydounChakra, onMove); break; } }
public void MoveDone(BtlCtrlCharacter btlCtrlCharacter) { }
public bool HasCharacter(BtlCtrlCharacter character) { return(_characters.ContainsKey(character.id)); }