private void SelectACharacter(Character selectedChar, List <int> eligibleSpells, List <CoolDownData> cooldownSpells, List <int> eligibleSecrets, List <CoolDownData> cooldownSecrets, bool isSelected) { if (selectedChar == null) //It means actions done without selecting character like Abbot { CheckStates(); return; } selectedChar.SetSelected(isSelected); DivineDebug.Log("SelectACharacter " + selectedChar.moniker + " " + isSelected); if (isSelected) { _currentSelectedCharacter = selectedChar; Party selectedParty = _parties[0].ContainCharacter(selectedChar) ? _parties[0] : _parties[1]; _newBattleUI.SetCharacterSelected(selectedChar, eligibleSpells, cooldownSpells, eligibleSecrets, cooldownSecrets, _battleSpellDataProvider.GetBattleSpellDatas(selectedChar.charInfo, selectedParty.actionPoint)); } else { _currentSelectedCharacter = null; _newBattleUI.SetTurnFinished(); } if (_currentSelectedCharacter == null) //Turn try to finished should check state again { CheckStates(); } }
internal void PrintCharStats() { foreach (Character ch in _charsDic.Values) { DivineDebug.Log(ch.moniker + " in this state: " + ch.state, DivineLogType.Error); } }
private void ShowUpdatingStatsVisual(SpellEffectInfo spellEffectInfo) { switch (spellEffectInfo.effectOnCharacter) { case SpellEffectOnChar.Miss: _charVisual.charUI.newCharHUD.AddBuzz(BuzzType.Miss); return; case SpellEffectOnChar.Dodge: _charVisual.charUI.newCharHUD.AddBuzz(BuzzType.Dodge); return; case SpellEffectOnChar.SeriousDamage: _charVisual.charUI.newCharHUD.AddBuzz(BuzzType.Critical); break; } for (int i = 0; i < spellEffectInfo.singleStatChanges.Count; i++) { SpellSingleStatChangeInfo singleStatChange = spellEffectInfo.singleStatChanges[i]; DivineDebug.Log("On Receive Damage" + singleStatChange.charStatChangeType.ToString() + " " + singleStatChange.intVal); switch (singleStatChange.charStatChangeType) { case SpellSingleStatChangeType.curDamageValChange: ShowUI_StatChange_DMG(singleStatChange.intVal, spellEffectInfo.effectOnCharacter); break; } } ShowUI_StatChange_HpOrShield(spellEffectInfo.isMultiPart); Show_EffectForFlagChange(_currentStats.flags, spellEffectInfo.effectOnCharacter == SpellEffectOnChar.None); }
private bool RunNextAction_IfWeHaveAny() { if (_actionData.Count == 0) { DivineDebug.Log("No action data to run."); return(false); } _numOfKilledCharacterInThisAct = 0; _apGeneratedInThisTurn = false; _curState = BattleLogicStates.TurnLoop_DoingFightActions; DivineDebug.Log("Run action number " + _indexOfCurrentAction + " ."); ActionData ad = _actionData[0]; if ((ad as FightActionData) != null) { Character.Deleg_SpellCasted onCharacterCastSpell = OnCharacterCastSpell; ad.RunAction(onCharacterCastSpell); } else if ((ad as SecretActionData) != null) { ad.RunAction(null); } _actionData.Remove(ad); _indexOfCurrentAction++; return(true); }
//Public Methods public void Appear(System.Action onAppearDone, string moniker, bool flipX) { _onAppearDone = onAppearDone; if (_skeletonAnim == null) { _skeletonAnim = GetComponent <SkeletonAnimation>(); } _skeletonAnim.skeleton.a = 1; _skeletonAnim.skeleton.flipX = flipX; if (_skeletonAnim.skeleton.GetAttachment(_headSlot, "heads/" + moniker) != null) { _skeletonAnim.skeleton.SetAttachment(_headSlot, "heads/" + moniker); } else { DivineDebug.Log("Grave for " + moniker + " Doesn't Exist", DivineLogType.Error); } if (_skeletonAnim.skeleton.GetAttachment(_weaponSlot, moniker) != null) { _skeletonAnim.skeleton.SetAttachment(_weaponSlot, moniker); } else { _skeletonAnim.skeleton.SetAttachment(_weaponSlot, "bone"); } _skeletonAnim.state.SetAnimation(0, Utilities.GetRandomArrayElement <string>(_appear), false).Complete += OnAppear; }
private void CheckStates() { DivineDebug.Log("State checked in this state: " + _curState); if (_curState == BattleLogicStates.WaitForPartiesReadyToStartFight) { _curState = BattleLogicStates.PartiesReadyToStartFight; WaitToStartBattle(); } else if (_curState == BattleLogicStates.TurnLoop_DoingFightActions) { CheckFightActionList(); } else if (_curState == BattleLogicStates.TryToEndBattle) { TryToEndBattle(); } else if (_curState == BattleLogicStates.TurnLoop_Start) { StartWaitingForActionReceive(); } else if (_curState == BattleLogicStates.TurnLoop_TryToFinishTurn && _currentSelectedCharacter == null) { FinishTurn(); } else if (_curState == BattleLogicStates.WaitForPrefight && _battleEndCame) { OnBattleFinished(); } }
private void SetState_SpecificAnim(CharacterSpecificAnimation animType) { if (_curState != CharacterState.Idle) { return; } if (_isSelected) { return; } _curState = CharacterState.SpecificAnim; DivineDebug.Log("Run Specific Anim " + moniker + " AnimType: " + animType.ToString()); List <CharVisualActionInfo> acts = new List <CharVisualActionInfo>(); CharVisualActionInfo act = new CharVisualActionInfo(); act = new CharVisualActionInfo(); act.actionType = CharVisualActionType.SpecificAnimation; act.specificAnimType = animType; acts.Add(act); _charVisual.StartActionList(acts); if (Event_StateChange != null) { Event_StateChange(this, _curState); } }
//Public Methods public void Init(Party owner, CharInfo charInfo, CharacterVisual charVisual) { _extraSpellHandler = new ExtraSpellHandler(); _charVisual = charVisual; _charVisual.Event_ActionsFinished += OnCharVisualActionsFinish; _charVisual.Event_SpellCast += OnCharVisualSpellCast; _charInfo = charInfo; _currentStats = _charInfo.baseStats; DivineDebug.Log(moniker + " Created with hp: " + _currentStats.hp + " Shield: " + _currentStats.shield); SetOwnerParty(owner); _charVisual.charUI.Init( _charVisual.Tr_HUD_HelperPos, _charVisual.Tr_SelectionButton_HelperPos, _charVisual.Tr_decal_HelperPos); _charVisual.charUI.SubscribeForSelectTarget(SelectedAsTarget); _charVisual.charUI.newCharHUD.Init(_currentStats.maxHp, _currentStats.hp, _currentStats.maxShield, _currentStats.shield, _charInfo.level, side == PartySide.Player, isHero); ResetCharacterUIAndEffect(); _isActive = charInfo.enableInStart; }
private void MakeParties(PartyInfo[] partyInfoes) { DivineDebug.Log("Making Parties started."); int numberOfValidParties = 2; _parties = new Party[numberOfValidParties]; if (partyInfoes.Length > 2) { DivineDebug.Log(String.Concat("party infoes from battle info is more than ", numberOfValidParties, "."), DivineLogType.Error); } for (int i = 0; i < numberOfValidParties; i++) { if (i == 0) { _parties[i] = new Party(partyInfoes[i], PartySide.Player, _battleScene.spawnPointsForLeftSide, _battleScene.selectedPoint_left, UpdateActioPoints); } else { _parties[i] = new Party(partyInfoes[i], PartySide.Enemy, _battleScene.spawnPointsForRightSide, _battleScene.selectedPoint_right, UpdateActioPoints); } } DivineDebug.Log("Making Parties Finished."); }
private void OnBattleFinishedComeFromServer(BattleResultData battleResultData, List <TroopCoolDownData> troopCoolDowns, bool connectionLost) { TimeManager.instance.Event_OneSecTick -= OnSecTick; BattleDataProvider.instance.Event_BattlePingTick -= OnPinging; DivineDebug.Log("Battle Finish Come From Server", DivineLogType.Normal); _battleResultData = battleResultData; GameAnalytics.NewDesignEvent( "Battle Result " + (_battleInfo.isBot ? "With" : "Without") + "Bot: " + (_battleResultData.isVictorious ? "Win" : "Lose")); _battleEndCame = true; PlayerInfo player = GameManager.instance.player; for (int i = 0; i < troopCoolDowns.Count; i++) { player.FindTroop(troopCoolDowns[i].id).SetRemainingCooldownTime(troopCoolDowns[i].remainingSeconds); } if (connectionLost) { OnBattleFinished(); } if (FakeServer.instance.isFake) { OnBattleFinished(); } }
private void OnActionReceived(List <ActionData> actionList) { DivineDebug.Log("Action come from fight data analyzer. In This State: " + _curState.ToString()); DivineDebug.Log("Fight Action Datas: Action Count: " + actionList.Count); for (int i = 0; i < actionList.Count; i++) { actionList[i].Init(this); _actionData.Add(actionList[i]); } if (_curState != BattleLogicStates.TurnLoop_WaitForAction && _curState != BattleLogicStates.WaitForPrefight) { DivineDebug.Log("Action wont run because we are in this state now: " + _curState.ToString()); return; } if (_curState == BattleLogicStates.WaitForPrefight) { BattleDataProvider.instance.Event_BattleTurnTick -= OnFirstTimeTickCome; _waitingToStartNewTurn = true; } StartFightActions(); }
public SpellCastTransData FindProperCastingPos(Divine.Moniker owner, Character target) { if (owner == Divine.Moniker.Archer) { return(FindProperCastingPos_Archer(target)); } else if (owner == Divine.Moniker.Wizard) { return(FindProperCastingPos_Wizard(target)); } else if (owner == Divine.Moniker.Skeleton_Archer) { return(FindProperCastingPos_Archer(target)); } else if (owner == Divine.Moniker.Kharback) { return(FindProperCastingPos_Archer(target)); } else if (owner == Divine.Moniker.FereydounChakra) { return(FindProperCastingPos_ChakraFereydoun(target)); } else if (owner == Divine.Moniker.Fereydoun) { return(FindProperCastingPos_Wizard(target)); } DivineDebug.Log("Find proper pos doesnt support this character: " + target.moniker, DivineLogType.Error); return(null); }
public void DestroyIt() { DivineDebug.Log("Deleting Party with hero named: + " + _hero.moniker); foreach (var ch in _charsDic.Values) { ch.Event_OnClick -= OnCharacterClick; ch.Event_StateChange -= OnCharacterStateChange; ch.Event_SpellReceived -= OnCharacterSpellReceived; ch.Event_ChakraApeared -= OnChakraApear; ch.DestroyIt(); } _hero = null; _charsDic = null; _characters = null; _selectingPoint = null; _currentTargetList = null; Event_PartyReady = null; Event_CharacterDied = null; Event_ChakraAppeared = null; Event_TargetSelected = null; Event_ActionPointChanged = null; }
public void ChangePartyTargetMode(bool isTarget, bool ignoreTaunt = false, List <Character> mustTargetChar = null) { //Do some visual effect for characters if (isTarget) { SetCurrentTargets(ignoreTaunt, mustTargetChar); int ind = 0; foreach (var ch in _currentTargetList) { DivineDebug.Log("PossibleTarget " + ind++ + " named: " + ch.moniker + " isTaunt: " + ch.isTaunt); } } if (_currentTargetList != null) { for (int i = 0; i < _currentTargetList.Count; i++) { _currentTargetList[i].SetTargetStatus(isTarget); } } SetRegisterationForEvent_SelectedAsTarget(isTarget); }
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 UpdateStats(SpellEffectInfo effectInfo, bool isFinal) { DivineDebug.Log("Update Stats for: "); DivineDebug.Log("CurrentHP: " + _currentStats.hp + " FinalHP: " + effectInfo.finalCharacterStats.hp + " IsFinal: " + isFinal); if ((effectInfo.isMultiPart && isFinal) || !effectInfo.isMultiPart) { _currentStats = effectInfo.finalCharacterStats; DivineDebug.Log("moniker " + moniker + " hp: " + _currentStats.hp + " shield: " + _currentStats.shield + " damage: " + _currentStats.damage); charInfo.SetBaseStats(_currentStats.hp, _currentStats.maxHp, _currentStats.damage, _currentStats.shield, _currentStats.maxShield); } else { for (int i = 0; i < effectInfo.singleStatChanges.Count; i++) { switch (effectInfo.singleStatChanges[i].charStatChangeType) { case SpellSingleStatChangeType.None: break; case SpellSingleStatChangeType.curHPValChange: _currentStats.SetHP(_currentStats.hp + effectInfo.singleStatChanges[i].intVal); break; case SpellSingleStatChangeType.curShieldValChange: _currentStats.SetShield(_currentStats.shield + effectInfo.singleStatChanges[i].intVal); break; case SpellSingleStatChangeType.curDamageValChange: _currentStats.damage += effectInfo.singleStatChanges[i].intVal; break; case SpellSingleStatChangeType.curFlagValChange: _currentStats.flags = (BattleFlags)effectInfo.singleStatChanges[i].intVal; break; default: break; } } } DivineDebug.Log("After Update CurrentHP: " + _currentStats.hp + " Shield: " + _currentStats.shield + " Flag: " + _currentStats.flags.ToString()); ShowUpdatingStatsVisual(effectInfo); if (_curState == CharacterState.Idle && _currentStats.hp <= 0) { SetState_Dying(false); } _previousFlag = _currentStats.flags; }
private void OnCharacterSelectAsTarget(Character character) { _currentSelectedTarget = character; _currentSelectedCharacter.SpellSelectionDone(); _newBattleUI.SetTurnFinished(); for (int i = 0; i < _parties.Length; i++) { _parties[i].Event_TargetSelected -= OnCharacterSelectAsTarget; _parties[i].ChangePartyTargetMode(false); } DivineDebug.Log("BattleLogic, char: " + character.moniker); SkillShotType skillShotType = AppearanceConfigData.instance.GetMagicWithIndex(_currentSelectedCharacter.moniker, _currentSelectedSpellIndex)._skillShotType; DivineDebug.Log("OnCharacterSelectAsTarget ----------> skillShotType: " + skillShotType.ToString()); if (skillShotType == SkillShotType.None) { Net_SendAction(character.id, _currentSelectedSpellIndex); } //else // ; //Skill Shot??? //(UIGroup.CreateGroup("Skillshot_" + skillShotType.ToString()) as ISkillshot).Init(OnSkillShotFinished); }
public ChangeStatInfo ApplyDamage(int amount) { DivineDebug.Log("Character " + moniker + " Hp-Shield: " + _stats.hp + " " + _stats.shield, DivineLogType.Warn); if (amount > 0) { DivineDebug.Log("Positive amount for damage is wrong", DivineLogType.Error); _lastChangeStatInfo.SetValues(0, 0); return(_lastChangeStatInfo); } int beforeDmgShield = 0; int amountDecreaseFromHP = 0; int amountDecreaseFromShield = 0; if (_stats.shield > 0) { beforeDmgShield = _stats.shield; _stats.SetShield(_stats.shield + amount); // amount is negative here amountDecreaseFromShield = _stats.shield > 0 ? amount : beforeDmgShield; amount += beforeDmgShield; amount = Mathf.Min(amount, 0); } if (amount < 0) //still has damage to apply { int beforeDmghp = _stats.hp; _stats.SetHP(_stats.hp + amount); amountDecreaseFromHP = _stats.hp > 0 ? amount : beforeDmghp; } _lastChangeStatInfo.SetValues(amountDecreaseFromHP, amountDecreaseFromShield); if (_isActive) { relatedParty.ChangeAP(1); } if (isDead && type == Type.Troop && _isActive) { relatedParty.ChangeAP(2); } DivineDebug.Log("Character " + moniker + " Hp-Shield: " + _stats.hp + " " + _stats.shield, DivineLogType.Warn); if (beforeDmgShield > 0 && shield <= 0 && type == Type.Hero) { CastSpell(2, new List <BtlCtrlCharacter> { relatedParty.chakra }, null, false); } return(_lastChangeStatInfo); }
private void GenerateAP() { DivineDebug.Log("Adding Action Point: " + _spellInfo.generatedActionPoint); _spellInfo.owner.AddActionPoint(_spellInfo.generatedActionPoint); DestroyIt(); }
private void TryToFinishTurn() { DivineDebug.Log("Trying To Finish Turn"); _curState = BattleLogicStates.TurnLoop_TryToFinishTurn; SelectACharacter(_currentSelectedCharacter, null, null, null, null, false); }
private void OnCharacterSelectAsTarget(Character character) { DivineDebug.Log("Party, char: " + character.moniker); if (Event_TargetSelected != null) { Event_TargetSelected(character); } }
private void OnCharacterClick(Character character) { DivineDebug.Log("Char: " + character.moniker + " Clicked."); if (Event_CharacterClicked != null) { Event_CharacterClicked(character); } }
//Private Methods private void OnSecretReveal() { DivineDebug.Log("Running Secret, spelleffectCount:" + _spellInfo.spellEffectInfos.Count); foreach (var effect in _spellInfo.spellEffectInfos) { DivineDebug.Log("SpellEffect:" + effect.effectOnCharacter); } _secretOwner.CastSpell(_spellInfo, 0); }
void Start() { _sklAnim = GetComponentInChildren <SkeletonAnimation>(); if (_sklAnim == null) { DivineDebug.Log("Spell_Range_Spine cant find skeleton for this object " + name); } }
protected override void StartSpell() { _InitialPos = transform.position; Movement movement = GetComponent <Movement>(); if (movement) { Vector3 targetPos = GetTargetPos(); Vector3 targetScale = _spellInfo.spellEffectInfos[0].targetCharacter.scale; Vector3 endPos = Utilities.FindHitPointWithOffset(new Vector2(_offsetX, _offsetY), targetPos, targetScale); MoveInfo mi = new MoveInfo(endPos); mi.easeType = _easeType; bool shouldRotate = true; ParticleSystem parSys = transform.GetComponentInChildren <ParticleSystem>(); if (_spellInfo.owner.isFliped) { if (parSys == null) { transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z); } else // For particle we should change scale of each not the parent { parSys.transform.localScale = new Vector3(parSys.transform.localScale.x * -1, parSys.transform.localScale.y, parSys.transform.localScale.z); } } if (parSys != null) { shouldRotate = false; float angleDif = Utilities.AngleBetweenToPoint(transform.position, endPos, true); float angleRad = (angleDif * 2f * 3.14f) / 360f; var main = parSys.main; main.startRotation = new ParticleSystem.MinMaxCurve(angleRad); parSys.Play(); } movement.StartMovement(mi, OnReachTarget, shouldRotate); } else { DivineDebug.Log("This Spell: " + gameObject.name + " doesnt have movement."); } }
private void OnSpellSelectedByCurrentChar(Character character, int spellIndex) { for (int i = 0; i < _parties.Length; i++) { _parties[i].Event_TargetSelected -= OnCharacterSelectAsTarget; _parties[i].ChangePartyTargetMode(false); } _currentSelectedSpellIndex = spellIndex; SpellTargetType tarType = AppearanceConfigData.instance. GetMagicWithIndex(character.moniker, spellIndex)._targetType; bool isSplash = AppearanceConfigData.instance. GetMagicWithIndex(character.moniker, spellIndex)._isSplash; bool ignoreTaunt = (tarType == SpellTargetType.Ally) || isSplash; switch (tarType) { case SpellTargetType.Ally: _parties[0].Event_TargetSelected += OnCharacterSelectAsTarget; _parties[0].ChangePartyTargetMode(true, ignoreTaunt); break; case SpellTargetType.Enemy: _parties[1].Event_TargetSelected += OnCharacterSelectAsTarget; _parties[1].ChangePartyTargetMode(true, ignoreTaunt); break; case SpellTargetType.All: _parties[0].Event_TargetSelected += OnCharacterSelectAsTarget; _parties[0].ChangePartyTargetMode(true, true); _parties[1].Event_TargetSelected += OnCharacterSelectAsTarget; _parties[1].ChangePartyTargetMode(true, ignoreTaunt); break; case SpellTargetType.Self: _parties[0].Event_TargetSelected += OnCharacterSelectAsTarget; _parties[0].ChangePartyTargetMode(true, ignoreTaunt, new List <Character> { character }); break; default: break; } DivineDebug.Log("OnSpellSelectedByCurrentChar, targetType: " + tarType.ToString()); DivineDebug.Log("OnSpellSelectedByCurrentChar, char: " + character.moniker); if (characterVisitor != null) { characterVisitor.OnCharacterSpellSelected(character, spellIndex); } }
private void Show_EffectForFlagChange(BattleFlags newFlag, bool isFromTurnStat) { DivineDebug.Log("Show_EffectForFlagChange New: " + newFlag.ToString() + " Prev: " + _previousFlag.ToString()); _charVisual.charUI.newCharHUD.ResetActiveEffects(newFlag); _extraSpellHandler.SetExtraSpells(_previousFlag, newFlag, position_pivot, scale, _charVisual, isFromTurnStat); _charVisual.charEffects.HandleChangingFlag(newFlag, _previousFlag, scale); }
protected void ApplySpellEffectsAndDestroyIt() { DivineDebug.Log("Spell Effect Info Count: " + _spellInfo.spellEffectInfos.Count); for (int i = 0; i < _spellInfo.spellEffectInfos.Count; i++) { ApplySpellEffect(i); } DestroyIt(); }
//Private Methods private void Init(PartyInfo partyInfo, PartySide side, Transform[] initialPoints, Transform selectingPoint, Deleg_ActionPointChanged onActionPointChanged) { DivineDebug.Log("Initing party started."); _side = side; _name = partyInfo.Name; _secrets = partyInfo.availableSecrets; _actionPoint = partyInfo.actionPoint; Event_ActionPointChanged += onActionPointChanged; _selectingPoint = selectingPoint; _charsDic = new Dictionary <long, Character>(); //Build Hero _hero = BuildCharacter(partyInfo.heroInfo, initialPoints[0], true) as Hero; _hero.Event_StateChange += OnCharacterStateChange; _charsDic.Add(partyInfo.heroInfo.uniqueID, _hero); _characters = new Character[partyInfo.charInfoes.Length]; for (int i = 0; i < partyInfo.charInfoes.Length; i++) { if (i + 1 < initialPoints.Length) { _characters[i] = BuildCharacter(partyInfo.charInfoes[i], initialPoints[i + 1], false); } else { _characters[i] = BuildCharacter(partyInfo.charInfoes[i], initialPoints[0], false); //For Chakra } _characters[i].Event_StateChange += OnCharacterStateChange; _characters[i].Event_ChakraApeared += OnChakraApear; _charsDic.Add(partyInfo.charInfoes[i].uniqueID, _characters[i]); } //Register charaters for click and receive spells foreach (Character ch in _charsDic.Values) { ch.Event_OnClick += OnCharacterClick; ch.Event_SpellReceived += OnCharacterSpellReceived; } //if (!FakeServer.instance.isFake) //{ _characters[_characters.Length - 1].SetIsChakra(true); _chakra = _characters[_characters.Length - 1]; //} }
private void Net_SendAction(long id, int currentSelectedSpellIndex, int skillShotValue) { List <long> targets = new List <long>(); targets.Add(id); DivineDebug.Log("Sending Action Data With Skill Shot-> Selected spell index: " + currentSelectedSpellIndex + " target: " + GetCharacterWithID(id).moniker + " ID: " + id + " Skillshot Value: " + skillShotValue); NetworkManager.instance.Move(_currentSelectedCharacter.id, currentSelectedSpellIndex, skillShotValue, targets); }