private void Attack2Shoot() { var t = time % 8000; if (t < 2000) { shootState = ShootState.RELOAD; shootCount = 0; } else if (t < 4000) { if (shootState == ShootState.RELOAD) { parent.effectSystems.Add(new EffectSystem.SpellCharge(position, EffectSystem.Particle.State.CONVERGENCE)); shootState = ShootState.CHARGE; } } else if (4000 < t) { if (shootCount < attack2enableShootCount && (t - 4000) / attack2ShootInterval >= shootCount) { for (int i = 0; i < 17; i++) { parent.enemyBullets.Add( new SpinToCurve(position, Vector2.Zero, index, 0.15f, (VirtualEnemyBullet.SetColor)(shootCount % 7), (i / 17.0) * MathHelper.TwoPi + ((time + 10000) / 350.0), shootDirection)); } shootCount++; shootDirection *= -1.0; } } }
void BubbleMoving() { CurrentBubble.transform.position = Vector3.MoveTowards(CurrentBubble.transform.position, TargetLine[currentIndex], BubbleSpeed * Time.deltaTime * 5); if (CurrentBubble.transform.position.Equals(TargetLine[currentIndex])) { if (currentIndex == TargetLine.Count - 1) { BubbleToMergeInto = Instantiate(BubblePrefab, TargetLine[TargetLine.Count - 1], Quaternion.identity, BubbleHolder.transform).GetComponent <BubbleScript>(); BubbleToMergeInto.SetValue(CurrentBubbleValue); CurrentBubble.transform.position = TargetLine[0]; if (CurrentBubble.GetComponent <TrailRenderer>() != null) { CurrentBubble.GetComponent <TrailRenderer>().enabled = false; } SetNeighborBubbles(); currentState = ShootState.MergingBubbles; currentIndex = 0; } else { currentIndex++; } } }
protected override void BuildFSM() { //Other States Here PatrolState patrol = new PatrolState(this); patrol.AddTransitionState(FSMStateID.Investigate, FSMTransitions.HeardPlayer); patrol.AddTransitionState(FSMStateID.Shoot, FSMTransitions.SawPlayer); AddFSMState(patrol); InvestigateState investigate = new InvestigateState(this); investigate.AddTransitionState(FSMStateID.Patrol, FSMTransitions.FoundNothing); investigate.AddTransitionState(FSMStateID.Shoot, FSMTransitions.SawPlayer); AddFSMState(investigate); ShootState shoot = new ShootState(); shoot.AddTransitionState(FSMStateID.Investigate, FSMTransitions.PlayerOutOfRange); AddFSMState(shoot); DeadState dead = new DeadState(); AddFSMState(dead); }
void Shoot() { if (target == null) { return; } eShootState = ShootState.E_NONE; GameObject bullet = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation); Destroy(bullet, bulletSurviveDuration); Rigidbody2D rb = bullet.GetComponent <Rigidbody2D>(); Vector3 dirction = target.position - firePoint.position; dirction.Normalize(); rb.AddForce(dirction * bulletForce, ForceMode2D.Impulse); fireCount++; if (fireCount > stopMaxFireCount && enemyMovement.GetMoveState() != EnemyMovement.MOVE_STATE.E_END) { fireCount = 0; if (enemyMovement.bFinishedMove) { enemyMovement.SetMoveState(EnemyMovement.MOVE_STATE.E_CHASE); } else { enemyMovement.SetMoveState(EnemyMovement.MOVE_STATE.E_MOVE); } } }
// Update is called once per frame void LateUpdate() { CheckHit(); if (state == ShootState.aiming && aimCount > aimTime) { State = ShootState.shooting; aimCount = 0f; } else if (state == ShootState.aiming) { aimCount += Time.deltaTime; } else if (aimCount > 0f) { aimCount -= Time.deltaTime * 0.5f; Mathf.Clamp(aimCount, 0f, aimTime); } if (state == ShootState.shooting && shootCount < shootDelay) { shootCount += Time.deltaTime; } else if (state == ShootState.shooting) { shootCount = 0f; aimCount = 0f; Shoot(); State = ShootState.seeking; } }
public void Fire() { if (SafetyEngaged == false) { if (Time.time > NextFire) { if (CurrentReload == ReloadState.None && NeedsToReload == false) { if ((CurrentGunState == GunState.Auto) || (CurrentGunState == GunState.Burst && CurrentBurst <= BurstAmount) || (CurrentGunState == GunState.Single && CurrentBurst <= 1)) { CurrentBurst++; MuzzleFlareVisible = true; if (CurrentShoot == ShootState.None) { CurrentShoot = ShootState.LoopStart; WeaponObject.animation.Play("shootStart"); } else if (CurrentShoot == ShootState.Loop) { WeaponObject.animation.Play("shootLoop"); } FireRound(); NextFire = Time.time + FireDelay; } } } } }
private void Logger(object sender, ShootState state) { string result = ""; var sqr = (Square)sender; if (sqr.Board == Player.Board) { result += $"[{DateTime.Now:mm:ss}] Enemy: {state}!"; } else { result += $"[{DateTime.Now:mm:ss}] Player: {state}!"; } if (Log.Count == 10) { for (int i = 0; i < Log.Count - 1; i++) { Log[i] = Log[i + 1]; } Log[9] = result; } else { Log.Add(result); } }
public static ShipShootState GetShootState(ShootState state) { ShipManager pShipMan = ShipManager.PrivInstance(); Debug.Assert(pShipMan != null); ShipShootState pShipShootState = null; switch (state) { case ShipManager.ShootState.MissileReady: pShipShootState = pShipMan.pMissileReadyState; break; case ShipManager.ShootState.MissileFlying: pShipShootState = pShipMan.pMissileFlyingState; break; case ShipManager.ShootState.Locked: pShipShootState = pShipMan.pMissileLockedState; break; } return(pShipShootState); }
void Reload() { SetNeighborBubbles(); CurrentBubbleValue = CurrentBubble.GetComponent <BubbleScript>().SetValue(NextBubbleValue); NextBubbleValue = NextBubble.GetComponent <BubbleScript>().SetRandomValue(BubbleScript.BubbleValue.Two, BubbleScript.BubbleValue.SixtyFour); currentState = ShootState.Aiming; }
void DestroyFloating() { SetNeighborBubbles(); SetHeights(); var Bubbles = BubbleHolder.GetComponentsInChildren <BubbleScript>(); List <BubbleScript> d = new List <BubbleScript>(); for (int i = 0; i < Bubbles.Length; i++) { if (Bubbles[i].StepHeight == 0) { d.Add(Bubbles[i]); } } for (int i = 0; i < d.Count; i++) { d[i].GetAllNeighbors(ref d); } for (int i = 0; i < Bubbles.Length; i++) { if (!d.Contains(Bubbles[i])) { Bubbles[i].Pop(); } } currentState = ShootState.AddingMoreBubbles; }
protected override void BuildFSM() { PatrolState patrol = new PatrolState(PatrolPoints, navAgent, agroDistance); patrol.AddTransitionState(FSMStateID.Shoot, FSMTransitions.SawPlayer); patrol.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth); ShootState shoot = new ShootState(chargeDistance, spawnerScript); shoot.AddTransitionState(FSMStateID.Patrol, FSMTransitions.PlayerOutOfRange); shoot.AddTransitionState(FSMStateID.Chase, FSMTransitions.PlayerTooClose); shoot.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth); ChaseState chase = new ChaseState(navAgent, chargeDistance); chase.AddTransitionState(FSMStateID.Shoot, FSMTransitions.PlayerOutOfRange); chase.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth); DeadState dead = new DeadState(); AddFSMState(patrol); AddFSMState(shoot); AddFSMState(chase); AddFSMState(dead); }
public void ReceivePortal(Portal portal, Portal other, int clipIndex, ShootState state, Vector3 impact, Vector3 pos, Vector3 normal) { MuzzlePlarticle(portal); switch (state) { case ShootState.Place: ImpactParticle(impact, normal, portal, portal.layer); portal.Place(this, pos, Quaternion.LookRotation(normal, GetPseudoPortalUp(portal.transform, normal)), Vector3.one * size.Value); SetEmission(portal.color); VidyaMod.PlayAudio(audioSource, clips[clipIndex], 1f, 0.9f, 1.05f); break; case ShootState.Impact: ImpactParticle(impact, normal, portal, other.layer); other.StartAnimation(PortalAnim.Disturb); VidyaMod.PlayAudio(audioSource, clips[2], 0.9f); break; case ShootState.Miss: VidyaMod.PlayAudio(audioSource, clips[2], 0.9f); break; case ShootState.Unable: VidyaMod.PlayAudio(audioSource, clips[2], 0.3f); portal.StartAnimation(PortalAnim.Disturb); other.StartAnimation(PortalAnim.Disturb); break; } }
public static ShipShootState GetShootState(ShootState state) { ShipMan pShipMan = ShipMan.PrivInstance(); Debug.Assert(pShipMan != null); ShipShootState pShipState = null; switch (state) { case ShipMan.ShootState.Ready: pShipState = pShipMan.pStateReady; break; case ShipMan.ShootState.MissileFlying: pShipState = pShipMan.pStateMissileFlying; break; case ShipMan.ShootState.End: pShipState = pShipMan.pStateEnd; break; default: Debug.Assert(false); break; } return(pShipState); }
void Update() { if (shootState != ShootState.not_shooting) { shootState = ShootState.not_shooting; } // TODO: Ideally should work with dictionary<int,matType> - GetButton(Material{int})->currentMat=dict[int] if (Input.GetKeyDown("1")) { currentMaterial = FloopableMaterialTypes.Reflective; } if (Input.GetKeyDown("2")) { currentMaterial = FloopableMaterialTypes.Opaque; } if (Input.GetKeyDown("3")) { currentMaterial = FloopableMaterialTypes.GoThrough; } if (Input.GetMouseButtonDown(0)) { Shoot(); } }
protected override void BuildFSM() { PatrolState patrol = new PatrolState(PatrolPoints, navAgent, agroDistance); patrol.AddTransitionState(FSMStateID.Shoot, FSMTransitions.SawPlayer); patrol.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth); ShootState shoot = new ShootState(retreatDistance, spawnerScript); shoot.AddTransitionState(FSMStateID.Patrol, FSMTransitions.PlayerOutOfRange); shoot.AddTransitionState(FSMStateID.Retreat, FSMTransitions.PlayerTooClose); shoot.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth); RetreatState retreat = new RetreatState(navAgent, retreatDistance); retreat.AddTransitionState(FSMStateID.Shoot, FSMTransitions.CloserDistanceReached); retreat.AddTransitionState(FSMStateID.Dead, FSMTransitions.OutOfHealth); DeadState dead = new DeadState(); AddFSMState(patrol); AddFSMState(shoot); AddFSMState(retreat); AddFSMState(dead); }
// Start is called before the first frame update void Start() { eShootState = ShootState.E_NONE; target = FindObjectOfType <Player>().GetComponent <Transform>(); rb = weapon.GetComponent <Rigidbody2D>(); fireCount = 0; StartCoroutine(ShootRoutine()); }
void Start() { _shootStates = new ShootState[_pinchDetectors.Length]; for (int i = 0; i < _pinchDetectors.Length; i++) { _shootStates[i] = new ShootState(); } }
private void DeadShoot() { if (shootState == ShootState.RELOAD) { parent.effectSystems.Add(new EffectSystem.SpellCharge(position, EffectSystem.Particle.State.DIVERGENCE)); shootState = ShootState.CHARGE; } }
private ShootState() { if (_instance != null) { return; } _instance = this; }
public override void Shoot() { base.Shoot(); if (details.CheckBattery(details.fireballCost)) { currentState = new ShootState(details); currentState.Shoot(); } }
protected void SendPortalPlacement(Portal portal, ShootState state, Vector3 impact, Vector3 pos, Vector3 normal) { MuzzlePlarticle(portal); VidyaMod.PlayAudio(audioSource, state == ShootState.Place ? clips[portal.index] : clips[2], 0.9f); if (!StatMaster.isLocalSim) { Message targetMessage = portalShotMessageType.CreateMessage(Block.From(this), portal.index, (int)state, impact, pos, normal); ModNetworking.SendToAll(targetMessage); } }
private void NextShootState() { if ((int)shootState == 4) { shootState = 0; } else { shootState++; } }
private void InitStates() { PatrolState patrol = new PatrolState(this, _path, direction, _arriveDistance); FollowTargetState followTarget = new FollowTargetState(this); ShootState shoot = new ShootState(this); _states.Add(patrol); _states.Add(followTarget); _states.Add(shoot); CurrentState = patrol; CurrentState.StateActivated(); }
void Awake() { // state references. rsState = GetComponent <RoamState>(); chState = GetComponent <CollectHealthState>(); sState = GetComponent <ShootState>(); caState = GetComponent <CollectAmmoState>(); // initialize states. rsState.enabled = true; activeState = rsState; }
IEnumerator ShootStateCoroutine() { // Delay yield return(new WaitForSeconds(ShootDuration)); _shootState = ShootState.Cooldown; // Delay yield return(new WaitForSeconds(CooldownDuration)); _shootState = ShootState.Ready; }
void Awake() { // state references. rs = GetComponent <RoamState>(); cs = GetComponent <CollectHealthState>(); ss = GetComponent <ShootState>(); ams = GetComponent <CollectAmmoState>(); // initialize states. rs.enabled = true; cs.enabled = false; activeState = rs; }
private void Awake() { _idleState = GetComponent <IdleState>(); _idleState.enabled = false; _moveState = GetComponent <MoveState>(); _moveState.enabled = false; _shootState = GetComponent <ShootState>(); _shootState.enabled = false; _currentState = _idleState; _target = FindObjectOfType <PlayerController>().gameObject.transform; }
private BossState currentState; // current state of boss // Start is called before the first frame update void Start() { currentState = BossState.Idle; frameCounter = 0; isShakeScale = false; notShakeScale = new Vector3(1 / 2, 1 / 2, 1 / 2); shootCounter = 0; shootCounter2 = 0; shootState = ShootState.Basic; player = GameObject.FindGameObjectWithTag("Player"); animator = GetComponent <Animator>(); animator.Play("xidle"); }
void Awake() { searchState = new SearchState(this); shootState = new ShootState(this); /*sentryState = new SentryState(this); * fleeState = new FleeState(this);*/ gruntSlotList = transform.GetChild(3).gameObject; navMeshAgent = GetComponent <UnityEngine.AI.NavMeshAgent>(); walkTargetParent = transform.GetChild(0).gameObject; walkTargetOrig = walkTargetParent.transform.GetChild(0).gameObject; }
private void AssignPlayer(ShootState state) { if (state == ShootState.Beside) { if (CurrentPlayer.IsEnemy) { CurrentPlayer = Player; } else { CurrentPlayer = EnemyPlayer; } } }
void Reset() { // deattach shot transform.parent = turret.transform; // reset scales of anchor points origin.transform.localScale = originScaleInit; end.transform.localScale = endScaleInit; // reset location of laser shot transform.localPosition = laserShotPosInit; transform.localScale = laserShotScaleInit; if (turret.AlarmOn) { shootState = ShootState.arming; // if still in range, fire immediately } else { shootState = ShootState.alert; // if out of range, disarm. } }
// Update is called once per frame void Update() { float len = Vector3.Dot (transform.parent.localScale, delta); // take the right scale switch (shootState) { case ShootState.alert: transform.parent = origin.transform; // attach the shot to the origin point if (turret.AlarmOn) { shootState = ShootState.arming; fireTime = armTime + Time.realtimeSinceStartup; } break; case ShootState.arming: transform.parent = origin.transform; // attach the shot to the origin point if (!turret.AlarmOn) { shootState = ShootState.alert; } if (Time.realtimeSinceStartup >= fireTime) { shootState = ShootState.fire; } break; case ShootState.fire: if (len < maxScale - Time.deltaTime * fireSpeed) { transform.parent.localScale += Time.deltaTime * fireSpeed * delta; } else { transform.parent.localScale += (maxScale - len) * delta; shootState = ShootState.shrink; } break; case ShootState.shrink: transform.parent = end.transform; // switch anchor to end if (len > 0 + Time.deltaTime * fireSpeed) { transform.parent.localScale += -Time.deltaTime * fireSpeed * delta; } else { transform.parent.localScale += -len * delta; Reset(); } break; } }
// Use this for initialization void Start() { turret = transform.parent.GetComponent<Turret>(); Physics.IgnoreCollision(turret.collider, collider); // ignore turret collider Physics.IgnoreCollision(turret.GetComponentInChildren<Detector>().collider, collider); // ignore detector collider transform.parent = turret.transform; // attach to the turret originScaleInit = origin.transform.localScale; laserShotPosInit = transform.localPosition; laserShotScaleInit = transform.localScale; fireTime = 0; armTime = turret.armTime; fireSpeed = turret.fireSpeed; maxScale = turret.detectorLength/turret.halfTurretLength*originScaleInit.x + originScaleInit.x; if (turret.direction == Turret.Direction.up || turret.direction == Turret.Direction.down) { delta = new Vector3(0, 0, 1); } else { delta = new Vector3(1, 0, 0); } // set end point scale to max! endScaleInit = end.transform.localScale; end.transform.localScale += (maxScale - Vector3.Dot (endScaleInit, delta)) * delta; endScaleInit = end.transform.localScale; shootState = ShootState.alert; }
public void Fire() { if (SafetyEngaged == false) { if (Time.time > NextFire) { if (CurrentReload == ReloadState.None && NeedsToReload == false) { if ( (CurrentGunState == GunState.Auto) || (CurrentGunState == GunState.Burst && CurrentBurst <= BurstAmount) || (CurrentGunState == GunState.Single && CurrentBurst <= 1)) { CurrentBurst++; MuzzleFlareVisible = true; if (CurrentShoot == ShootState.None) { CurrentShoot = ShootState.LoopStart; WeaponObject.animation.Play("shootStart"); } else if (CurrentShoot == ShootState.Loop) { WeaponObject.animation.Play("shootLoop"); } FireRound(); NextFire = Time.time + FireDelay; } } } } }
private void EnterFireLoop() { CurrentShoot = ShootState.Loop; }
private void StopShooting(bool isOnce) { if (CurrentReload == ReloadState.None) { if (isOnce == false) { WeaponObject.animation.Play("shootEnd"); CurrentShoot = ShootState.LoopEnd; CurrentBurst = 0; } else { StartIdling(); CurrentShoot = ShootState.None; CurrentBurst = 0; } } }