private List <CharacterBhv> IsOpponentInZone(int x, int y) { var character = _currentCharacterBhv.Character; if (character.Weapons[_currentWeaponId].RangeZones == null) { return(null); } List <CharacterBhv> tmpTouchedOpponents = new List <CharacterBhv>(); foreach (var tmpDirection in character.Weapons[_currentWeaponId].RangeZones) { var tmpPos = Helper.DetermineRangePosFromRangeDirection(x - _currentCharacterBhv.X, y - _currentCharacterBhv.Y, tmpDirection); var tmpX = tmpPos.X + x; var tmpY = tmpPos.Y + y; if (!Helper.IsPosValid(tmpX, tmpY)) { continue; } var cell = Cells[tmpX, tmpY].GetComponent <CellBhv>(); CharacterBhv tmpTouched = null; if (cell.Type == CellType.On && (tmpTouched = IsOpponentOnCell(tmpX, tmpY)) != null) { tmpTouchedOpponents.Add(tmpTouched); continue; } } if (tmpTouchedOpponents.Count != 0) { return(tmpTouchedOpponents); } return(null); }
public bool IsOpponentInSkillRange(CharacterBhv characterBhv, int skillId, List <CharacterBhv> opponentBhvs) { _currentCharacterBhv = characterBhv; _currentOpponentBhvs = opponentBhvs; var character = characterBhv.Character; for (int i = 0; i < character.Skills[skillId].RangePositions?.Count; i += 2) { var x = character.Skills[skillId].RangePositions[i] + characterBhv.X; var y = character.Skills[skillId].RangePositions[i + 1] + characterBhv.Y; if (!Helper.IsPosValid(x, y)) { continue; } var cell = Cells[x, y].GetComponent <CellBhv>(); if (cell.Type == CellType.On) { if (IsAnythingBetween(characterBhv.X, characterBhv.Y, x, y)) { continue; } else if (IsOpponentOnCell(x, y) != null) { return(true); } } } return(false); }
public RangePos IsOpponentInWeaponRangeAndZone(CharacterBhv characterBhv, int weaponId, List <CharacterBhv> opponentBhvs) { _currentCharacterBhv = characterBhv; _currentOpponentBhvs = opponentBhvs; _currentWeaponId = weaponId; var character = characterBhv.Character; for (int i = 0; i < character.Weapons[weaponId].RangePositions.Count; i += 2) { var x = character.Weapons[weaponId].RangePositions[i] + characterBhv.X; var y = character.Weapons[weaponId].RangePositions[i + 1] + characterBhv.Y; if (!Helper.IsPosValid(x, y)) { continue; } var cell = Cells[x, y].GetComponent <CellBhv>(); if (cell.Type == CellType.On) { if (IsAnythingBetween(characterBhv.X, characterBhv.Y, x, y)) { continue; } else if (IsOpponentOnCell(x, y) != null || IsOpponentInZone(x, y) != null) { return(new RangePos(x, y)); } } } return(null); }
public void ShowWeaponRange(CharacterBhv characterBhv, int weaponId, List <CharacterBhv> opponentBhvs) { ResetAllCellsDisplay(); _currentCharacterBhv = characterBhv; _currentOpponentBhvs = opponentBhvs; _currentWeaponId = weaponId; var character = characterBhv.Character; for (int i = 0; i < character.Weapons[weaponId].RangePositions.Count; i += 2) { var x = character.Weapons[weaponId].RangePositions[i] + characterBhv.X; var y = character.Weapons[weaponId].RangePositions[i + 1] + characterBhv.Y; if (!Helper.IsPosValid(x, y)) { continue; } var cell = Cells[x, y].GetComponent <CellBhv>(); if (cell.Type == CellType.On && cell.State == CellState.None) { if (IsAnythingBetween(characterBhv.X, characterBhv.Y, x, y)) { cell.ShowWeaponOutOfRange(); } else { cell.ShowWeaponRange(); } } } }
public void SetPrivates() { _characterBhv = GetComponent <CharacterBhv>(); _opponentBhv = _characterBhv.OpponentBhvs[0]; _gridBhv = GameObject.Find(Constants.GoSceneBhvName).GetComponent <GridBhv>(); _fightSceneBhv = GameObject.Find(Constants.GoSceneBhvName).GetComponent <FightSceneBhv>(); }
public override void OnEndAttack(int damages, CharacterBhv opponentBhv) { CharacterBhv.Instantiator.NewEffect(InventoryItemType.Skill, CharacterBhv.transform.position, null, EffectId, Constants.GridMax - CharacterBhv.Y); float goldToSteal = CharacterBhv.Character.Gold * Helper.MultiplierFromPercent(0, _percentToSteal); CharacterBhv.Character.GainGold((int)goldToSteal); }
public virtual void Init(CharacterBhv characterBhv, List <CharacterBhv> opponentBhvs, GridBhv gridBhv, int id) { CharacterBhv = characterBhv; OpponentBhvs = opponentBhvs; GridBhv = gridBhv; Id = id; }
private void AddToLoot(CharacterBhv opponentBhv) { if (_loot == null) { _loot = new List <InventoryItem>(); } var drop = Random.Range(0, 100); if (drop > PlayerBhv.Character.LootPercent) { return; } var type = Random.Range(0, Helper.EnumCount <InventoryItemType>()); InventoryItem item = null; if (type == InventoryItemType.Weapon.GetHashCode()) { item = opponentBhv.Character.Weapons[Random.Range(0, 2)]; } else if (type == InventoryItemType.Skill.GetHashCode()) { item = opponentBhv.Character.Skills[Random.Range(0, 2)]; } else if (type == InventoryItemType.Item.GetHashCode()) { item = ItemsData.GetRandomItem(); } if (item == null) { return; } item.LootHistory = "Looted from " + opponentBhv.Character.Name + ",\na level " + opponentBhv.Character.Level + " " + opponentBhv.Character.Race; _loot.Add(item); }
private void RemoveOpponentFromExistence(CharacterBhv opponentBhv) { for (int i = 0; i < _orderList.Count; ++i) { if (_orderList[i].Id == opponentBhv.OrderId) { if (i < _currentOrderId) { --_currentOrderId; } _orderList.RemoveAt(i); break; } } for (int i = 0; i < PlayerBhv.OpponentBhvs.Count; ++i) { if (PlayerBhv.OpponentBhvs[i].OrderId == opponentBhv.OrderId) { PlayerBhv.OpponentBhvs.RemoveAt(i); break; } } for (int i = 0; i < OpponentBhvs.Count; ++i) { if (OpponentBhvs[i].OrderId == opponentBhv.OrderId) { OpponentBhvs.RemoveAt(i); break; } } }
public void ShowSkillRange(RangeType rangeType, CharacterBhv characterBhv, int skillId, List <CharacterBhv> opponentBhvs, bool hasToBeEmpty = false) { ResetAllCellsDisplay(); ResetAllCellsVisited(); ResetAllCellsSkillVisited(); _currentCharacterBhv = characterBhv; _currentOpponentBhvs = opponentBhvs; _currentSkillId = skillId; var character = characterBhv.Character; if (rangeType != RangeType.FullRange) { if (character.Skills[skillId].RangePositions == null || character.Skills[skillId].RangePositions.Count == 0) { return; } for (int i = 0; i < character.Skills[skillId].RangePositions.Count; i += 2) { var x = character.Skills[skillId].RangePositions[i] + characterBhv.X; var y = character.Skills[skillId].RangePositions[i + 1] + characterBhv.Y; ShowSkillRangeOnPosition(x, y, hasToBeEmpty, rangeType, characterBhv); } } else { for (int x = 0; x < Constants.GridMax; ++x) { for (int y = 0; y < Constants.GridMax; ++y) { ShowSkillRangeOnPosition(x, y, hasToBeEmpty, rangeType, characterBhv); } } } }
public void Debuff(CharacterBhv debuffedOpponentBhv) { if (debuffedOpponentBhv == null) { return; } debuffedOpponentBhv.ClearAllSkillEffects(isDebuff: true); }
public virtual void OnPlayerDeath(CharacterBhv playerBhv) { playerBhv.Character.IsDead = true; StartCoroutine(Helper.ExecuteAfterDelay(1.0f, () => { Defeat(playerBhv.Character); return(true); })); }
public override void Activate(int x, int y) { base.Activate(x, y); CharacterBhv.StartCoroutine(Helper.ExecuteAfterDelay(PlayerPrefsHelper.GetSpeed(), () => { AfterActivation(); return(true); })); }
public override void Activate(int x, int y) { base.Activate(x, y); CharacterBhv.StartCoroutine(Helper.ExecuteAfterDelay(PlayerPrefsHelper.GetSpeed(), () => { CharacterBhv.Instantiator.NewEffect(InventoryItemType.Skill, GridBhv.Cells[x, y].transform.position, null, EffectId, Constants.GridMax - y); CharacterBhv.MoveToPosition(x, y, false); return(true); })); }
public void Smite(CharacterBhv smitedOpponentBhv) { if (smitedOpponentBhv == null) { return; } var floatAmount = 100.0f * CharacterBhv.Character.GetDamageMultiplier(); smitedOpponentBhv.TakeDamages(new Damage((int)floatAmount)); }
public override int OnTakeDamage(int damages) { if (IsApplyingEffect()) { EffectDuration = 0; CharacterBhv.Instantiator.NewEffect(InventoryItemType.Skill, CharacterBhv.transform.position, null, EffectId, Constants.GridMax - CharacterBhv.Y); CharacterBhv.LoseSkillEffect(Effect); return(0); } return(damages); }
public override void Activate(int x, int y) { base.Activate(x, y); CharacterBhv.StartCoroutine(Helper.ExecuteAfterDelay(PlayerPrefsHelper.GetSpeed(), () => { CharacterBhv.Instantiator.NewEffect(InventoryItemType.Skill, CharacterBhv.transform.position, null, EffectId, Constants.GridMax - CharacterBhv.Y); _floatHealAmount = 50.0f * Helper.MultiplierFromPercent(1, 10 * (CharacterBhv.Character.Level - 1)); CharacterBhv.GainHp((int)_floatHealAmount); AfterActivation(); return(true); })); }
public override void OnStartTurn() { CharacterBhv.Instantiator.PopIcon(Helper.GetSpriteFromSpriteSheet("Sprites/IconsSkill_" + IconId), CharacterBhv.transform.position); CharacterBhv.StartCoroutine(Helper.ExecuteAfterDelay(PlayerPrefsHelper.GetSpeed(), () => { CharacterBhv.Instantiator.NewEffect(InventoryItemType.Skill, CharacterBhv.transform.position, null, EffectId, Constants.GridMax - CharacterBhv.Y); float hpToRestore = (CharacterBhv.Character.HpMax * 0.05f); //hpToRestore *= Helper.MultiplierFromPercent(1.0f, Random.Range(0, 51)); CharacterBhv.GainHp((int)hpToRestore); return(true); })); }
public override void Activate(int x, int y) { base.Activate(x, y); _currentTargetX = x; _currentTargetY = y; //CharacterBhv.GainSkillEffect(SkillEffect.Immuned); CharacterBhv.StartCoroutine(Helper.ExecuteAfterDelay(PlayerPrefsHelper.GetSpeed(), () => { CharacterBhv.LosePm(CharacterBhv.Character.PmMax); AfterActivation(); return(true); })); }
public override void Activate(int x, int y) { base.Activate(x, y); CharacterBhv.StartCoroutine(Helper.ExecuteAfterDelay(PlayerPrefsHelper.GetSpeed(), () => { var result = Grap(GridBhv.IsOpponentOnCell(x, y)); if (result == false) { AfterGrap(); } return(true); })); }
private void SpreadPmStart(int x, int y, int nbPm, CharacterBhv characterBhv, List <CharacterBhv> opponentBhvs) { var spentPm = 1; if (IsAdjacentOpponent(x, y, opponentBhvs)) { --nbPm; ++spentPm; } SpreadPm(x, y + 1, nbPm, spentPm, characterBhv, opponentBhvs); SpreadPm(x + 1, y, nbPm, spentPm, characterBhv, opponentBhvs); SpreadPm(x, y - 1, nbPm, spentPm, characterBhv, opponentBhvs); SpreadPm(x - 1, y, nbPm, spentPm, characterBhv, opponentBhvs); }
public override int OnTakeDamage(int damages) { if (IsApplyingEffect()) { if (Helper.IsPosValid(_currentTargetX, _currentTargetX) && !GridBhv.IsOpponentOnCell(_currentTargetX, _currentTargetY, true, true)) { CharacterBhv.MoveToPosition(_currentTargetX, _currentTargetY, false); CharacterBhv.Instantiator.NewEffect(InventoryItemType.Skill, GridBhv.Cells[_currentTargetX, _currentTargetY].transform.position, null, EffectId, Constants.GridMax - _currentTargetY); } EffectDuration = 0; CharacterBhv.LoseSkillEffect(Effect); return(0); } return(damages); }
public void ShowPm(CharacterBhv characterBhv, List <CharacterBhv> opponentBhvs, bool unlimitedPm = false) { ResetAllCellsVisited(); ResetAllCellsDisplay(); _currentCharacterBhv = characterBhv; _currentOpponentBhvs = opponentBhvs; var nbPm = unlimitedPm ? Constants.UnlimitedPm : characterBhv.GetComponent <CharacterBhv>().Pm; int x = characterBhv.GetComponent <CharacterBhv>().X; int y = characterBhv.GetComponent <CharacterBhv>().Y; if (nbPm <= 0) { return; } SpreadPmStart(x, y, nbPm, characterBhv, opponentBhvs); }
public void OnOpponentDeath(CharacterBhv opponentBhv) { opponentBhv.SkinContainer.OnDeath(); Instantiator.PopIcon(Helper.GetSpriteFromSpriteSheet("Sprites/IconsStatus_0"), opponentBhv.transform.position); StartCoroutine(Helper.ExecuteAfterDelay(1.0f, () => { PlayerBhv.Character.GainGold(opponentBhv.Character.Gold); PlayerBhv.Character.GainXp(Helper.XpWorthForLevel(opponentBhv.Character.Level)); RemoveOpponentFromExistence(opponentBhv); AddToLoot(opponentBhv); Destroy(opponentBhv.gameObject); if (_orderList.Count == 1) { Invoke(nameof(EndFightVictory), 1.0f); } return(true); })); }
public bool Grap(CharacterBhv grabbedOpponentBhv) { _grabbedOpponentBhv = grabbedOpponentBhv; if (_grabbedOpponentBhv == null) { return(false); } _grabbedOpponentBhv.AfterMouvementDelegate = AfterGrap; int x = CharacterBhv.X - _grabbedOpponentBhv.X; int y = CharacterBhv.Y - _grabbedOpponentBhv.Y; if (x != 0) { x = x < 0 ? ++x : --x; } if (y != 0) { y = y < 0 ? ++y : --y; } while (x != 0) { if (GridBhv.Cells[_grabbedOpponentBhv.X + x, _grabbedOpponentBhv.Y + y].GetComponent <CellBhv>().Type == CellType.On) { _grabbedOpponentBhv.MoveToPosition(_grabbedOpponentBhv.X + x, _grabbedOpponentBhv.Y + y, false); break; } x = x < 0 ? ++x : --x; } while (y != 0) { if (GridBhv.Cells[_grabbedOpponentBhv.X + x, _grabbedOpponentBhv.Y + y].GetComponent <CellBhv>().Type == CellType.On) { _grabbedOpponentBhv.MoveToPosition(_grabbedOpponentBhv.X + x, _grabbedOpponentBhv.Y + y, false); break; } y = y < 0 ? ++y : --y; } CharacterBhv.Instantiator.NewEffect(InventoryItemType.Skill, GridBhv.Cells[_grabbedOpponentBhv.X + x, _grabbedOpponentBhv.Y + y].transform.position, null, EffectId, Constants.GridMax - (_grabbedOpponentBhv.Y + y)); return(true); }
private void SpreadPm(int x, int y, int nbPm, int spentPm, CharacterBhv characterBhv, List <CharacterBhv> opponentBhvs) { if (!Helper.IsPosValid(x, y) || (opponentBhvs != null && IsOpponentOnCell(x, y, true)) || nbPm <= 0) { return; } var cell = Cells[x, y]; if (cell == null || (x == characterBhv.X && y == characterBhv.Y)) { return; } if (cell.GetComponent <CellBhv>().Type == CellType.On && (spentPm < cell.GetComponent <CellBhv>().Visited || cell.GetComponent <CellBhv>().Visited == -1) && (opponentBhvs == null || !IsOpponentOnCell(x, y, true))) { //if (characterBhv.IsPlayer) cell.GetComponent <CellBhv>().ShowPm(); cell.GetComponent <CellBhv>().Visited = spentPm; //DEBUG// //cell.transform.GetChild(0).GetComponent<UnityEngine.UI.Text>().text = cell.GetComponent<CellBhv>().Visited.ToString(); if (--nbPm > 0) { if (IsAdjacentOpponent(x, y, opponentBhvs)) { --nbPm; ++spentPm; //cell.GetComponent<CellBhv>().Visited = spentPm; } if (nbPm > 0) { SpreadPm(x, y + 1, nbPm, spentPm + 1, characterBhv, opponentBhvs); SpreadPm(x + 1, y, nbPm, spentPm + 1, characterBhv, opponentBhvs); SpreadPm(x, y - 1, nbPm, spentPm + 1, characterBhv, opponentBhvs); SpreadPm(x - 1, y, nbPm, spentPm + 1, characterBhv, opponentBhvs); } } } }
public override void OnEndAttack(int damages, CharacterBhv opponentBhv) { int tmp = Random.Range(0, 100); int pmToRemove; if (tmp < 5) { pmToRemove = 0; } else if (tmp < 50) { pmToRemove = 1; } else if (tmp < 95) { pmToRemove = 2; } else { pmToRemove = 3; } opponentBhv?.LosePm(pmToRemove); }
private int CalculateInitiative(CharacterBhv characterBhv, int orderId = -1) { int initiative = 0; initiative += (characterBhv.Character.Level - 1) * RacesData.InitiativeLevel; if (characterBhv.Character.Weapons != null) { if (characterBhv.Character.Weapons.Count > 0) { initiative += characterBhv.Character.Weapons[0].Rarity.GetHashCode() * RacesData.InitiativeWeapon; } if (characterBhv.Character.Weapons.Count > 1) { initiative += characterBhv.Character.Weapons[1].Rarity.GetHashCode() * RacesData.InitiativeWeapon; } } if (characterBhv.Character.Skills != null) { if (characterBhv.Character.Skills.Count > 0) { initiative += characterBhv.Character.Skills[0].Rarity.GetHashCode() * RacesData.InitiativeSkill; } if (characterBhv.Character.Skills.Count > 1) { initiative += characterBhv.Character.Skills[1].Rarity.GetHashCode() * RacesData.InitiativeSkill; } } initiative += characterBhv.Character.Hp / characterBhv.Character.HpMax * 100; initiative += _map.Type == characterBhv.Character.StrongIn ? RacesData.InitiativeStrongIn : 0; if (orderId != -1) { characterBhv.Initiative = initiative; characterBhv.OrderId = orderId; _orderList.Add(new CharOrder(orderId, initiative)); } return(initiative); }
public bool Push(CharacterBhv pushedOpponentBhv) { _pushedOpponentBhv = pushedOpponentBhv; if (_pushedOpponentBhv == null) { return(false); } int x = _pushedOpponentBhv.X - CharacterBhv.X; int y = _pushedOpponentBhv.Y - CharacterBhv.Y; if (!Helper.IsPosValid(_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y) || GridBhv.Cells[_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y].GetComponent <CellBhv>().Type != CellType.On || GridBhv.IsOpponentOnCell(_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y, true)) { if ((Helper.IsPosValid(_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y) && GridBhv.Cells[_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y].GetComponent <CellBhv>().Type == CellType.Off) || GridBhv.IsOpponentOnCell(_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y, true)) { var floatAmount = 30.0f * CharacterBhv.Character.GetDamageMultiplier(); //pushedOpponentBhv.TakeDamages(new Damage((int)floatAmount)); var damage = new Damage((int)floatAmount); CharacterBhv.Instantiator.PopText("-" + pushedOpponentBhv.Character.TakeDamages(damage.Amount).ToString(), pushedOpponentBhv.transform.position, damage.Critical ? TextType.HpCritical : TextType.Hp); pushedOpponentBhv.SkinContainer.OnHit(); } else if (!Helper.IsPosValid(_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y) || GridBhv.Cells[_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y].GetComponent <CellBhv>().Type == CellType.Impracticable) { pushedOpponentBhv.LosePm(1); } return(false); } _pushedOpponentBhv.AfterMouvementDelegate = AfterPush; _pushedOpponentBhv.MoveToPosition(_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y, false); CharacterBhv.Instantiator.NewEffect(InventoryItemType.Skill, GridBhv.Cells[_pushedOpponentBhv.X + x, _pushedOpponentBhv.Y + y].transform.position, null, EffectId, Constants.GridMax - (_pushedOpponentBhv.Y + y)); return(true); }
public override void OnPlayerDeath(CharacterBhv playerBhv) { playerBhv.SkinContainer.OnDeath(); Instantiator.PopIcon(Helper.GetSpriteFromSpriteSheet("Sprites/IconsStatus_0"), playerBhv.transform.position); base.OnPlayerDeath(playerBhv); }