//Handles moving the player and drops firespots private void ChannelAbility() { //Dash at the beginning of the cast if (!hasDashed) { Dash(); } //While casting duration is available if (DurationRemaining > 0) { if (FlameSpotDeltaRemaining > 0) { FlameSpotDeltaRemaining -= Time.deltaTime; } else { DropFire(); FlameSpotDeltaRemaining = FlameSpotDelta; } DurationRemaining -= Time.deltaTime; } else //Put ability on cooldown { DurationRemaining = 0; Status = CastState.CoolDown; } }
//Creates fire while channeling void ChannelAbility() { //Cast the ability unless canceled if (DurationRemaining > 0 && Input.GetAxis("Primary Fire") <= 0) { Debug.Log("Channelling: " + DurationRemaining); //Spawn a new projectile every FlameDelta seconds if (FlameDeltaRemaining > 0) { FlameDeltaRemaining -= Time.deltaTime; } else { CreateFlames(); FlameDeltaRemaining = FlameDelta; } DurationRemaining -= Time.deltaTime; } else { DurationRemaining = 0; Status = CastState.CoolDown; } }
public bool Use(OldContext context) { if (!Usable(context)) { return(false); } this.context = context; context.ability = this; SetComponentContext(context); OnUse(); if (castState == CastState.Invalid) { if (castMode == CastMode.Channel) { float actualChannelTime = channelTime.Value; castTimer.Reset(actualChannelTime); channelTimer.Reset(actualChannelTime / channelTicks.Value); } else { float actualCastTime = castTime.Value; castTimer.Reset(actualCastTime); actualCastMode = (actualCastTime <= 0f) ? CastMode.Instant : castMode; } castState = CastState.Casting; OnCastStarted(); } return(true); }
private void Awake() { idleState = new IdleState(this); moveState = new MoveState(this); attackState = new AttackState(this); castState = new CastState(this); fleeState = new FleeState(this); defendState = new DefendState(this); anim = GetComponent <Animator>(); walkSpeed = 1.0f; navMeshAgent = GetComponent <NavMeshAgent>(); navSpeedDefault = navMeshAgent.speed; eyes = transform.FindChild("Eyes"); sightCollider = GetComponent <SphereCollider>(); tm = GameObject.FindWithTag("TeamManager").GetComponent <TeamManager>(); ah = GameObject.FindWithTag("AbilityHelper").GetComponent <AbilityHelper>(); //this is a mess. These are "shared" variables between co-op ai and player script player = GetComponent <Player>(); animController = player.animController; abilities = player.abilities; attributes = player.attributes; watchedEnemies = player.watchedEnemies; visibleEnemies = player.visibleEnemies; }
void ChargeSpell() { if (myState == CastState.Neutral) { StartCharge = Time.time; myState = CastState.Charging; } }
public CastState UpdateCast() { if (castState == CastState.Casting) { if (!CheckRequirements(context, RequirementType.CastUpdate)) { castState = CastState.Invalid; OnCastCancelled(); return(castState); } switch (actualCastMode) { case CastMode.Instant: castState = CastState.Completed; break; case CastMode.Cast: castState = castTimer.Ready ? CastState.Completed : CastState.Casting; break; case CastMode.Channel: if (castTimer.Ready || channelTimer.ReadyWithReset()) { Debug.Log("Tick: " + castTimer.ElapsedTime); OnChannelTick(); } castState = castTimer.Ready ? CastState.Completed : CastState.Casting; break; case CastMode.CastToChannel: break; } } if (castState == CastState.Completed) { if (CheckRequirements(context, RequirementType.CastComplete)) { OnCastCompleted(); ExpireCharge(); OnCastEnded(); SetComponentContext(null); castState = CastState.Invalid; return(CastState.Completed); } else { CancelCast(); castState = CastState.Invalid; } } return(castState); }
//Sets/Preps defaults for casting ability void CastAbility() { Debug.Log("Casting: "); //Set values to prep for casting ChargeTimeRemaining = ChargeTime; DurationRemaining = Duration; FlameSpotDeltaRemaining = 0; CoolDownRemaining = CoolDown; //Change status Status = CastState.Charging; }
//Handles Ability Cooldown private void AbilityCoolDown() { //Wait for cooldown to finish if (CoolDownRemaining > 0) { Debug.Log("CoolDown: " + CoolDownRemaining); CoolDownRemaining -= Time.deltaTime; } else { CoolDownRemaining = 0; Status = CastState.Ready; } }
public void ButtonUp() { if (myState == CastState.Charged) { mySpells.Dequeue().Activate(spellSpawn.position, transform.forward, myTrans); SpellSpriteHandler(); StartCharge = 0.0f; myState = CastState.Recharging; StartDelay = Time.time; mySpells.Enqueue(myDad.GetNewSpell());//get a new spell for the list! } else { myState = CastState.Neutral; } }
//Handles Charging ability void ChargeAbility() { //disable main attack //gameObject.GetComponent<ModestoAttack>().enabled = false; //wait for animation if (ChargeTimeRemaining > 0) { Debug.Log("Charging: " + ChargeTimeRemaining); ChargeTimeRemaining -= Time.deltaTime; } else { ChargeTimeRemaining = 0; Status = CastState.Channeling; } }
private void FixedUpdate() { if (myState == CastState.Charging) { //check the time if (Time.time - StartCharge >= mySpells.Peek().ChargeTime()) { myState = CastState.Charged; } } else if (myState == CastState.Recharging) { //check the time if (Time.time - StartDelay >= delayTime) { myState = CastState.Neutral; } } }
public Ability UpdateCast() { if (queuedExpire.ReadyWithReset(0.2f)) { queuedAbility = null; } if (currentAbility == null || !gcdTimer.Ready) { return(null); } CastState castState = currentAbility.UpdateCast(); if (castState == CastState.Invalid) { Clear(); } else if (castState == CastState.Completed) { if (currentAbility.IsInstant && !currentAbility.IgnoreGCD) { gcdTimer.Reset(GetGlobalCooldownTime(currentAbility)); } currentAbility = queuedAbility; currentContext = queuedContext; queuedAbility = null; queuedContext = null; if (currentAbility != null && !currentAbility.Use(currentContext)) { currentAbility = null; currentContext = null; } } return(currentAbility); }
public bool Use(Context context) { if (!contextType.IsAssignableFrom(context.GetType())) { Debug.LogError("Ability `" + Id + "` expects a context type assignable to " + contextType.Name + ", but was used with: " + context.GetType().Name); } if (!Usable(context)) { return(false); } this.context = context; SetComponentContext(context); OnUse(); if (castState == CastState.Invalid) { if (castMode == CastMode.Channel) { float actualChannelTime = channelTime.Value; castTimer.Reset(actualChannelTime); channelTimer.Reset(actualChannelTime / channelTicks.Value); } else { float actualCastTime = castTime.Value; castTimer.Reset(actualCastTime); actualCastMode = (actualCastTime <= 0f) ? CastMode.Instant : castMode; } castState = CastState.Casting; OnCastStarted(); } return(true); }
void Start() { playerModelDefaultRotation = playerModel.transform.localRotation; playerModelClimbRotation = Quaternion.identity; playerModelTauntRotation.SetLookRotation(new Vector3(0, 0, -1), new Vector3(0, 1, 0)); attackCollider.enabled = false; lightningGenerator.SetActive(false); // temp dashAttackCollider.enabled = false; shieldCollider.enabled = false; ShowShield(false); ShowHorn(false); playerAnimator = GetComponent <Animator>(); GameObject.FindGameObjectWithTag("GameSession").GetComponent <SavePlayerState>().RecoverPlayerStatusValues(this); staminaRecovery = 0.0f; fullStaminaRecovery = false; GameObject guiObject = GameObject.Find("GUI"); if (guiObject) { guiManager = guiObject.GetComponent <GUIManager>(); } activeRespawnPoint = initialPosition; cameraFade = GameObject.Find("PlayerCamera").GetComponent <CameraFade>(); attack = new AttackState(CalculateFramesFromTime(attackDuration)); cast = new CastState(CalculateFramesFromTime(castDuration)); climb = new ClimbState(); dash = new DashState(CalculateFramesFromTime(dashDuration)); dead = new DeadState(CalculateFramesFromTime(deadDuration)); defense = new DefenseState(); drink = new DrinkState(CalculateFramesFromTime(drinkDuration)); fall = new FallState(); fallcloud = new FallCloudState(CalculateFramesFromTime(fallCloudDuration)); hit = new HitState(CalculateFramesFromTime(hitDuration)); idle = new IdleState(); jump = new JumpState(CalculateFramesFromTime(GetComponent <PlayerMove>().timeToJumpApex)); refill = new RefillState(CalculateFramesFromTime(refillDuration)); taunt = new TauntState(CalculateFramesFromTime(tauntDuration)); walk = new WalkState(); SetState(idle); facingRight = true; jumpAvailable = true; climbLadderAvailable = false; beerRefillAvailable = false; justHit = false; jumpFrames = 0; framesInDelayCount = 0; camFollow = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <CameraFollow>(); colliderSize = GetComponent <BoxCollider>().size; godMode = false; }
// Start is called before the first frame update void Start() { Status = CastState.Ready; }
public ScriptEventArgs(CastState currentState) { CurrentCastState = currentState; }
//No charge time so set straight to channeling private void ChargeAbility() { ChargeTimeRemaining = 0; Status = CastState.Channeling; hasDashed = false; }