public PhantomLancer(Unit9 owner, MultiSleeper abilitySleeper, Sleeper orbwalkSleeper, ControllableUnitMenu menu) : base(owner, abilitySleeper, orbwalkSleeper, menu) { this.ComboAbilities = new Dictionary <AbilityId, Func <ActiveAbility, UsableAbility> > { { AbilityId.phantom_lancer_spirit_lance, x => this.lance = new NukeAbility(x) }, { AbilityId.phantom_lancer_doppelwalk, x => this.doppel = new Doppelganger(x) }, { AbilityId.item_diffusal_blade, x => this.diffusal = new DebuffAbility(x) }, { AbilityId.item_abyssal_blade, x => this.abyssal = new DisableAbility(x) }, { AbilityId.item_manta, x => this.manta = new BuffAbility(x) }, { AbilityId.item_bloodthorn, x => this.bloodthorn = new Bloodthorn(x) }, { AbilityId.item_orchid, x => this.orchid = new DisableAbility(x) }, { AbilityId.item_nullifier, x => this.nullifier = new Nullifier(x) }, }; this.MoveComboAbilities.Add(AbilityId.phantom_lancer_doppelwalk, x => this.doppelBlink = new BlinkAbility(x)); }
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); }