void DefenseSent(DefenseInfo _info) { if (BallPhysics.instance.state == BallPhysics.BallState.Waiting) { m_receivedDefense = true; //para que tire siempre que se haya hecho ya la defensa } }
void CalcDefenseResult(DefenseInfo _info) { if (m_gestureReady) { return; } //kickEffects.instance.defenseCircle(_info); m_gestureReady = true; m_defensePoint = _info.Target; if (m_ballReady) { GetGrab(_info.Target); ShotResultService.noDefense = false; /*if(GameplayService.IsGoalkeeper() && GameplayService.networked) * { * MsgDefend msg = Shark.instance.mensaje<MsgDefend>(); * msg.LoadDefense(preResult, lastResult); * msg.send(); * m_networkDefenseSent = true; * }*/ } else { lastResult = GKResult.Early; } }
public Vector3 GetGrab(Vector3 _target) { DefenseInfo info = new DefenseInfo { Target = _target, ForcedResult = false }; return(GetGrab(info)); }
public void OnDefenseExecuted(DefenseInfo defenseInfo) { if (DefenseExecuted != null) { lastDefense = defenseInfo; DefenseExecuted(defenseInfo); } }
public async Task GetArmor(string address) { IConfiguration config = Configuration.Default.WithDefaultLoader(l => l.IsResourceLoadingEnabled = true).WithCss(); IBrowsingContext context = BrowsingContext.New(config); var page = await context.OpenAsync(address); SetInfo setinfo = GetSetInfo(page); ConsoleWriters.StartingPageMessage($"Starting the {setinfo.armor_set} set."); var tables = page.QuerySelectorAll(".table"); var defense_trs = tables[0].QuerySelectorAll("tbody tr").SkipLast(1); var skill_table = tables[1].Children[1].Children.ToArray(); var create_table = tables[2].Children[1].Children.ToArray(); var upgrade_table = tables[4].Children[1].Children.ToArray(); // Skip the last tr, because that is the total foreach (var tr in defense_trs) { DefenseInfo definfo = GetArmorPieceDefenseInfo(tr); int tr_index = tr.ParentElement.Children.Index(tr); ArmorSkillInfo asi = GetArmorSkills(skill_table[tr_index]); Armor piece = new Armor() { armor_name = definfo.armor_name, armor_set = setinfo.armor_set, armor_description = setinfo.piece_descriptions[tr_index], rarity = setinfo.rarity, max_upgrade = setinfo.max_upgrade, monster_id = setinfo.monster_id, is_blademaster = setinfo.is_blademaster, is_gunner = setinfo.is_gunner, is_male = setinfo.is_male, is_female = setinfo.is_female, min_armor_defense = definfo.min_defense, max_armor_defense = definfo.max_defense, fire_def = definfo.fire_defense, water_def = definfo.water_defense, thunder_def = definfo.thunder_defense, ice_def = definfo.ice_defense, dragon_def = definfo.dragon_def, slots = asi.slots, }; await db.InsertAsync(piece); foreach (ArmorSkill skill in asi.skills) { skill.armor_id = piece.armor_id; } await Task.WhenAll( db.InsertAllAsync(asi.skills), db.InsertAllAsync(GetArmorScraps(create_table[tr_index], "create", piece.armor_id)), db.InsertAllAsync(GetArmorScraps(upgrade_table[tr_index], "upgrade", piece.armor_id)), db.InsertAllAsync(GetArmorCrafts(create_table[tr_index], piece.armor_id)), db.InsertAllAsync(GetArmorUpgradeItems(upgrade_table[tr_index], piece.armor_id)) ); } ConsoleWriters.CompletionMessage($"Finished with the {setinfo.armor_set} set!"); }
public int GetFinalDamage(DefenseInfo di, out bool isCriticalHit, ActionController target) { int ret = 0; ret = DamageCounter.Result(_attackInfo, di, out isCriticalHit, _owner, target); if (isCriticalHit && _owner.IsPlayerSelf) { _owner.IsCriticalHit = isCriticalHit; } return(ret); }
public DefenseInfo UnloadDefense(DefenseInfoNet _info) { DefenseInfo result = new DefenseInfo(); result.Target = new Vector3(_info.X, _info.Y, _info.Z); result.ForcedResult = true; result.Result = _info.success ? (_info.perfect ? GKResult.Perfect : GKResult.Good) : (_info.precisionFail ? GKResult.Fail : (_info.late ? GKResult.Late : GKResult.Early)); if (_info.noDefense) { result.Result = GKResult.Idle; //cuidado con las prioridades!! } return(result); }
public int GetFinalDamage(DefenseInfo di, out bool isCriticalHit, ActionController target) { isCriticalHit = false; if (_enableDamage) { int ret = 0; ret = DamageCounter.Result(_attackInfo, di, out isCriticalHit, _owner, target); if (isCriticalHit) { _owner.IsCriticalHit = isCriticalHit; } return(ret); } return(0); }
void StopGKTuto(DefenseInfo _info) { if (!GameplayService.IsGoalkeeper()) { return; } hide = true; step++; if (step > 1) { isActive = false; PopUpVisible(false); line.SetVertexCount(0); } }
void sendDefense(Vector2 _screenPosition) { Blocked = true; Ray ray = Camera.main.ScreenPointToRay(_screenPosition); float distance; planeGoalClose.Raycast(ray, out distance); Vector3 target = ray.GetPoint(distance); DefenseInfo defenseInfo = new DefenseInfo(); if (target.y < 0) { target.y = 0.1f; } defenseInfo.Target = target; ServiceLocator.Request <IDefenseService>().OnDefenseExecuted(defenseInfo); }
public DefenseInfo GetArmorPieceDefenseInfo(IElement tr) { DefenseInfo def_info = new DefenseInfo(); string[] defenses = tr.Children[1].TextContent.Split('-'); return(new DefenseInfo() { armor_name = tr.FirstElementChild.TextContent, min_defense = defenses[0].ToInt(), max_defense = defenses[1].ToInt(), fire_defense = tr.Children[2].TextContent.ToInt(), water_defense = tr.Children[3].TextContent.ToInt(), thunder_defense = tr.Children[4].TextContent.ToInt(), ice_defense = tr.Children[5].TextContent.ToInt(), dragon_def = tr.Children[6].TextContent.ToInt(), }); }
public override void process() { InputManager.instance.m_timeToThrow = InputManager.instance.deltaTimeToThrow; GoalCamera.instance.stateMachine.changeState = ThrowerCameraStates.Wait.instance; //Time.timeScale = ServiceLocator.Request<IGameplayService>().GetGameMode() == GameMode.GoalKeeper ? 0.8f : 1f; //TODO parametrizar mejor los tiempos de cada modo de juego ServiceLocator.Request <IGameplayService>().ResetTime(); DefenseInfo infoR = UnloadDefense(info); Goalkeeper.instance.m_futureDefense = infoR; Goalkeeper.instance.SetupNetworkDefense(infoR); if (info.powerupUsed != -1) { PowerupService.instance.UsePowerup((Powerup)info.powerupUsed); } if (!ignoreState) { Player.serverState = state; } }
public Eot[] GetEots(DefenseInfo di) { if (_hitInfo != null && _hitInfo.Length > 0) { foreach (Eot eot in _hitInfo[_step]._eots) { eot.IsFrom2p = _isFrom2P; switch (eot.eotType) { case Eot.EOT_TYPE.EOT_PHYSICAL: eot.OwnerDamage = _attackInfo._attackPoints[0] - di._defensePoints[0]; break; case Eot.EOT_TYPE.EOT_FIRE: eot.OwnerDamage = _attackInfo._attackPoints[1] - di._defensePoints[1]; break; case Eot.EOT_TYPE.EOT_ICE: eot.OwnerDamage = _attackInfo._attackPoints[1] - di._defensePoints[1]; break; case Eot.EOT_TYPE.EOT_THUNDER: eot.OwnerDamage = _attackInfo._attackPoints[1] - di._defensePoints[1]; break; case Eot.EOT_TYPE.EOT_POISON: eot.OwnerDamage = _attackInfo._attackPoints[1] - di._defensePoints[1]; break; default: eot.OwnerDamage = _attackInfo._attackPoints[0] - di._defensePoints[0]; break; } } return(_hitInfo[_step]._eots); } return(null); }
public Eot[] GetEots(DefenseInfo di) { if (_owner.ACGetCurrentAttack() != null) { foreach (Eot eot in _owner.ACGetCurrentAttack()._eots) { switch (eot.eotType) { case Eot.EOT_TYPE.EOT_PHYSICAL: eot.OwnerDamage = _attackInfo._attackPoints[0] - di._defensePoints[0]; break; case Eot.EOT_TYPE.EOT_FIRE: eot.OwnerDamage = _attackInfo._attackPoints[1] - di._defensePoints[1]; break; case Eot.EOT_TYPE.EOT_ICE: eot.OwnerDamage = _attackInfo._attackPoints[1] - di._defensePoints[1]; break; case Eot.EOT_TYPE.EOT_THUNDER: eot.OwnerDamage = _attackInfo._attackPoints[1] - di._defensePoints[1]; break; case Eot.EOT_TYPE.EOT_POISON: eot.OwnerDamage = _attackInfo._attackPoints[1] - di._defensePoints[1]; break; default: eot.OwnerDamage = _attackInfo._attackPoints[0] - di._defensePoints[0]; break; } } return(_owner.ACGetCurrentAttack()._eots); } return(null); }
public override void Draw(SpriteBatch Target) { if (Visible) { var TmpCardNameColor = CardName.color; var TmpDamageInfoColor = DamageInfo.color; var TmpDefenseInfoColor = DefenseInfo.color; var TmpAttDistInfoColor = AttackDistanceInfo.color; var TmpMovePointsInfoColor = MovePointsInfo.color; var TmpHPInfoColor = HPInfo.color; var TmpMoneyInfoColor = MoneyInfo.color; if (!Enabled) { CurrentFrame = DisabledFrame; CardName.color = Color.Gray; DamageInfo.color = Color.Gray; DefenseInfo.color = Color.Gray; AttackDistanceInfo.color = Color.Gray; MovePointsInfo.color = Color.Gray; HPInfo.color = Color.Gray; MoneyInfo.color = Color.Gray; } Target.Draw(Texture, Position, null, new Rectangle(Convert.ToInt32(CurrentFrame * FrameSize.X), 0, Convert.ToInt32(FrameSize.X), Convert.ToInt32(FrameSize.Y)), RotationPoint, 0, Scale, Color.White, SpriteEffects.None, Layer); if (Art != null) { Art.Draw(Target); } if (CardName != null) { CardName.Draw(Target); } if (DamageInfo != null) { DamageInfo.Draw(Target); } if (DefenseInfo != null) { DefenseInfo.Draw(Target); } if (AttackDistanceInfo != null) { AttackDistanceInfo.Draw(Target); } if (MovePointsInfo != null) { MovePointsInfo.Draw(Target); } if (HPInfo != null) { HPInfo.Draw(Target); } if (MoneyInfo != null) { MoneyInfo.Draw(Target); } if (!Enabled) { CardName.color = TmpCardNameColor; DamageInfo.color = TmpDamageInfoColor; DefenseInfo.color = TmpDefenseInfoColor; AttackDistanceInfo.color = TmpAttDistInfoColor; MovePointsInfo.color = TmpMovePointsInfoColor; HPInfo.color = TmpHPInfoColor; MoneyInfo.color = TmpMoneyInfoColor; } } }
public static int Result(AttackInfo ai, DefenseInfo di, out bool isCriticalHit, ActionController attacker, ActionController target) { float ret = 0; isCriticalHit = false; float physicalDamageReduction = 0; if (GameManager.Instance.IsPVPMode) { ret = Mathf.Max(ai._attackPoints[0] - di._defensePoints[0], ((float)ai._attackPoints[0]) * 0.3f); //pvp damage reduction if (attacker.SelfCountAgent != null) { attacker.SelfCountAgent.OnTryToHit((int)ai._attackPoints[0]); } } else { ret = Mathf.Max(ai._attackPoints[0] - di._defensePoints[0], ((float)ai._attackPoints[0]) * 0.1f); //pve damage reduction } //ret = ret * (1 - di._defensePercents[0]); //if (ret < 1) //{ // ret = 1; //} for (int i = 1; i < ai._attackPoints.Length; i++) { float ret1 = ((float)(ai._attackPoints[i] - di._defensePoints[i])) * (1 - di._defensePercents[i]); if (ret1 < 0.5) { ret1 = 0; } ret += ret1; } /*if(attacker.IsPlayer) * { * float r1 = Mathf.Pow((ai._criticalChance*10/(75* Mathf.Exp((attacker.Data._level-1)*(0.065f-attacker.Data._level*0.0002f)))),1.7f); * chance = (int)(Mathf.Sqrt(r1)*0.7f +0.5f); * //chance = (int)(Mathf.Log(ai._criticalChance*0.25f)*1.25f); * //Debug.Log(chance); * }*/ int chance = Mathf.RoundToInt(ai._criticalChance * 100); chance = Mathf.Clamp(chance, 1, 50); if (chance >= Random.Range(1, 100)) { ret = (1 + ai._criticalDamage - di._criticalDamageResist) * ret; isCriticalHit = true; } float addScale = 0; if (attacker.ACGetCurrentAttack() != null && attacker.AIUse.AddDamageScale > 0) { addScale = attacker.AIUse.AddDamageScale; } ret = ret * (ai._damageScale + addScale); if (ai._skillAttackDamage > 0) { chance = Mathf.RoundToInt(ai._skillTriggerChance * 100); chance = Mathf.Clamp(chance, 1, 50); if (chance >= Random.Range(1, 100)) { ret = (1 + ai._skillAttackDamage) * ret; } } if (CheatManager.showAttackInfo) { if (isCriticalHit) { attacklog = attacklog + "This is a critical \n"; } attacklog = attacklog + "Final damage = " + ret + "\n"; } if (ret < 1 && ret >= 0) { ret = 1; } if (attacker.IsPlayerSelf && isCriticalHit) { if (isCriticalHit) { if (attacker.ACGetCurrentAttack() != null) { attacker.ACHitTargetIsCrit(target); } if (attacker.SkillGodDown) { int deltaHp = Mathf.RoundToInt(ret * attacker.Data.PassiveSkillGodDownCriticalToHp); attacker.ACIncreaseHP(deltaHp); } } } if (CheatManager.showAttackInfo) { attacklog = "------------------------------------------------------\n"; attacklog = attacklog + "Attacker is " + attacker.Data.id + "\n"; attacklog = attacklog + "Target is " + target.Data.id + "\t Level " + target.Data.Level + "\tArmor = " + target.Data.TotalDefense + "\n"; attacklog = attacklog + target.Data.id + " hitpoint before hurt = " + target.HitPoint + "\n"; attacklog = attacklog + "Normal Attack point = " + ai._attackPoints[0] + "\n"; attacklog = attacklog + "Normal Defense point = " + di._defensePoints[0] + "\n"; attacklog = attacklog + "Damage reduction percent = " + physicalDamageReduction + "\n"; attacklog = attacklog + "Damage = " + ret + "\n"; } return((int)ret); }
public void defenseCircle(DefenseInfo _info) { defPoint = _info.Target; }
public Vector3 GetGrab(DefenseInfo _info) { bool playingGoalkeeper = ServiceLocator.Request <IGameplayService>().GetGameMode() == GameMode.GoalKeeper; m_ready = false; ClearBall = false; GrabBall = false; if (_info.Result == GKResult.Idle) { return(_info.Target); } transform.position = new Vector3(0, 0, -49.5f); bool success = true; string sufix = MakeAnimSufix(_info.Target); if (sufix == "") { m_animName = ""; m_animIdle = ""; return(_info.Target); } if (!GameplayService.IsGoalkeeper()) { lastResult = GKResult.IAFail; } float precision = Mathf.Clamp01(Vector3.Distance(_info.Target, m_ballPoint) / ServiceLocator.Request <IDifficultyService>().GetSuccessRadius(_info.Target)); if (m_debugTrace) { Debug.Log("PRECISION: " + precision); kickEffects.instance.DebugCircle(_info.Target, ServiceLocator.Request <IDifficultyService>().GetPerfectRadius() * 2f, new Color(1, 0.5f, 0)); kickEffects.instance.DebugCircle(_info.Target, ServiceLocator.Request <IDifficultyService>().GetSuccessRadius(_info.Target) * 2f, Color.cyan); kickEffects.instance.DebugTarget(m_ballPoint); } if (!GameplayService.networked && !playingGoalkeeper) { precision = Random.Range(0f, 1f); } #region powerup reflejo if (PowerupService.instance.IsPowerActive(Powerup.Reflejo)) { int casillaX = (int)GetCasilla(_info.Target).x; if (casillaX == 7) { casillaX = 6; } else if (casillaX == 0) { casillaX = 1; } Vector3[] targets = { GetCasillaPosition(casillaX + 1, 0), GetCasillaPosition(casillaX, 0), GetCasillaPosition(casillaX - 1, 0), GetCasillaPosition(casillaX + 1, 1), GetCasillaPosition(casillaX, 1), GetCasillaPosition(casillaX - 1, 1), GetCasillaPosition(casillaX + 1, 2), GetCasillaPosition(casillaX, 2), GetCasillaPosition(casillaX - 1, 2) }; /*Vector3[] targets = {GetCasillaPosition(0,0), GetCasillaPosition(1,0), GetCasillaPosition(2,0), GetCasillaPosition(3,0), GetCasillaPosition(4,0), GetCasillaPosition(5,0), GetCasillaPosition(6,0), GetCasillaPosition(7,0), * GetCasillaPosition(0,1), GetCasillaPosition(1,1), GetCasillaPosition(2,1), GetCasillaPosition(3,1), GetCasillaPosition(4,1), GetCasillaPosition(5,1), GetCasillaPosition(6,1), GetCasillaPosition(7,1), * GetCasillaPosition(0,2), GetCasillaPosition(1,2), GetCasillaPosition(2,2), GetCasillaPosition(3,2), GetCasillaPosition(4,2), GetCasillaPosition(5,2), GetCasillaPosition(6,2), GetCasillaPosition(7,2) * };*/ /*Vector3[] targets = {GetCasillaPosition(0,0), GetCasillaPosition(1,0), GetCasillaPosition(2,0), * GetCasillaPosition(0,1), GetCasillaPosition(1,1), GetCasillaPosition(2,1), * GetCasillaPosition(0,2), GetCasillaPosition(1,2), GetCasillaPosition(2,2) * };*/ Time.timeScale = 0.5f; for (int i = 0; i < targets.Length; i++) { Vector3 mirrorTarget = targets[i];//new Vector3(_info.Target.x * -1f , _info.Target.y, _info.Target.z); float precision2 = Mathf.Clamp01(Vector3.Distance(mirrorTarget, m_ballPoint) / ServiceLocator.Request <IDifficultyService>().GetSuccessRadius(mirrorTarget)); Vector3 mirrorPos = _info.Target; if (precision2 < precision) { mirrorPos = _info.Target; precision = precision2; sufix = MakeAnimSufix(mirrorTarget); _info.Target = mirrorTarget; } else { mirrorPos = mirrorTarget; } GameObject doppelganger = Instantiate(FieldControl.instance.goalKeeperPrefab[FieldControl.instance.doppelgangerindex], Goalkeeper.instance.transform.position, Goalkeeper.instance.transform.rotation) as GameObject; Destroy(doppelganger.GetComponent <Goalkeeper>());//.enabled = false; string mirrorAnimName = MakeAnimSufix(mirrorPos); mirrorAnimName += "_01"; mirrorAnimName = "P_Dpj" + mirrorAnimName; doppelganger.GetComponent <Animation>()[mirrorAnimName].speed = m_animationDescriptorsResource.GetByName(mirrorAnimName).m_grabTime / m_ballTime; Doppelganger comp = doppelganger.AddComponent <Doppelganger>(); comp.m_balltime = m_ballTime; comp.m_animName = mirrorAnimName; doppelganger.GetComponent <Animation>().Play(mirrorAnimName); kickEffects.instance.DoDoppelganger(doppelganger); } } #endregion if (playingGoalkeeper) { //if(m_ballCasilla == sufix) success = true; if (precision < successPrecision) { success = true; } else { success = false; } } else { success = _info.Result == GKResult.Good || _info.Result == GKResult.Perfect; } if (success) { sufix = m_ballCasilla; } sufix += "_01"; m_animName = "P_Dpj" + sufix; m_descriptor = m_animationDescriptorsResource.GetByName(m_animName); bool possiblePerfect = false; lastPerfect = false; if (playingGoalkeeper) { SetGrabTime(m_descriptor.m_grabTime); if (m_animTime <= 0f && !(lastResult == GKResult.Early)) //para comprobar que no se haya hecho la defensa antes incluso de chutar, da 0 en ese caso { lastResult = GKResult.Late; success = false; } else if (m_animTime >= 1f) { lastResult = GKResult.Early; success = false; m_animTime = 0.1f; } else if (m_animTime <= 0.2f && success) { possiblePerfect = true; success = true; } else if (m_animTime <= 0.4f && success) { success = true; } else if (!success) { lastResult = GKResult.Fail; m_animTime = 0f; } } m_animIdle = "P_Idle01"; ClearBall = success; //preparar el perfect float precisionDist = ServiceLocator.Request <IDifficultyService>().GetPerfectRadius(); bool perfectRadius = Vector3.Distance(_info.Target, m_ballPoint) <= precisionDist; float precisionRatio = precisionDist / ServiceLocator.Request <IDifficultyService>().GetSuccessRadius(_info.Target); if (PowerupService.instance.IsPowerActive(Powerup.Resbaladiza) && success) { float max = successPrecision - precisionRatio; float transfProb = (precision - precisionRatio); float finalProb = 0f; if (transfProb < 0f) { finalProb = 0.25f; } else if (transfProb > max) { finalProb = 0.55f; } else { finalProb = 0.4f * (transfProb / max) + 0.1f; } bool forcedFail = finalProb > Random.Range(0f, 1f); BallPhysics.instance.noCatch = forcedFail; Debug.Log("GreasyBall prob = " + finalProb); } if (BallPhysics.instance.state != BallPhysics.BallState.Idle) { if ((playingGoalkeeper && success && perfectRadius) || (!playingGoalkeeper && _info.Result == GKResult.Perfect)) { if (possiblePerfect || !playingGoalkeeper) { AnimationDescriptorsResource.AnimationDescriptorResource tempDescriptor = m_animationDescriptorsResource.GetByName("P_Par" + sufix); if (tempDescriptor != null) { m_animName = "P_Par" + sufix; m_animIdle = "P_IdleCB01"; m_descriptor = tempDescriptor; GrabBall = true; } } } else { possiblePerfect = false; } } if (playingGoalkeeper && possiblePerfect) { lastResult = GKResult.Perfect; lastPrecision = 0; GeneralSounds.instance.perfect(); possiblePerfect = true; } else if (playingGoalkeeper && success) { if (precision < 0.2) { lastPrecision = 1; } else if (precision < 0.45) { lastPrecision = 2; } else { lastPrecision = 3; } lastResult = GKResult.Good; possiblePerfect = false; } lastPerfect = possiblePerfect; forceWin = success; if (playingGoalkeeper && success) { AdjustAnimation(); } Vector3 preResult = transform.position + m_descriptor.m_grabDiff; //preResult.z = InputManager.planeGoalClose.distance; return(preResult); }
public void SetupNetworkDefense(DefenseInfo _info) { m_futureDefense = _info; m_forcedResult = _info.Result; m_networkDefenseReceived = true; }