// Use this for initialization public static ShootingAction GetAction(float speed) { ShootingAction sa = ScriptableObject.CreateInstance <ShootingAction> (); sa.speed = speed; return(sa); }
public void SpawnPlayer_AddProjectile() { var gameLogic = this.CreateGameLogic(); string username = "******"; gameLogic.HandleSpawnPlayer(username); Thread.Sleep(100); ShootingAction s = new ShootingAction(); s.Angle = 0.0f; s.Username = "******"; gameLogic.HandleAction(s); var(a, b) = gameLogic.GetState(); Assert.AreEqual(1, a.Values.Count); }
public void AddProjectile_CorrectPosition_CorrectAngle() { var gameLogic = CreateGameLogic(); string username = "******"; gameLogic.HandleSpawnPlayer(username); Thread.Sleep(100); ShootingAction s = new ShootingAction(); s.Angle = 0.0f; s.Username = "******"; gameLogic.HandleAction(s); var(a, b) = gameLogic.GetState(); //Changed in the BulletModel Class from 0 Assert.False(19.2 == a.ElementAt(0).Value.Radius); }
// Update is called once per frame protected new void Update() { if (Input.GetMouseButtonDown(0) && Time.time > Player.Instance.next_fire && scene_controller.status) { Bullet bullet = Player.Instance.shoot(); ShootingAction sa = ShootingAction.GetAction(bullet.speed); sa.type = 1; RunAction(bullet.getBullet(), sa, this); Player.Instance.next_fire += Player.Instance.fire_rate * Time.deltaTime; } if (Time.time > ClayPigeonFirer.Instance.next_fire && !scene_controller.isGameOver) { ClayPigeonFirer.Instance.transform.LookAt(new Vector3(7, Random.Range(1, 10), Random.Range(6, 15))); ClayPigeon clayPigeon = ClayPigeonFirer.Instance.fireClayPigeon(RoundController.Instance); ShootingAction sa = ShootingAction.GetAction(clayPigeon.speed); sa.type = 1; RunAction(clayPigeon.getClayPigeon(), sa, this); ClayPigeonFirer.Instance.next_fire += ClayPigeonFirer.Instance.fire_rate * Time.deltaTime; } base.Update(); }
public void AddProjectile_CorrectPosition() { var gameLogic = this.CreateGameLogic(); string username = "******"; gameLogic.HandleSpawnPlayer(username); Thread.Sleep(100); ShootingAction s = new ShootingAction(); s.Angle = 0.0f; s.Username = "******"; gameLogic.HandleAction(s); var(a, b) = gameLogic.GetState(); Assert.False(0.0f == a.ElementAt(0).Value.XPos); Assert.False(0.0f == a.ElementAt(0).Value.YPos); }
void Update() { if ((data.gameStatus == GameState.GAME_OVER || data.gameStatus == GameState.WINS_GAME)) { return; } //Todo: slow mo modifier in data for effects later DeltaTimeSystem.Parse(ref delta); GameStatusManager.Parse(ref world, ref data); // Will receive players input and modify controls InputReceiver.Parse(delta, world, ref controls); CalculateReticle.Parse(ref data, world, controls, settings); CharacterMovement.Parse(ref data, ref world, delta, controls, settings); ShootingAction.Parse(ref data, ref world, delta, controls, settings); EnemyAction.Parse(ref data, ref world, delta, controls, settings); CharacterActions.Parse(ref data, world, controls, settings); CameraMovement.Parse(ref data, ref world, delta, controls, settings); CharacterLaunching.Parse(ref data, ref world, delta, controls, settings); // clears input like buttons InputDeleter.Parse(ref controls); if (data.gameStatus == GameState.GAME_OVER) { StartCoroutine(Death()); } if (data.gameStatus == GameState.WINS_GAME) { StartCoroutine(Win()); } }
public async Task FireWeapon(ShootingAction shootingAction) { bool res = false; if (_interpolator != null) { try { if (_gameLogic.IsPlayerSpawned(shootingAction.Username)) { res = _interpolator.ParseAction(shootingAction); } } catch (Exception e) { Console.WriteLine(e); } } var responseString = res ? "Fire Weapon Action accepted by interpolator" : "Fire Weapon Action rejected by interpolator."; await Clients.Caller.ReceiveString(responseString); }
public async Task MoveAndShoot(MovementAction movementAction, ShootingAction shootingAction) { bool res = true; if (_interpolator != null) { try { if (!_gameLogic.IsPlayerSpawned(movementAction.Username)) //Should Deprecate this in favor of requiring the player to call the SpawnPlayer action. { _gameLogic.HandleSpawnPlayer(movementAction.Username, movementAction.PlayerClass); } var x = Task.Run((() => _interpolator.ParseAction(movementAction))); } catch (Exception e) { Console.WriteLine(e.StackTrace); } try { var y = Task.Run((() => _interpolator.ParseAction(shootingAction))); } catch (Exception e) { Console.WriteLine(e.StackTrace); } } var responseString = res ? "Action accepted by interpolator" : "Action rejected by interpolator. Action sent too close to previous action."; await Clients.Caller.ReceiveString(responseString); }