public Instruction(Direction direction, MoveType moveType, FiringState fireStatus1, FiringState fireStatus2) { this.Direction = direction; this.MoveType = moveType; this.FireStatus1 = fireStatus1; this.FireStatus2 = fireStatus2; }
public void Fire(StaticItem source, FiringState firingState, Direction direction) { if (direction == Direction.None) { throw new ArgumentOutOfRangeException(nameof(direction)); } if (firingState != FiringState.Pulse || source.Energy < 4) { return; } var adjacentTilePos = source.TilePosition.GetPositionAfterOneMove(direction); var itemsOnTile = GlobalServices.GameState.GetItemsOnTile(adjacentTilePos); if (itemsOnTile.Any(item => item.Properties.Get(GameObjectProperties.EffectOfShot) == EffectOfShot.Impervious)) { return; } var startPos = source.TilePosition.ToPosition() + direction.ToVector() * Constants.CentreOfTile; GlobalServices.GameState.AddStandardShot(startPos, direction, source.Energy >> 2, source); source.PlaySound(GameSound.PlayerShoots); _countOfShotsBeforeCostingEnergy--; if (_countOfShotsBeforeCostingEnergy < 0) { _countOfShotsBeforeCostingEnergy = 3; source.ReduceEnergy(1); } }
private void FireControl() { switch (firingState) { case FiringState.Idle: if (Input.GetMouseButtonDown(0)) { // click to pull back firingState = FiringState.Aiming; } break; case FiringState.Aiming: MoveProjectileToMousePosition(); if (Input.GetMouseButtonUp(0)) { // Release the slingshot firingState = FiringState.Firing; // we damp it when we're pulling back so that it doesn't oscillate // Now turn this off to let it accelerate springJoint.dampingRatio = 0f; } break; case FiringState.Firing: if (transform.position.x >= springAttachmentPoint.x) { springJoint.enabled = false; // if we're close enough to the center, turn off the spring (so that the projectile flies) GetComponent <DistanceJoint2D>().enabled = false; // also turn off the distance lock } break; } }
public void Fire(StaticItem source, World world, FiringState firingState, Direction direction) { if (firingState != FiringState.Pulse || this._countOfMinesRemaining < 1) return; TilePos tp = source.TilePosition; if (world.IsStaticItemOnTile(tp)) return; world.AddMine(tp.ToPosition()); this._countOfMinesRemaining--; }
void Start() { //Initialise states idleState = gameObject.AddComponent <IdleState>(); runState = gameObject.AddComponent <RunState>(); jumpState = gameObject.AddComponent <JumpState>(); shootState = gameObject.AddComponent <FiringState>(); State.AssignPlayer(this); AttachedRigidBody = GetComponent <Rigidbody2D>(); PlayerSprite = GetComponentInChildren <SpriteRenderer>(); PlayerAnimator = GetComponentInChildren <Animator>(); PlayerAudio = GetComponent <AudioSource>(); Reset(); }
public void Fire() { if (firingState == null) { firingState = new FiringState(playerView); GameApplication.Instance.GetService <ISoundService>().PlayShootSound(); AddToStateDictionary(firingState, true); } var _bulletController = GameApplication.Instance.GetService <IBulletService>().SpawnBullet(this); Vector3 firePos = playerView.GetMuzzlePosition(); Quaternion fireRot = playerView.GetMuzzleRotation(); Vector3 fireDirection = playerView.GetMuzzleDirection(); _bulletController.FireBullet(firePos, fireRot, fireDirection); }
public void Fire(StaticItem source, FiringState firingState, Direction direction) { if (firingState != FiringState.Pulse || this._countOfMinesRemaining < 1) { return; } TilePos tp = source.TilePosition; if (GlobalServices.GameState.IsStaticItemOnTile(tp)) { return; } var mine = GlobalServices.GameState.AddMine(tp.ToPosition()); mine.PlaySound(GameSound.MineLaid); this._countOfMinesRemaining--; }
// Update is called once per frame void Update () { if (reloading >= 0) { reloading -= Time.deltaTime; } if (reloading > 0) { currentState = FiringState.Reloading; } else if (IsBarrelMoving()) { currentState = FiringState.Moving; } else { currentState = FiringState.Firing; } }
void FiringBehavior() { velocity.x = 0; if (lastPlacePlayerSeen != null) { faceDirX = (int)Mathf.Sign(lastPlacePlayerSeen.position.x - gameObject.transform.position.x); } #region Switching or Keeping State if (GeometryUtility.TestPlanesAABB(planes, thisCollider.bounds)) { if (Time.time > NextTimeToRaycast) { RaycastHit2D hit = LookAtPlayerSpiderWalker(); if (hit && hit.transform.tag == "Player") { if (firingState == FiringState.ready && Time.time > endShockwaveCooldownTime) { FireArrow(); firingState = FiringState.firing; } endFireTime = Time.time + fireAttentionSpan; } else { if (Time.time > endFireTime) { firingState = FiringState.turningOff; } } } } else { if (Time.time > endFireTime) { firingState = FiringState.turningOff; } } #endregion }
public Barrel(OutputPort supply, OutputPort tank, OutputPort shot, AnalogInput pressure, AirMaster fillMaster, int barrelNumber) { this.supplyValve = supply; this.tankValve = tank; this.shotValve = shot; this.pressureSensor = pressure; this.fillMaster = fillMaster; this.barrelNumber = barrelNumber; closeValve(supplyValve); closeValve(tankValve); closeValve(shotValve); idleState = new IdleState(); waitFillState = new WaitFillState(); seatingState = new SeatingState(); fillingState = new FillingState(); waitFireState = new WaitFireState(); preFireState = new PreFireState(); firingState = new FiringState(); }
protected new void Awake() { base.Awake(); Reach = _ORIGINAL_HEIGHT; HalfWidth = _ORIGINAL_HALFWIDTH; _coll = GetComponent <PolygonCollider2D>(); _coll.enabled = false; _points = new Vector2[6]; _audioSourceLoop = GetComponent <AudioSource>(); _chargingTimer = new Timer(TimeOfCharge); FireChargingState s1 = new FireChargingState(_ASM, this); FiringState s2 = new FiringState(_ASM, this); s1.SetTargetStates(s2); s2.SetTargetStates(s1); _ASM.InitializeWithStates(new InactiveEnabledAttackState(_ASM, this), s1); ClearCooldown(); }
public void Fire(StaticItem source, World world, FiringState firingState, Direction direction) { if (direction == Direction.None) throw new ArgumentOutOfRangeException("direction"); if (firingState != FiringState.Pulse || source.Energy < 4) return; var startPos = source.TilePosition.ToPosition(); var shot = new StandardShot(world, startPos, direction, source.Energy >> 2, ShotType.Player); if (!shot.CanMoveInDirection(direction)) return; startPos += direction.ToVector() * Tile.Size / 2; shot.SetPosition(startPos); world.AddShot(shot); world.Game.SoundPlayer.Play(GameSound.PlayerShoots); _countOfShotsBeforeCostingEnergy--; if (_countOfShotsBeforeCostingEnergy < 0) { _countOfShotsBeforeCostingEnergy = 3; source.ReduceEnergy(1); } }
public Instruction(Direction direction, FiringState fireStatus1, FiringState fireStatus2) { this.Direction = direction; this.FireStatus1 = fireStatus1; this.FireStatus2 = fireStatus2; }
public void ReadyToFire() { firingState = FiringState.ready; }
void SwitchToFiring() { spiderWalkerState = SpiderWalkerState.firing; firingState = FiringState.prepping; endFireTime = Time.time + fireAttentionSpan; }
public void Start() { firingState = FiringState.Reloading; firingTimer = reloadTime; trackingTimer = 0; laserRenderer.enabled = false; trackingState = TrackingState.TrackingRight; targets = new List<GameObject>(); currentTarget = null; }
public PlayerControl(Direction direction, FiringState fireState1, FiringState fireState2) { this.Direction = direction; this.FireState1 = fireState1; this.FireState2 = fireState2; }
void TrackTarget() { if (!currentTarget) { return; } float angle = Quaternion.FromToRotation(Vector3.up, currentTarget.transform.position - gunPivot.position).eulerAngles.z; gunPivot.eulerAngles = new Vector3(0, 0, angle); switch (firingState) { case FiringState.Ready: // Fire! firingState = FiringState.Firing; firingTimer = fireTime; if (firingSound) { AudioSource3D.PlayClipAtPoint(firingSound, transform.position); } laserRenderer.enabled = true; if (currentTarget) { laserRenderer.SetPosition(0, laserOrigin.position); int layerMask = 0; beamBlockingLayers.ForEach(l => layerMask |= 1 << LayerMask.NameToLayer(l)); Vector3 direction = currentTarget.transform.position - laserOrigin.position; RaycastHit2D hit = Physics2D.Raycast(laserOrigin.position, direction, layerMask); if (hit) { laserRenderer.SetPosition(1, hit.point); } } break; case FiringState.Firing: // Update laser firingTimer -= Time.deltaTime; if (currentTarget) { laserRenderer.SetPosition(0, laserOrigin.position); int layerMask = 0; beamBlockingLayers.ForEach(l => layerMask |= 1 << LayerMask.NameToLayer(l)); Vector3 direction = currentTarget.transform.position - laserOrigin.position; RaycastHit2D hit = Physics2D.Raycast(laserOrigin.position, direction, Mathf.Infinity, layerMask); if (hit) { laserRenderer.SetPosition(1, hit.point); } if (firingTimer < 0) { if (hit) { hit.collider.gameObject.SendMessage("TakeDamage", 1, SendMessageOptions.DontRequireReceiver); } } } if (firingTimer < 0) { laserRenderer.enabled = false; firingState = FiringState.Reloading; firingTimer = reloadTime; } break; case FiringState.Reloading: // Wait for reload firingTimer -= Time.deltaTime; if (firingTimer < 0) { firingState = FiringState.Ready; } break; } }