public WeaponFSM(string name, BaseWeapon weapon) : base(name, weapon) { if (!weapon) { // TODO: Add log LogHalt("BaseWeapon object null!"); Halt(); } idleState = new IdleState(this, EWeaponState.IDLE, "STATE_IDLE", weapon); windupState = new WindupState(this, EWeaponState.WINDUP, "STATE_WINDUP", weapon); fireState = new FireState(this, EWeaponState.FIRING, "STATE_FIRING", weapon); cooldownState = new CooldownState(this, EWeaponState.COOLDOWN, "STATE_COOLDOWN", weapon); idleState.AddTransition(new Tran_IdleToWindup(windupState, weapon)); windupState.AddTransition(new Tran_WindupToIdle(idleState, weapon)); windupState.AddTransition(new Tran_WindupToFire(fireState, weapon)); fireState.AddTransition(new Tran_FireToCooldown(cooldownState, weapon)); fireState.AddTransition(new Tran_FireToIdle(idleState, weapon)); fireState.AddTransition(new Tran_FireToFire(fireState, weapon)); AddState(idleState); AddState(windupState); AddState(fireState); AddState(cooldownState); }
//Initilizes trap public override void Init() { base.Init(); _currDetectDistance = 0; _startDelay = Time.time; _mystate = FireState.BEGINBURNING; }
public void ToFireMode() { base.MoveTo(gameObject.transform.position); mFireState = FireState.CANFIRE; rend.material.color = Color.red; Debug.Log("canfire"); }
void Start() { enemies = new List <Enemy>(); // not sure spawners = new List <Spawner>(FindObjectsOfType <Spawner>()); process = new ProcessState(); spawn = new SpawnState(spawners); arrange = new ArrangeState(FindObjectOfType <GridManager>()); fire = new FireState(); if (null == processButton) { Debug.Log("no process button"); } else { process.AddReadyButton(processButton); } process.nextState = spawn; spawn.nextState = arrange; arrange.nextState = fire; fire.nextState = process; currentState = process; }
//stops fire animation //receeds raycasts with fire animation void StopFire() { _currDelay = (Time.time - _startDelay) / _fireIncDuration; _currDetectDistance = _maxDetectDistance * (1 - _currDelay); LookForPlayer(); if (_currDelay >= 1) { _currDelay = 1; _currDetectDistance = 0; _startDelay = Time.time; if (bossEntity.GetComponent <TrapBossGlhost>()) { bossEntity.GetComponent <TrapBossGlhost>().IsNotPossessing = true; } else if (bossEntity.GetComponent <MiniTrapBossGlhost>()) { bossEntity.GetComponent <MiniTrapBossGlhost>().IsPossessing = true; } _mystate = FireState.FLAMEBURNOUT; } }
private void ChangeState(int futureState) { if (futureState >= 0) { currentState.effect.Stop(); currentState = states[futureState]; Debug.Log(currentState.displayName); Debug.Log(currentState.displayColor); currentState.effect.Play(); BURN_TIER = currentState.burnTier; fireText.text = currentState.displayName; fireText.color = currentState.displayColor; } /* * particles[state].Stop(); * particles[futureState].Play(); * if(futureState == 3) * { * WeatherScript.NIGHT_ENABLED = true; * } * state++; */ }
private void CheckFireReload() { switch (m_FireState) { case FireState.Ready: if (true == Input.GetKey(KeyCode.Space)) { m_FireState = FireState.Fire; } break; case FireState.Fire: FireBullet(); m_FireState = FireState.Reload; m_FireTime = Time.timeSinceLevelLoad; break; case FireState.Reload: if (Time.timeSinceLevelLoad - m_FireTime > m_ReloadTime) { m_FireState = FireState.Ready; } break; } }
void Update() { if (_grid != null) { foreach (var cell in _grid.gridCells) { if (_burningCells.Contains(cell.Value)) { if (cell.Value.state == FireState.Normal && cell.Value.HasReachedBurningTemperature()) { _flames.Add(cell.Value.position, Instantiate(firePrefab, cell.Value.position, Quaternion.identity, transform)); _burningCells.AddRange(GetCellNeighbours(cell.Value)); _state = FireState.OnFire; _heatSource.enabled = true; break; } else if (!cell.Value.IsStillBurning(Time.deltaTime)) { Destroy(_flames[cell.Key]); _flames.Remove(cell.Key); _burningCells.Remove(cell.Value); } } } } if (_burningCells.Count == 0 && _state == FireState.OnFire) { _heatSource.enabled = false; _state = FireState.BurntDown; } }
public virtual void Release(Vector3 attackDirectionVector, float charge) { AudioManager.PlaySound(attackReleaseSound); fireState = FireState.Live; charge = Mathf.Clamp(charge, 1, chargeLimit); velocity = attackDirectionVector * velocityModifier * charge; enabledTimer = Timer.CreateComponent(gameObject, enabledTime); }
// ------------------------------------------------- // MonoBehaviour // ------------------------------------------------- public override void Start() { base.Start(); invincible = true; fireballs = new List <AttackController>(); fireState = FireState.descending; this.floatHeight = this.transform.position.y + this.floatHeight; }
// Use this for initialization void Start() { base.Start(); mFireState = FireState.MOVING; rend = GetComponent <Renderer>(); cannonRend = cannon.GetComponent <Renderer>(); CommanderUnitControl mCommander = (CommanderUnitControl)GameObject.FindObjectOfType <CommanderUnitControl>(); }
private void enqueueFires(int count, float health) { for (int i = 0; i != count; ++i) { FireState fs = new FireState(health); remainingFires.Enqueue(fs); } }
public void ThrowWeapon() { skeletonAnimation.state.ClearTrack(3); skeletonAnimation.state.SetAnimation(4, "throw", false); skeletonAnimation.state.End += ThrowAnimationCompleteHandler; skeletonAnimation.state.Event += OnWeaponThrown; fireState = FireState.THROW; }
void Start() { _state = FireState.Normal; _heatSource = GetComponent <HeatSource>(); _heatSource.enabled = false; _meshRenderer = GetComponent <Renderer>(); _burningCells = new List <FireCell>(); }
public void FireTransition(Peach peach) { sound = peach.Content.Load <SoundEffect>("Sound Effects/Power Up"); sound.Play(); var state = new FireState(this); peach.PowerUpState = state; peach.SwitchToFireSprite(); }
//starts delay to spit out fire void StartingDelay() { _currDelay = (Time.time - _startDelay) / _beginningDelay; if (_currDelay >= 1) { _currDelay = 1; _startDelay = Time.time; _mystate = FireState.SMOKEON; } }
public void UpdateFireState(bool status) { if (status) { fireState = FireState.Ready; } else { fireState = FireState.NotReady; } }
public Tile(float flammability, int material, string texture1, string texture2, string texture3, FireState state, bool solid, bool outside, bool explodes) { Flammability = flammability; Material = material; State = state; _solid = solid; Outside = outside; EXPLODES = explodes; }
void SetFireState(FireState newFireState) { //TODO: cambiar el color de los sprite cuando se comience a quemar if (newFireState == FireState.level0) { //CallStartFireNeighbor(); level1.SetActive(false); level2.SetActive(false); level3.SetActive(false); level4.SetActive(false); contFire = 0; } if (newFireState == FireState.level1) { //CallStartFireNeighbor(); level1.SetActive(true); level2.SetActive(false); level3.SetActive(false); level4.SetActive(false); contFire = 1; } if (newFireState == FireState.level2) { level1.SetActive(false); level2.SetActive(true); level3.SetActive(false); level4.SetActive(false); contFire = 2; //CallFireLevel2(); } if (newFireState == FireState.level3) { contFire = 3; level1.SetActive(false); level2.SetActive(false); level3.SetActive(true); level4.SetActive(false); //CallFireLevel3(); } if (newFireState == FireState.level4) { contFire = 4; level1.SetActive(false); level2.SetActive(false); level3.SetActive(false); level4.SetActive(true); //CallFireLevel4(); } }
void FireOff() { Scale(0.0f); if (markTime + offTime < Time.time) { state = FireState.READY; rend.enabled = false; col_detect.enabled = true; scaleTarget.localScale = Vector3.one; target.SendMessage("Activate"); } }
void FireOn() { Scale(1.0f); if (markTime + onTime < Time.time) { state = FireState.OFF; markTime = Time.time; rend.enabled = true; col_detect.enabled = false; target.SendMessage("Deactivate"); } }
//plays fire animation after a delay void StartSmoke() { _currDelay = (Time.time - _startDelay) / _fireDelay; if (_currDelay >= 1) { _currDelay = 1; _mySmoke.Play(); _startDelay = Time.time; _mystate = FireState.FLAMEDELAY; } }
//plays fire animation after a delay void StartFire() { _currDelay = (Time.time - _startDelay) / _fireDelay; if (_currDelay >= 1) { _currDelay = 1; _mySmoke.Stop(); _myFire.Play(); _startDelay = Time.time; _mystate = FireState.FLAMEON; } }
private void SpawnFires() { int numFires = findFires().Count; int numToCreate = Mathf.Min(MaxActiveFires - numFires, remainingFires.Count); for (int i = 0; i != numToCreate; ++i) { Vector3 spawnPos = new Vector3(Random.Range(-3.25f, 3.25f), Random.Range(1.3f, 1.8f), 0.0f); GameObject newFire = Instantiate(fire, spawnPos, Quaternion.identity, gameObject.transform); FireState fs = remainingFires.Dequeue(); newFire.GetComponent <FireController>().State = fs; } }
// ------------------------------------------------- // Active // ------------------------------------------------- protected override void Active() { if (this.fireState == FireState.floating) { CheckFlips(); if (Mathf.Abs(this.transform.position.x - target.transform.position.x) <= this.range) { this.rb.velocity = Vector2.zero; if (rangedCoolDown <= 0) { rangedCoolDown = rangedCoolDownMax; FireAttack(); } } else { this.rb.velocity = Vector2.right * this.walkSpeed * -TargetDirection(); } if (this.transform.position.y > this.floatHeight) { ascend(); } } else if (this.fireState == FireState.ascending) { if (this.transform.position.y >= this.floatHeight) { this.rb.velocity = Vector2.zero; this.fireState = FireState.floating; } int modifier = 1; if (this.transform.position.y > this.floatHeight) { modifier = -1; } rb.velocity = Vector2.up * ascendVelocity * modifier; } else if (this.fireState == FireState.descending) { if (grounded) { StartCoroutine(LandStun()); this.fireState = FireState.landStun; } } }
public bool HasReachedBurningTemperature() { if (state == FireState.OnFire) { return(false); } _currentTemperature += settings.temperatureChangePerFrame; if (_currentTemperature >= settings.initialBurningTemperature) { state = FireState.OnFire; return(true); } return(false); }
public void OnTriggerEnter(Collider coll) { if (state == FireState.READY) { if (coll.gameObject.tag == "Player" || coll.gameObject.tag == "Hologram" || coll.gameObject.tag == "Enemy") { state = FireState.ON; markTime = Time.time; scaleTarget.localScale = Vector3.zero; rend.enabled = true; col_detect.enabled = true; } } }
//plays fire animation after a delay void StartFire() { _currDelay = (Time.time - _startDelay) / _fireDelay; if (_currDelay >= 1) { _currDelay = 1; _myFire.Play(); _startDelay = Time.time; Debug.Log("Shoot Fire"); _mystate = FireState.FLAMEON; } }
public bool IsStillBurning(float timeElapsed) { if (state == FireState.BurntDown || state == FireState.Normal) { return(true); } _burningTime += timeElapsed; if (_burningTime >= settings.burningTime) { state = FireState.BurntDown; return(false); } return(true); }
public void CopyInformation(CellAlchemyState copy) { gasState = copy.gasState; liquidState = copy.liquidState; solidState = copy.solidState; blessingState = copy.blessingState; fireState = copy.fireState; shockState = copy.shockState; changedValues.Clear(); foreach (AlchemyChangeType change in copy.changedValues) { changedValues.Add(change); } }
protected bool FireWeapons() { foreach (WeaponBase wep in weapons) { FireState ret = wep.Fire(); if (ret == FireState.OutOfAmmo) { ReloadWeapons(); return(false); } } return(true); }
private void CheckFireReload() { switch( m_FireState ) { case FireState.Ready : m_FireState = FireState.Fire ; break ; case FireState.Fire : FireBullet() ; m_FireState = FireState.Reload ; m_FireTime = Time.timeSinceLevelLoad ; break ; case FireState.Reload : if( Time.timeSinceLevelLoad - m_FireTime > m_ReloadTime ) m_FireState = FireState.Ready ; break ; } }
private void CheckFireReload() { switch( m_FireState ) { case FireState.Ready : if( true == Input.GetKey( KeyCode.Space ) ) { m_FireState = FireState.Fire ; } break ; case FireState.Fire : FireBullet() ; m_FireState = FireState.Reload ; m_FireTime = Time.timeSinceLevelLoad ; break ; case FireState.Reload : if( Time.timeSinceLevelLoad - m_FireTime > m_ReloadTime ) m_FireState = FireState.Ready ; break ; } }
public void FireHoming() { if (fireState == FireState.Waiting) { if (counter > waitDuration) { fireState = FireState.Firing; counter -= waitDuration; } } else if (fireState == FireState.Firing) { GameObject bullet = (GameObject)Instantiate(homingProjectile, new Vector3(transform.position.x, transform.position.y + 1.0f, transform.position.z), new Quaternion()); bullet.GetComponent<EvilToken>().difficulty = difficulty; Destroy(bullet, homingLifeTime); fireState = FireState.Waiting; reloadCount = 0; counter = 0; PickNextGunType(); } }
void FixedUpdate( ) { if ( !m_RobotComponent.bCanMove || !GameManager.Instance.m_MatchStarted ) { m_NavAgent.Stop( ); return; } else { m_NavAgent.Resume( ); } if ( m_NavAgent.velocity != Vector3.zero ) m_CurrentLocomotionState = LocomotionState.MOVING; else m_CurrentLocomotionState = LocomotionState.IDLE; //Handle moving switch ( m_CurrentLocomotionState ) { case LocomotionState.IDLE: Vector3 _targetLoc = GetRandomLocationNearPlayer(); if ( _targetLoc != Vector3.zero ) { m_NavAgent.SetDestination( _targetLoc ); return; } if ( Vector3.Distance( transform.position, _targetLagLocation ) < 6 ) { transform.LookAt( _targetLagLocation, Vector3.up ); } break; case LocomotionState.MOVING: _targetLagLocation = Vector3.Lerp( _targetLagLocation, m_PlayerCurrentLocation, 0.03f ); transform.LookAt( _targetLagLocation, Vector3.up ); if ( Vector3.Distance( transform.position, _targetLagLocation ) < 3 ) { m_NavAgent.Stop( ); } else { m_CurrentLocomotionState = LocomotionState.IDLE; } break; } //Handle firing switch ( m_CurrentFireState ) { case FireState.AIMING: if (Vector3.Distance (m_PlayerCurrentLocation, transform.position) < 3) { if (!m_IsFiringLeftWeapon) { FireLeftWeapon (); } if (!m_IsFiringRightWeapon) { FireRightWeapon (); } } else m_CurrentFireState = FireState.AIMING; break; case FireState.FIRING: break; } }
void FireRightWeapon( ) { m_CurrentFireState = FireState.FIRING; m_IsFiringRightWeapon = true; m_RobotComponent.RightWeaponFire( ); }
private void StartThrow() { fireState = FireState.START_THROW; skeletonAnimation.state.SetAnimation(2, "throw_start",false); skeletonAnimation.state.End += SartThrowCompleteHandler; }
void ThrowAnimationCompleteHandler(Spine.AnimationState state, int trackIndex) { if (trackIndex != 4) return; skeletonAnimation.state.End -= ThrowAnimationCompleteHandler; this.fireState = FireState.IDLE; }
void OnMainStateStateChanged(PlayerController.State state) { if (state == PlayerController.State.Hurt) fireState = FireState.IDLE; }
private void SartThrowCompleteHandler(Spine.AnimationState state, int trackIndex) { if (trackIndex != 2) return; skeletonAnimation.state.End -= SartThrowCompleteHandler; skeletonAnimation.state.SetAnimation(3, "throw_boost", true); this.fireState = FireState.BOOST_THROW; boostStarTime = TimerManager.Instance.CurrentTime; }
public void FireLaser() { if (fireState == FireState.Waiting) { if (counter > waitDuration) { fireState = FireState.Firing; counter -= waitDuration; } } else if (fireState == FireState.Firing) { if (reloadCount < laserFireCount) { if (counter > laserFireRate) { counter -= laserFireRate; GameObject bullet = (GameObject)Instantiate(laserProjectile, new Vector3(transform.position.x, transform.position.y + 1.0f, transform.position.z), new Quaternion()); bullet.GetComponent<EvilToken>().difficulty = difficulty; bullet.GetComponent<Rigidbody>().AddForce(dirToPlayer * laserVelocity * bullet.GetComponent<Rigidbody>().mass); reloadCount++; Destroy(bullet, laserBulletLifeTime); } } else { fireState = FireState.Waiting; reloadCount = 0; PickNextGunType(); } } }
//Mose of these methods are fairly similar. Most do velocity setting and difficulty scaling. They fire at different rates and create diffferent projectiles. //The homing projectile auto-homes so we just need to set and forget it. public void FireShotgun() { if (fireState == FireState.Waiting) { if (counter > waitDuration) { fireState = FireState.Firing; counter -= waitDuration; } } else if (fireState == FireState.Firing) { for (int i = 0; i < buckCount; i++) { Vector3 randV = new Vector3(1.0f * Random.Range(-scatterAmount, scatterAmount), 1.0f * Random.Range(-scatterAmount, scatterAmount), 1.0f * Random.Range(-scatterAmount, scatterAmount)) ; GameObject bullet = (GameObject)Instantiate(shotgunProjectile, new Vector3(transform.position.x, transform.position.y + 1.0f, transform.position.z), new Quaternion()); bullet.GetComponent<EvilToken>().difficulty = difficulty; bullet.GetComponent<Rigidbody>().AddForce((dirToPlayer + randV) * buckVelocity * bullet.GetComponent<Rigidbody>().mass); Destroy(bullet, buckLifeTime); } fireState = FireState.Waiting; counter = 0; PickNextGunType(); reloadCount = 0; } }
public BoostState(Tutorial context, ChainedState _back) : base(context) { back = _back; next = new FireState(context, this); }