/// <summary> /// Load the components required for this script. /// </summary> protected void Awake() { animator = GetComponent<Animator>(); audioSource = GetComponent<AudioSource>(); shipMovement = GetComponent<Movement>(); shipShooter = GetComponent<Shooter>(); }
public ShooterInstructions getShooterInstructions(GameTime gameTime, Shooter shooter) { if (targetPosition == null) { targetPosition = calculateTargetAngle(gameTime, shooter); currentWait = AiWait; Debug.Assert(targetPosition <= Shooter.MAX_ROTATION && targetPosition >= Shooter.MIN_ROTATION, "Target Angle must be between the clamp values impossed by the shooter class"); } if (shooter.aimingAngle == targetPosition) { if (currentWait > TimeSpan.Zero) { currentWait -= gameTime.ElapsedGameTime; return new ShooterInstructions(0.0f, false); } else { targetPosition = null; return new ShooterInstructions(0.0f, true); } } else { return ShooterControllerHelper.towardsTargetAngle((float)targetPosition, shooter.aimingAngle); } }
public ShooterInstructions getShooterInstructions(GameTime gameTime, Shooter shooter) { KeyboardState currentKeyboardState = Keyboard.GetState(); float shooterMovement = 0.0f; if (currentKeyboardState.IsKeyDown(Keys.Left)) { shooterMovement += MOVEMENT_SPEED; } if (currentKeyboardState.IsKeyDown(Keys.Right)) { shooterMovement -= MOVEMENT_SPEED; } if (currentKeyboardState.IsKeyDown(Keys.S)) { shooterMovement /= 5.0f; } bool fireBall; if (currentKeyboardState.IsKeyDown(Keys.Space)) { fireBall = true; } else { fireBall = false; } return new ShooterInstructions(shooterMovement, fireBall); }
void Start () { shooter = GetComponent<Shooter> (); if (shooter == null) { throw new MissingComponentException("Must have a Shooter script attached"); } }
/// <summary> /// Load all components required to run this script. /// </summary> protected void Awake() { myTransform = transform; movement = GetComponent<Movement>(); shooter = GetComponent<Shooter>(); powerUpManager = GetComponent<PlayerPowerUpManager>(); }
public Score(Shooter shooter, Vector2 drawRatio, String label) : base(Game1.game) { this.score = 0; this.shooter = shooter; this.label = label; this.drawRatio = drawRatio; EventHandlers.getInstance().collision += collisionEventHandler; }
public SetupPacket(List<Shooter> shooters, Shooter clientsShooter) { foreach (Shooter shooter in shooters) { data += shooter.identifier + "@" + colorToString(shooter.color) + ","; } data = data.TrimEnd(','); data += "#" + clientsShooter.identifier; }
void Start() { //getcomponent shoot = GameObject.Find("Main Camera"); shooter = shoot.GetComponent<Shooter>(); isInvincible = false; anim = gameObject.GetComponent<Animator>(); GameManager.OnDuckMiss += MakeInvincible; GameManager.OnDuckShot += MakeInvincible; }
//DISPLAY GUI items on game objects // Use this for initialization void Start() { shooterScript = ShooterShip.GetComponent<Shooter>(); GUItext = GameObject.Instantiate(GUItext) as GameObject; GUItext.GetComponent<GUIText>().text = "Target"; ThreeDtext = GameObject.Instantiate(ThreeDtext) as GameObject; ThreeDtext.GetComponent<TextMesh>().text = "Target"; }
public Ball(Shooter shotBy, Circle startingLocation, float angle, bool isSimulation = false) : base(Game1.game) { this.shotBy = shotBy; this.isSimulation = isSimulation; this.location = startingLocation; maxSpeed = PhysicsSettings.MAX_BALL_SPEED; color = RandomHelper.randomBasicColor(); velocity = new PolarCoordinate(PhysicsSettings.MAX_BALL_SPEED, angle).toCartesian(); }
void Start() { anim = GetComponent<Animator> (); duckSprite = GetComponent<SpriteRenderer> (); GameObject shooter = GameObject.Find("Main Camera"); shoot = shooter.GetComponent<Shooter>(); bounce = 0; GameManager.OnDuckShot += StopMovement; GameManager.OnDuckMiss += FlyAway; RandomDirection(); paused = false; }
public void ballFallenEventHandler(object sender, BallFallenArgs e) { //Check ball is not a ball being simulated by the AI if(!e.ball.isSimulation) { Shooter deactivatedShooter = activeShooter; shooterQueue.Enqueue(activeShooter); activeShooter = shooterQueue.Dequeue(); EventHandlers.getInstance().raiseEvent(new TurnChangeArgs(activeShooter, deactivatedShooter)); } }
// Use this for initialization void Start() { numberOfBalls= 3; updateTime= 3; nextUpdate= Time.time+updateTime; shooter = (Shooter)FindObjectOfType(typeof(Shooter)); scene= (Scene)FindObjectOfType(typeof(Scene)); positions= new Vector3 [numberOfBalls]; positions[0]= new Vector3(-16,2,-12); positions[1]= new Vector3(-15,2,-12); positions[2]= new Vector3(-14,2,-12); balls= new Ball[numberOfBalls]; regenerateBalls(); }
public Enemy(Game i_Game, int i_NumOfTexture, int i_NumOfImageFromTexture, int i_Score, Color i_TintColor, int i_MaxNumOfBullets) : base(k_EnemiesPath, i_Game) { m_MaxNumOfBullets = i_MaxNumOfBullets; r_NumOfTexture = i_NumOfTexture; Velocity = new Vector2(r_EnemyInitialVelocity, 0); m_AreMovingDown = false; r_StartIndexInTexture = i_NumOfImageFromTexture; TintColor = i_TintColor; TeamColor = r_TeamColor; IsAlive = true; r_Score = i_Score; r_Shooter = new Shooter(m_MaxNumOfBullets, Game, r_BulletColor, true, false); }
// Use this for initialization void Start() { GameObject shooter = GameObject.Find("Main Camera"); shoot = shooter.GetComponent<Shooter>(); roundPopupText = roundPopupNumText.GetComponent<Text>(); GameManager.OnDuckMiss += FlyAwaySkyOn; GameManager.OnDuckFlyAway += FlyAwaySkyOff; GameManager.OnSpawnDucks += FlyAwaySkyOff; GameManager.OnNewRound += FlyAwaySkyOff; GameManager.OnStartGame += DisplayRoundNumOn; GameManager.OnNewRound += DisplayRoundNumOn; GameManager.OnSpawnDucks += DisplayRoundNumOff; }
public void ChangeWeapon(int num) { if (CurrentWeapon != null) { // Unsubscribe to event if the gun is not null CurrentWeapon.OnGunShoot -= GunShotEvent; } weapons[currentWeapon].gameObject.SetActive(false); currentWeapon = num; weapons[currentWeapon].gameObject.SetActive(true); CurrentWeapon = weapons[currentWeapon].GetComponent<Shooter>(); // Subscribe to the current weapons shoot event CurrentWeapon.OnGunShoot += GunShotEvent; }
protected override void OnSimulateFixedStart() { if (DroneAIType.Value == 1) { IAmSwitching = true; TargetSelector(); } else { foreach (DroneControlBlockBehavior DCBB in Machine.Active().SimulationMachine.GetComponentsInChildren <DroneControlBlockBehavior>()) { if (DCBB.DroneTag.Value == this.DroneTag.Value) { DCBB.AIDroneList.Add(this); MyControl = DCBB; break; } } } Shooter = Instantiate(PrefabMaster.BlockPrefabs[11].gameObject); Shooter.transform.parent = this.transform; Destroy(Shooter.GetComponent <ConfigurableJoint>()); 炮弹速度 = 5 * 58; Shooter.transform.localEulerAngles = Vector3.right * 270; Shooter.transform.localPosition = Vector3.up * 0.8f + Vector3.forward * 3f; Destroy(Shooter.GetComponentInChildren <CapsuleCollider>()); CB = Shooter.GetComponent <CanonBlock>(); CB.knockbackSpeed = 30; CB.myRigidbody = rigidbody; Destroy(Shooter.GetComponent <Rigidbody>()); CB.Sliders[0].Value = 5; MeshCollider MC = this.transform.GetComponentInChildren <MeshCollider>(); MC.material.dynamicFriction = 0; MC.material.staticFriction = 0; MyPrecision = 0.25f; MySize = 1; 精度 = 0.25f; size = 1; SetUpHP(200); RotatingSpeed = 1f; //RotatingSpeed = 5f; PositionIndicator = GameObject.CreatePrimitive(PrimitiveType.Sphere); DestroyImmediate(PositionIndicator.GetComponent <Rigidbody>()); DestroyImmediate(PositionIndicator.GetComponent <Collider>()); }
protected Projectile SpawnProjectile(Shooter p_shooter) { GameObject proj = Game.m_projPool.Get(); Projectile projectile = proj.GetComponent <Projectile>(); Projectile referenceProj = Projectile.Get(m_projectile); proj.transform.position = m_spawnLocation == Vector3.zero ? p_shooter.transform.position : (Vector3)m_spawnLocation; proj.transform.rotation = referenceProj.transform.rotation; projectile.Clone(referenceProj, m_projectileInfo, m_behaviours); projectile.m_reference = false; projectile.GetComponent <PolygonColliderExtruder>().Extrude(); return(projectile); }
internal void Equip(int index) { DeactivateWeapons(); canFire = true; m_ActiveWeapon = weapons [index]; m_ActiveWeapon.Equip(); weapons [index].gameObject.SetActive(true); if (OnWeaponSwitch != null) { OnWeaponSwitch(m_ActiveWeapon); } }
// Use this for initialization void Start() { m_Trans = transform; m_Enemy = GameObject.FindGameObjectWithTag("Enemy").GetComponent<Entity>(); m_Gun = m_Trans.GetComponent<Shooter>(); m_Gun.PlayerTransform = m_Trans; m_Beacon = m_Trans.GetComponent<BeaconTool>(); m_Beacon.Enemy = m_Enemy; m_StunGrenade = m_Trans.GetComponent<StunGrenadeTool>(); m_StunGrenade.PlayerTransform = m_Trans; }
// Use this for initialization void Start() { shooter = GameObject.Find("Shooter").GetComponent <Shooter>(); // Determine what type of powerup this is potentialAbilities[0] = new ShrapnelBlast(shooter); potentialAbilities[1] = new ShrapnelBlast(shooter); potentialAbilities[2] = new FasterCamera(shooter); potentialAbilities[3] = new StopCamera(shooter); abilityGiven = potentialAbilities[Random.Range(0, potentialAbilities.Length)]; renderer = this.GetComponent <SpriteRenderer>(); renderer.sprite = Resources.Load(abilityGiven.iconString, typeof(Sprite)) as Sprite; }
protected Projectile SpawnProjectile(Shooter p_shooter) { GameObject proj = Game.m_projPool.Get(); Projectile projectile = proj.GetComponent <Projectile>(); object spawnLocation = p_shooter.GetPatternInfo(this, "spawnLocation"); float offset = p_shooter.m_entity.transform.localScale.y / 2; //m_entity.m_renderer.sprite.bounds.max.y; proj.transform.position = spawnLocation == null ? p_shooter.transform.position : (Vector3)spawnLocation; proj.transform.position += new Vector3(0, m_flipShootOrigin ? -offset : offset, 0); proj.transform.rotation = m_projectile.transform.rotation; projectile.Clone(m_projectile, m_projectileInfo, m_behaviours); return(projectile); }
// Reparte los valores corriespondiente de la clase a cada componente private void Awake() { life = GetComponent <Life>(); armor = GetComponent <Armor>(); shooter = GetComponent <Shooter>(); playerMovement = GetComponent <PlayerMovement>(); playerCamera = GetComponentInChildren <Camera>(); PlayerJob(); foreach (Weapon weapon in classWeapons) { Instantiate(weapon, shooter.weaponAnchor.position, shooter.weaponAnchor.rotation, shooter.weaponAnchor); } skillQ = Instantiate(skill[0], gameObject.transform).GetComponentInChildren <Skill>(); skillE = Instantiate(skill[1], gameObject.transform).GetComponentInChildren <Skill>(); }
/// <summary> /// Check user validations /// </summary> /// <param name="entity">entity to check</param> /// <returns>List of validation results</returns> private IList <ValidationResult> CheckUserValidation(Shooter entity) { var validations = new List <ValidationResult>(); // controllo esistenza customer con stesso nome var existing = _userRepository.GetSingle(x => x.Id != entity.Id && (x.Username == entity.Username || x.Email == entity.Email)); if (existing != null) { validations.Add(new ValidationResult($"Entity with username or email already exist. {entity.Username} ({entity.Email})")); } return(validations); }
void Start() { shooter = gameObject.GetComponent <Shooter>(); projectile2 = Instantiate(shooter.projectile, gameObject.transform.position, Quaternion.identity); projectile2.transform.parent = shooter.projectile.transform; projectile2.transform.localScale = shooter.projectile.transform.localScale; shooter2 = shooter.projectile.AddComponent <Shooter>(); shooter2.projectile = projectile2; shooter2.numOfGuns = 6; shooter2.angleBetweenGuns = 60; shooter2.forwardOffset = 0.1f; shootOnDeath = shooter.projectile.AddComponent <ShootOnDeath>(); //shootOnDeath.allowedDeathCause = DeathCause.Сollision; shootOnDeath.shooter = shooter2; }
private void OnTriggerStay(Collider other) { if (other.tag == "Player") { if (Input.GetKeyDown(KeyCode.E)) { Shooter shooter = other.GetComponent <Shooter>(); if (shooter != null) { shooter._addAmmo(); Destroy(this.gameObject); } } } }
bool CheckMouseHit(Vector3 screenSpacePosition) { Ray ray = cam.ScreenPointToRay(screenSpacePosition); if (Physics.Raycast(ray, out RaycastHit hit, 1000, touchableMask)) { currentSelectedShooter = hit.collider.gameObject.GetComponentInParent <Shooter>(); raduis = currentSelectedShooter.transform.lossyScale.x * .5f; if (currentSelectedShooter.isTurn) { return(true); } } return(false); }
void RegisterEvents(WorldWalker walker, Shooter shooter, UnitSelector selector) { walker.MovementStarted += OnMovementStarted; walker.MovementFinished += OnMovementFinished; walker.MovementFailed += OnMovementFailed; walker.MovementCanceled += OnMovementCanceled; shooter.BeforeShotFired += BeforeShotFired; shooter.TargetAutoAcquired += OnTargetAutoAcquired; shooter.TargetDestroyed += OnTargetDestroyed; selector.UnitSelected += OnUnitSelected; }
private void SetWeaponActive(Shooter weapon, bool active) { // TODO: find a better way to set weapons to character's hand var parent = active ? hand : weaponsContainer; weapon.transform.SetParent(parent); if (active) { weapon.transform.localPosition = Vector3.zero; weapon.transform.localRotation = Quaternion.identity; } weapon.gameObject.SetActive(active); }
private void Start() { if (m_shooter == null) { m_shooter = GetComponent <Shooter>(); } if (m_shooter == null) { Debug.LogErrorFormat("Shooter Controller in {0} requires Shooter. Destroying.", name); Destroy(gameObject); return; } m_fireButton = InputManager.GetKeyCodeForGamepadInput(GamepadInput.ButtonX); }
private IEnumerable <ParticipationViewModel> FetchParticipationsByShooter(Shooter shooter) { ServiceDeskConfiguration sdk = ServiceLocator.Current.GetInstance <ServiceDeskConfiguration>(); ParticipationDescriptionCollection participations = sdk.ParticipationDescriptions; return(from shooterParticipation in _shooterParticipationDataStore.FindByShooterId(shooter.ShooterId) join participation in participations.GetAll() on shooterParticipation.ProgramNumber.ToString() equals participation.ProgramNumber orderby participation.ProgramNumber select new ParticipationViewModel { ProgramName = participation.ProgramName, ProgramNumber = shooterParticipation.ProgramNumber }); }
// Use this for initialization void Start() { GameObject shooter = GameObject.Find("Main Camera"); shoot = shooter.GetComponent <Shooter>(); roundPopupText = roundPopupNumText.GetComponent <Text>(); GameManager.OnDuckMiss += FlyAwaySkyOn; GameManager.OnDuckFlyAway += FlyAwaySkyOff; GameManager.OnSpawnDucks += FlyAwaySkyOff; GameManager.OnNewRound += FlyAwaySkyOff; GameManager.OnStartGame += DisplayRoundNumOn; GameManager.OnNewRound += DisplayRoundNumOn; GameManager.OnSpawnDucks += DisplayRoundNumOff; }
public void shooter_shooting_weapon_with_several_attacks_generates_as_much_ranged_attacks() { int randomNumberOfAttacks = new Random().Next(1, 10); int randomStrenght = new Random().Next(1, 10); Target target = new(1); Weapon weapon = new(randomNumberOfAttacks, randomStrenght); Shooter shooter = new Shooter(1); IEnumerable <RangedAttack> rangedAttacks = shooter.Shoot(target, weapon); Assert.AreEqual(randomNumberOfAttacks, rangedAttacks.Count()); Assert.IsTrue(rangedAttacks.All(r => r.WeaponStrenght == weapon.Strenght)); Assert.IsTrue(rangedAttacks.All(r => r.Shooter == shooter)); Assert.IsTrue(rangedAttacks.All(r => r.Target == target)); }
private float calculateTargetAngle(GameTime currentElapsedTime, Shooter shooter) { PriorityQueue<int, float> possibleShots = new PriorityQueue<int, float>(Comparer<int>.Default); const float interval = (Shooter.MAX_ROTATION - Shooter.MIN_ROTATION) / NO_SHOTS_SIMULATED; for (float angle = Shooter.MIN_ROTATION; angle < Shooter.MAX_ROTATION; angle += interval) { possibleShots.enqueue(new KeyValuePair<int, float>(new ShootSimulator(currentElapsedTime, shooter, angle).actionValue, angle)); } List<KeyValuePair<int, float>> bestShots = possibleShots.getBaseStorage().FindAll(shot => shot.Key == possibleShots.last().Key); return bestShots[RandomHelper.getRandom().Next(bestShots.Count)].Value; }
private static bool HasTargetableTarget(Turret turret, Shooter shooter, Transform target) { Vector3 toTarget = target.transform.position - turret.Gun.transform.position; Quaternion toTargetQ = Quaternion.LookRotation(toTarget.normalized); bool targettable = TargetInRange(turret, shooter, target); targettable &= Mathf.Abs(toTargetQ.eulerAngles.x) <= turret.MaxRotationXVertical; if (targettable) // optimization? do not raycast if this is false already { targettable &= TargetInSight(turret, target.transform.position, toTarget); } return(targettable); }
public static void CreatePlayers(Room room) { room.Groups.Player.defaultNode = room.MasterGroup.defaultNode.CreateClone(room); Shooter.MakeBullet(room); if (!EnablePlayers) { return; } //def.addComponent(comp.shooter, true); for (int i = 1; i < 5; i++) { TryCreatePlayer(room, room.Groups.Player.defaultNode, i, false); } //OrbIt.ui.sidebar.playerView.InitializePlayers(); }
private Shooter CreateUnknownShooter(int shooterNumber) { Person person = new Person() { FirstName = "unknown", LastName = "unknown" }; _personDataStore.Create(person); Shooter shooter = new Shooter(); shooter.PersonId = person.PersonId; shooter.ShooterNumber = shooterNumber; _shooterDataStore.Create(shooter); return(shooter); }
public static void CreateProjectile(Shooter shooter, GameObject prefab, Vector2 position, Vector2 look) { GameObject go = Pools.Instance.Get(prefab, position, Quaternion.identity); Projectile proj = go.GetComponent <Projectile>(); proj.shooter = shooter; proj.transform.right = look; if (proj.shooter.weaponData.operateInBotSpace) { go.transform.parent = shooter.gameObject.transform; } proj.sm.PlayClip(proj.shotSound); proj.Init(); BotManager.Instance.Projectiles.Add(proj); proj.managed = true; }
public ShootSimulator(GameTime time, Shooter shooter, float aimAngle) { actionValue = 0; EventHandlers.getInstance().collision += collisionEventHandler; simulatedBall = new Ball(null, shooter.calculateBallStartingLocation(aimAngle), aimAngle, true); Game1.addGameComponent(simulatedBall); while (!simulatedBall.ballFallen()) { Game1.levelStateManager.currentLevel.physicsProcessor.Update(time); } EventHandlers.getInstance().collision -= collisionEventHandler; Game1.removeGameComponent(simulatedBall); }
public void Equip(Gun gun) { if (this.hand.root != this.transform) { throw new Exception("Hand object is not attached to the gunholder"); } this.gun = gun; GameObject gunObject = Instantiate(this.gun.prefab); gunObject.transform.SetParent(hand); gunObject.transform.localPosition = gun.position; gunObject.transform.localEulerAngles = gun.rotation; gunObject.transform.localScale = gun.scale; this.shooter = gunObject.GetComponent <Shooter>(); }
public override void Init(Shooter p_shooter) { p_shooter.SetPatternInfo(this, "shift", Vector2.zero); p_shooter.SetPatternInfo(this, "shiftReverse", false); p_shooter.SetPatternInfo(this, "localShiftAngle", m_shiftAngle); if (m_shots % 2 == 0) { p_shooter.SetPatternInfo(this, "shiftOverHalf", true); p_shooter.SetPatternInfo(this, "shiftReverse", true); } else { p_shooter.SetPatternInfo(this, "shiftOverHalf", false); } }
public override void Init(Shooter p_shooter) { m_shift = Vector2.zero; m_shiftReverse = false; m_localShiftAngle = m_shiftAngle; if (m_shots % 2 == 0) { m_shiftOverHalf = true; m_shiftReverse = true; } else { m_shiftOverHalf = false; } }
private bool AddLoop(Shooter p_shooter) { p_shooter.SetPatternInfo(this, "shotsFired", 0); p_shooter.SetPatternInfo(this, "loops", (int)p_shooter.GetPatternInfo(this, "loops") + 1); p_shooter.SetPatternInfo(this, "lastLoopTime", Time.time * 1000); if (IsDoneLooping(p_shooter)) { p_shooter.StopShooting(this); return(true); } Init(p_shooter); return(false); }
void Start() { DetermineLanePosition(); raceManager = GameObject.FindObjectOfType <RaceManager>(); shooter = GetComponent <Shooter>(); player4RightSideCollider = GameObject.FindObjectOfType <Player4RightSideCollider>(); player4LeftSideCollider = GameObject.FindObjectOfType <Player4LeftSideCollider>(); leftTouchInput = GameObject.FindObjectOfType <LeftTouchInput>(); rightTouchInput = GameObject.FindObjectOfType <RightTouchInput>(); carPositionManager = GameObject.FindObjectOfType <CarPositionManager>(); engineAudioSource = GetComponent <AudioSource>(); anim = GetComponent <Animator>(); collisionHandler = GetComponent <CollisionHandler>(); speedProgressBar = GameObject.FindObjectOfType <SpeedProgessBar>(); desiredXPos = transform.position.x; //desiredXPos isn't assigned a value until we push left or right, need default value } //End Start
/** * Controller for weapon - enabling and disabling the weapon based on its position (within or out of restricted area). * @param colliding object - GameObject (weapon expected). * @param flag to enable/disable weapon - bool. */ private void ShootingController(GameObject collidingObject, bool flag) { if (collidingObject.tag == "ShootControl") { Transform parent = collidingObject.transform.parent; if (parent.tag == "Weapon") { if (weapon == null || !parent.Equals(weapon)) { weapon = parent.gameObject; shooterScript = parent.GetComponent <Shooter>(); } shooterScript.ControlShooting(flag); } } }
private bool AddLoop(Shooter p_shooter) { m_shotsFired = 0; m_loops++; m_lastLoopTime = Time.time; if (IsDoneLooping(p_shooter)) { p_shooter.StopShooting(this); return(true); } Init(p_shooter); return(false); }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("Bottle") || other.CompareTag("Glass")) { Destroy(other.gameObject); if (!Shooter.isGameOver) { Shooter health = obj.transform.GetComponent <Shooter>(); Shooter.Health -= 1; } } else { Destroy(other.gameObject); } }
public void SetAbilityShot(GameObject NewAbility) { //If there is an ability already Delete the Ability if (Cannon == null) { Cannon = GetComponentInChildren <Shooter>(); } if (Cannon != null) { Cannon.SetShot(NewAbility); } else { Debug.LogError("there is no cannon!"); } }
/// <summary> /// Initialize bullet in random direction. /// </summary> public void Initialize(Shooter owner, float scatterAngle) { this.owner = owner; deathTrigger.Pool = owner.bulletPool; deathTrigger.OnInitialize(); movement.speed = initialSpeed; movement.Lock = false; if (scatterAngle > 0) { float randomAngle = Mathf.Deg2Rad * Random.Range(-scatterAngle, scatterAngle); movement.Direction = new Vector2(owner.transform.right.x * Mathf.Cos(randomAngle), transform.up.y * Mathf.Sin(randomAngle)); } else { movement.Direction = owner.transform.right; } }
public ShooterInstructions getShooterInstructions(GameTime gameTime, Shooter shooter) { if (targetPosition != null) { if (Math.Abs(shooter.aimingAngle - (float)targetPosition) < 0.005f) { targetPosition = null; return new ShooterInstructions(0.0f, true); } else { return ShooterControllerHelper.towardsTargetAngle((float)targetPosition, shooter.aimingAngle); } } else { return new ShooterInstructions(0.0f, false); } }
public TurnManager(Queue<Shooter> shooters) : base(Game1.game) { EventHandlers.getInstance().ballFallen += ballFallenEventHandler; shooterQueue = shooters; foreach (Shooter shooter in shooters) { Game1.addGameComponent(shooter); } try { activeShooter = shooterQueue.Dequeue(); EventHandlers.getInstance().raiseEvent(new TurnChangeArgs(activeShooter, null)); } catch (InvalidOperationException e) { throw new InvalidOperationException("Queue passed to ShooterController should not be empty", e); } turnCount = 0; }
public override void Update(GameTime gameTime) { foreach (PlayerRequestRecord request in playerRequests) { if(DateTime.Now - request.lastResent > TimeSpan.FromSeconds(5)) { Debug.WriteLine("Resending"); NetworkInterface.send(new PlayerRequest(), request.ip); request.lastResent = DateTime.Now; } } if (startGame) { if (playerRequests.Count > 0) { foreach (PlayerRequestRecord request in playerRequests) { if (DateTime.Now - request.firstSent > REQUEST_TIMEOUT) { Game1.addGameComponent(new Networking.TimeoutInterface(this, request)); } } } else { if (shooters.Any()) { List<IPAddress> clients = new List<IPAddress>(); for (int i = 0; i < shooters.Count; i++) { if (shooters[i].getControllerType() == typeof(NetworkShooter)) { NetworkInterface.send(new SetupPacket(shooters, shooters[i]), ((NetworkShooter)shooters[i].shooterController).ipAddress); clients.Add(((NetworkShooter)shooters[i].shooterController).ipAddress); } } foreach (Shooter shooter in shooters) { if (shooter.getControllerType() != typeof(NetworkShooter)) { shooter.clients = clients; } } Game1.setLevelManager(new LevelStateManager(shooters)); Game1.levelStateManager.loadLevel(); } else { new Alert("First add some players", new Vector2(DrawHelper.getInstance().centerX("First add some players"), 200), TimeSpan.FromSeconds(2), Color.Red); startGame = false; } } } else { KeyboardInput.KeyboardButtons keyboardButtons = KeyboardInput.getInstance().buttonStates; if (keyboardButtons.keyPresses[Keys.Down] == KeyboardInput.KeyboardActions.Pressed) { selectedShooterIndex++; } else if (keyboardButtons.keyPresses[Keys.Up] == KeyboardInput.KeyboardActions.Pressed) { selectedShooterIndex--; } if (keyboardButtons.keyPresses[Keys.Left] == KeyboardInput.KeyboardActions.Pressed) { selectedColorIndex--; } else if (keyboardButtons.keyPresses[Keys.Right] == KeyboardInput.KeyboardActions.Pressed) { selectedColorIndex++; } selectedShooterIndex = (int)MathHelper.Clamp(selectedShooterIndex, 0, shooterTypes.Count - 1); selectedColorIndex = (int)MathHelper.Clamp(selectedColorIndex, 0, colors.Count - 1); if (keyboardButtons.keyPresses[Keys.Enter] == KeyboardInput.KeyboardActions.Pressed) { switch (shooterTypes[selectedShooterIndex].Value) { case MenuOptions.StartGame: startGame = true; break; case MenuOptions.PlayerInput: shooters.Add(new Shooter(colors[selectedColorIndex], PlayerInput.getInstance(), "Player ")); break; case MenuOptions.AI: Shooter shooter; shooters.Add(shooter = new Shooter(colors[selectedColorIndex], new AI(), "Shooter ")); shooter.shooterName += shooter.identifier; break; case MenuOptions.ClientMode: Game1.removeGameComponent(this); Game1.addGameComponent(new ClientMode()); break; case MenuOptions.NetworkPlayer: NetworkPlayerOptions networkPlayerOptions; Game1.addGameComponent(networkPlayerOptions = new NetworkPlayerOptions(this)); break; } } } }
//--Unity void Start() { //reverse= false; //speed = 0.0003f; //speed of the line //MaxNumberOfBalls= 20; //number of balls which are going to appear //BallDeath= true; //Balldeath mode? shooter = (Shooter)FindObjectOfType(typeof(Shooter)); //find the shooter path = (Path)gameObject.AddComponent ("Path"); //add the path numShotedBalls= 0; nextFireTime= Time.time+rememberTime; if(cashMachine==true){ cashmachine = (CashMachine)gameObject.AddComponent ("CashMachine"); //add the path } }
// Use this for initialization void Start () { audioLoader = GetComponent<AudioLoader>(); shooter = GetComponent<Shooter>(); //Se inicializa el estado de las charcas disponibles for (int i = 0; i < poolList.Length; i++) { availablePools.Add(poolList[i].GetComponent<Pool>()); availablePools[i].SetKappa(this); } //Se inicializa la lista de jugadores a tiro playersOnSight = new List<GameObject>(); //Se inicializa la posicion y los limites de altura maxHeight = transform.position.y; transform.position -= new Vector3(0, divingDepth, 0); minHeight = transform.position.y; //Comienza su comportamiento apareciendo Invoke("StartAppearing", divingTime); }
public TurnChangeArgs(Shooter activatedShooter, Shooter deactivatedShooter) { this.activatedShooter = activatedShooter; this.deactivatedShooter = deactivatedShooter; }
// Use this for initialization void Start() { shooter = GetComponent<Shooter> (); }
void NextShooter() { if (currentShooter == null) { currentShooter = shooters[0]; } else { int nextIndex = (shooters.IndexOf(currentShooter) + 1) % shooters.Count; currentShooter = shooters[nextIndex]; } }
internal void Initialize(Shooter shooter) { transform.Find("EnergyView").GetComponent<TowerEnergyView>().Initialize(shooter); specialView = transform.Find("Special"); }
// Use this for initialization // public GameItem gameItem; void Start() { //gameItem = (GameItem)GetComponent(typeof(GameItem)); lockedOn = false; cameraScript = camera.GetComponent<CameraScript>(); shooterScript = this.GetComponent<Shooter>(); map = this.GetComponentInChildren<Map>(); invX = 1; invY = 1; if(invertX) { invX = -1; } if(invertY) { invY = -1; } }
public void playerRequestResponseEventHandler(object sender, PlayerRequestResponseArgs e) { IEnumerable<PlayerRequestRecord> requests; if ((requests = playerRequests.Where(req => req.ip.Equals(e.ip))) != null) { if (e.answer) { Shooter newShooter = new Shooter(Color.Red, null, "Shooter "); newShooter.shooterName += newShooter.identifier; newShooter.shooterController = new NetworkShooter(e.ip, newShooter.identifier); shooters.Add(newShooter); foreach (PlayerRequestRecord remove in requests) { PlayerRequestRecord copy = remove; playerRequests.TryTake(out copy); } } else { foreach (PlayerRequestRecord remove in requests) { PlayerRequestRecord copy = remove; playerRequests.TryTake(out copy); new Alert(remove.ip + " rejected your request", new Vector2(10, 450), TimeSpan.FromSeconds(2), Color.Red); ConnectedTracker.removeClient(remove.ip); } } } }