void Start() { anchorBetweenCells = GeneralVariables.anchorBetweenCells; chainCellHeightWithAnchor = GeneralVariables.chainCellHeight_without_anchor + anchorBetweenCells; mainCharacter = GameObject.FindGameObjectWithTag("Player").GetComponent <ShootingMode> (); anchorFromCharacter = new Vector2(0.73f, -1.02f); }
public Cannon(Vector2 position, ShootingMode mode, float rotation, float baseRotation, double firePeriod, double initialDelay, Layer layer) : base(layer) { AddComponent(new PositionComponent(position)); _mode = mode; var solid = new SolidComponent(); var collider = new RectangleCollider(); collider.Size = Vector2.One * Size; collider.Position = position; solid.Collider = collider; AddComponent(solid); _rotation = rotation; _baseRotation = baseRotation; var rotationRad = MathHelper.ToRadians(rotation); _direction = new Vector2( Math.Sign((int)(Math.Cos(rotationRad) * 100)), // Double will be a tiny value instead of zero, so we need this. Math.Sign((int)(Math.Sin(rotationRad) * 100)) ); _fireAlarm = new AutoAlarm(firePeriod); _initialDelayAlarm = new Alarm(); _initialDelayAlarm.Set(initialDelay); }
void Awake() { mainCharacter = GameObject.FindWithTag("Player").GetComponent <ShootingMode>(); fixedJoint = GetComponent <FixedJoint2D> (); handleKilling = GameObject.FindWithTag("Player").GetComponent <EnemyKilling>(); arrowType = GetComponent <Shoot> (); tugComponent = mainCharacter.GetComponent <Tug> (); IgnoreOnCollisionEnter = false; }
// Use this for initialization void Awake() { velocity = GameObject.Find("ScreenInputZone").GetComponent <OnDrag>().ArrowVelocity; alpha = GameObject.Find("ScreenInputZone").GetComponent <OnDrag> ().alpha; mainCharacter = GameObject.FindWithTag("Player").GetComponent <ShootingMode>(); previousPosition = transform.localPosition; currentPosition = transform.localPosition; dx = 0.0f; dy = 0.0f; DerivatePositionVector = new Vector2(0.0f, 0.0f); }
void Start() { chainCellHeight = chainCellPrefab.GetComponent <Renderer> ().bounds.size.y; alpha = GameObject.Find("ScreenInputZone").GetComponent <OnDrag> ().alpha; mainCharacter = GameObject.FindGameObjectWithTag("Player").GetComponent <ShootingMode> (); if (mainCharacter.SwingMode) { //Jeśli jest włączony tryb swing, to tworze nowa strzale. Miejsce utworzenia jest bez znaczenia, bo po odpowiednim podpieciu anchorBetweenCells utworzy się łączenie między komórkami i gra przeniesie w odpowiednie miejsce obecną komórkę. Transform newCell = (Transform)Instantiate(chainCellPrefab, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity); newCell.GetComponent <HingeJoint2D> ().connectedBody = this.GetComponent <Rigidbody2D> (); newCell.GetComponent <HingeJoint2D> ().connectedAnchor = new Vector2(0.0f, arrowAnchor); oldCell = newCell; } }
public ShootingStage(IMainWindow _window, ShootingMode shootingMode) : base(_window) { InitializeComponent(); this.window = _window; this.parameterManager = window.ParameterManager; this.coord = window.CoordManager; this.mode = shootingMode; this.viewTimer = new DispatcherTimer(DispatcherPriority.Normal); this.viewTimer.Interval = new TimeSpan(ParameterManager.ParamtersIntervalMilliSec * 1000); this.viewTimer.Tick += viewTimer_Ticked; Loaded += new RoutedEventHandler(ShootingStage_Loaded); Unloaded += new RoutedEventHandler(ShootingStage_Unloaded); }
// Start is called before the first frame update void Start() { //Randomly choose a firing mode when created modeSelect = Random.Range(0, 2); switch (modeSelect) { case 0: shootMode = ShootingMode.RAPID; break; case 1: shootMode = ShootingMode.SPREAD; break; default: break; } StartCoroutine(DelayedDestroy(lifespan)); }
// Use this for initialization void Start() { //Debug.Log("Whatup"); player = GameObject.FindGameObjectWithTag("Player"); if (fireMode == FireMode.Simple) { myShootingMode = SimpleFire; } if (fireMode == FireMode.Burst) { myShootingMode = Burst; } if (fireMode == FireMode.Spread) { myShootingMode = SpreadShot; } if (fireMode == FireMode.BurstAndSpread) { myShootingMode += SpreadShot; myShootingMode += Burst; } if (fireMode == FireMode.BurstSpreadSine) { myShootingMode += SpreadShot; myShootingMode += Burst; myShootingMode += SineWave; } if (fireMode == FireMode.BurstNoCannon) { myShootingMode = burstNoCannon; } if (fireMode == FireMode.SineWave) { myShootingMode = SineWave; } }
public void UpdateBodies(Body[] bodies, DrawingImage zoneSource) { _buttons.unpressAll(); for (var index = 0; index < bodies.Length; index++) { var body = bodies[index]; if (body.IsTracked && body.HandLeftConfidence == TrackingConfidence.High && body.HandLeftState == HandState.Lasso && body.HandRightConfidence == TrackingConfidence.High && body.HandRightState == HandState.Lasso) { osd.displayMessage("Body " + index + " is now in control"); activeBody = index; // activeBodies.Add(index); } } for (var index = 0; index < bodies.Length; index++) { var body = bodies[index]; if (!body.IsTracked && activeBody == index) { activeBody = -1; osd.displayMessage("Controls are now released!"); continue; } if (!body.IsTracked || activeBody != index) { continue; } var halfASpine = body.Joints[JointType.SpineMid].Position.Y - body.Joints[JointType.SpineBase].Position.Y; var leftHandBelowSpineBase = body.Joints[JointType.HandLeft].Position.Y < body.Joints[JointType.SpineBase].Position.Y + (halfASpine / 8); var rightHandBelowSpineBase = body.Joints[JointType.HandRight].Position.Y < body.Joints[JointType.SpineBase].Position.Y + (halfASpine / 8); var anyHandBelowSpineBase = leftHandBelowSpineBase || rightHandBelowSpineBase; var bothHandBelowSpineBase = leftHandBelowSpineBase && rightHandBelowSpineBase; var leftHandAboveNeck = body.Joints[JointType.HandLeft].Position.Y > body.Joints[JointType.Neck].Position.Y; var rightHandAboveNeck = body.Joints[JointType.HandRight].Position.Y > body.Joints[JointType.Neck].Position.Y; var anyHandAboveNeck = leftHandAboveNeck || rightHandAboveNeck; var bothHandAboveNeck = leftHandAboveNeck && rightHandAboveNeck; var leftHandAboveHead = body.Joints[JointType.HandLeft].Position.Y > body.Joints[JointType.Head].Position.Y; var rightHandAboveHead = body.Joints[JointType.HandRight].Position.Y > body.Joints[JointType.Head].Position.Y; var anyHandAboveHead = leftHandAboveHead || rightHandAboveHead; var bothHandAboveHead = leftHandAboveHead && rightHandAboveHead; var shoulderWidth = body.Joints[JointType.ShoulderRight].Position.X - body.Joints[JointType.ShoulderLeft].Position.X; var leftHandIndicatingMovingRight = body.Joints[JointType.HandLeft].Position.X > body.Joints[JointType.SpineMid].Position.X; var leftHandIndicatingMovingLeft = body.Joints[JointType.HandLeft].Position.X < body.Joints[JointType.ShoulderLeft].Position.X - shoulderWidth; var rightHandIndicatingMovingLeft = body.Joints[JointType.HandRight].Position.X < body.Joints[JointType.SpineMid].Position.X; var rightHandIndicatingMovingRight = body.Joints[JointType.HandRight].Position.X > body.Joints[JointType.ShoulderRight].Position.X + shoulderWidth; var leftHandClosed = body.HandLeftState == HandState.Closed && body.Joints[JointType.HandLeft].TrackingState == TrackingState.Tracked; var rightHandClosed = body.HandRightState == HandState.Closed && body.Joints[JointType.HandRight].TrackingState == TrackingState.Tracked; var kneeTrigger = body.Joints[JointType.SpineBase].Position.Y - halfASpine / 3 * 2; var leftFeetAboveSpineBase = body.Joints[JointType.KneeLeft].Position.Y > kneeTrigger; var rightFeetAboveSpineBase = body.Joints[JointType.KneeRight].Position.Y > kneeTrigger; var leftHandInFront = body.Joints[JointType.HandLeft].Position.Z < body.Joints[JointType.ShoulderLeft].Position.Z - 0.30; var rightHandInFront = body.Joints[JointType.HandRight].Position.Z < body.Joints[JointType.ShoulderRight].Position.Z - 0.30; var rightHandFarInFront = body.Joints[JointType.HandRight].Position.Z < body.Joints[JointType.ShoulderRight].Position.Z - 0.50; var rightHandStraightFront = body.Joints[JointType.ShoulderRight].Position.X + shoulderWidth / 2 > body.Joints[JointType.HandRight].Position.X && body.Joints[JointType.ShoulderRight].Position.X - shoulderWidth / 2 < body.Joints[JointType.HandRight].Position.X && !rightHandAboveNeck && !rightHandBelowSpineBase; var rightThumpPointingUp = body.Joints[JointType.HandRight].Position.Y < body.Joints[JointType.ThumbRight].Position.Y - 0.05; var rightThumpPointingDown = body.Joints[JointType.HandRight].Position.Y > body.Joints[JointType.ThumbRight].Position.Y + 0.05; var rightThumpPointingLeft = body.Joints[JointType.HandRight].Position.X > body.Joints[JointType.ThumbRight].Position.X + 0.03 && !rightThumpPointingUp && !rightThumpPointingDown; // Moving left or right if (!leftHandIndicatingMovingLeft || !rightHandIndicatingMovingRight) { if (leftHandIndicatingMovingLeft && rightHandIndicatingMovingLeft) { // Running left _buttons.pressLeft(); _buttons.pressB(); } else if (leftHandIndicatingMovingRight && rightHandIndicatingMovingRight) { // Running right _buttons.pressRight(); _buttons.pressB(); } else if (leftHandIndicatingMovingLeft) { // Walking left _buttons.pressLeft(); } else if (rightHandIndicatingMovingRight) { // Walking right _buttons.pressRight(); } } // Jumping or pointing upwards if (bothHandAboveHead) { _stopwatch.Start(); if (_stopwatch.ElapsedMilliseconds > 1500) { _buttons.pressUp(); } } else { _stopwatch.Reset(); } if (anyHandAboveNeck && !_buttons.pressingUp()) { _buttons.pressA(); } if (anyHandBelowSpineBase && !_buttons.pressingUp()) { _buttons.pressDown(); } // Shooting if (_shootingMode != ShootingMode.DISABLED && (leftHandClosed || rightHandClosed) && (_shootingMode == ShootingMode.LOW_ACCURACY || leftHandClosed && body.HandLeftConfidence == TrackingConfidence.High || rightHandClosed && body.HandRightConfidence == TrackingConfidence.High) ) { _buttons.pressX(); } if (leftFeetAboveSpineBase) { _buttons.pressStart(); } if (rightFeetAboveSpineBase) { _buttons.pressY(); } thumbUp.setActive(rightHandFarInFront && rightHandStraightFront && !leftHandInFront && rightThumpPointingUp && !rightThumpPointingLeft && !rightThumpPointingDown); if (thumbUp.isTrigged()) { osd.displayMessage("Shooting is now in LOW accuracy mode"); _shootingMode = ShootingMode.LOW_ACCURACY; } else if (thumbUp.isDelayOnActive()) { osd.displayMessage("Keep pointing up to enable LOW accuracy shooting", 1000); } thumbLeft.setActive(rightHandFarInFront && rightHandStraightFront && !leftHandInFront && rightThumpPointingLeft); if (thumbLeft.isTrigged()) { osd.displayMessage("Shooting is now in HIGH accuracy mode"); _shootingMode = ShootingMode.HIGH_ACCURACY; } else if (thumbLeft.isDelayOnActive()) { osd.displayMessage("Keep pointing left to enable HIGH accuracy shooting", 1000); } thumbDown.setActive(rightHandFarInFront && rightHandStraightFront && !leftHandInFront && rightThumpPointingDown && !rightThumpPointingLeft && !rightThumpPointingUp); if (thumbDown.isTrigged()) { osd.displayMessage("Shooting now disabled"); _shootingMode = ShootingMode.DISABLED; } else if (thumbDown.isDelayOnActive()) { osd.displayMessage("Keep pointing down to DISABLE shooting", 1000); } } RefreshButtons(); osd.update(zoneSource); }
public ShootingModule(float delay, ShootingMode shootingMode) { shootingDelay = delay; this.shootingMode = shootingMode; }
// Update is called once per frame void Update() { // player dying if (m_animator.GetBool("Death")) { // if (m_deathCount > 0) // { // m_deathCount -= Time.deltaTime; // MessageDispacher.Instance.Send( // UIMessage.UpdateRebornProgress, 1.0f - m_deathCount / PlayerConfigure.RebornWaitingTime); // if (m_deathCount <= 0) // { // m_deathCount = 0; // m_networkService.Send(new PlayerRebornCommand(PlayerInfo.LocalPlayer.UserID)); // } // } return; } if (Cursor.lockState != CursorLockMode.Locked) { return; } // move m_keyBoardDirection = KeyBoardMoveDescriptor.None; float dx = Input.GetAxis("Mouse X"); var rate = PlayerConfigure.CameraMouseMoveRateX; m_phi += dx * rate; if (Mathf.Abs(dx) > 1e-5f) { m_isRotate = true; } var rotate = Quaternion.AngleAxis(360.0f * m_phi, Vector3.up); this.transform.rotation = rotate; if (Input.GetKey(KeyCode.W)) { m_keyBoardDirection |= KeyBoardMoveDescriptor.Up; m_animator.SetFloat("Direction", 1.0f, 0.0f, Time.deltaTime); } else if (Input.GetKey(KeyCode.S)) { m_keyBoardDirection |= KeyBoardMoveDescriptor.Down; m_animator.SetFloat("Direction", -1.0f, 0.0f, Time.deltaTime); } else { m_animator.SetFloat("Direction", 0.0f); } if (Input.GetKey(KeyCode.A)) { m_keyBoardDirection |= KeyBoardMoveDescriptor.Left; m_animator.SetFloat("LeftOrRight", -1.0f, 0.2f, Time.deltaTime); } else if (Input.GetKey(KeyCode.D)) { m_keyBoardDirection |= KeyBoardMoveDescriptor.Right; m_animator.SetFloat("LeftOrRight", 1.0f, 0.2f, Time.deltaTime); } else { m_animator.SetFloat("LeftOrRight", 0.0f, 0.2f, Time.deltaTime); } Move(); if (m_keyBoardDirection != KeyBoardMoveDescriptor.None || Input.GetKey(KeyCode.Space)) { m_networkService.Send( new MoveCommand( PlayerInfo.LocalPlayer.UserID, transform.position, m_phi, (byte)m_keyBoardDirection, Input.GetKey(KeyCode.Space) ) ); } else { if (m_isRotate) { m_networkService.Send(new PlayerRotateCommand(PlayerInfo.LocalPlayer.UserID, m_phi)); } } if (Input.GetKeyDown(KeyCode.Alpha1)) { m_currentPlayerMode = PlayerMode.Normal; m_handTrap.SetActive(false); } else if (Input.GetKeyDown(KeyCode.Alpha2)) { m_currentPlayerMode = PlayerMode.SetTrap; m_handTrap.SetActive(true); m_handTrap.GetComponent <TrapController>().Reset(); } if (m_currentPlayerMode == PlayerMode.Normal) { // switch shooting mode if (Input.GetKeyDown(KeyCode.T)) { if (m_shootingMode == ShootingMode.Fixed) { m_shootingMode = ShootingMode.Running; } else if (m_shootingMode == ShootingMode.Running) { m_shootingMode = ShootingMode.Fixed; } } // recharge if (Input.GetKeyDown(KeyCode.R)) { Recharge(); } // shoot Shoot(); } // set trap else { SetTrap(); } BuyThings(); DriveTank(); m_isRotate = false; }
//Returns the shooting mode to normal after the specefied amount of time public IEnumerator ShootModeTimer(float time) { yield return(new WaitForSeconds(time)); shootMode = ShootingMode.NORMAL; }
void ChangeToSniper() { burstRate = sniperFireRate; cooldownTime = sniperCooldownRate; GA_Script.SwitchToSniper(); currentShootingMode = ShootingMode.Sniper; }
void ChangeToSMG() { burstRate = smgFireRate; cooldownTime = smgCooldownRate; GA_Script.SwitchToSMG(); currentShootingMode = ShootingMode.SMG; }
// Use this for initialization void Start() { //Debug.Log("Whatup"); player = GameObject.FindGameObjectWithTag("Player"); if(fireMode == FireMode.Simple){ myShootingMode = SimpleFire; } if(fireMode == FireMode.Burst){ myShootingMode = Burst; } if(fireMode == FireMode.Spread){ myShootingMode =SpreadShot; } if(fireMode == FireMode.BurstAndSpread){ myShootingMode +=SpreadShot; myShootingMode +=Burst; } if (fireMode == FireMode.BurstSpreadSine){ myShootingMode +=SpreadShot; myShootingMode +=Burst; myShootingMode += SineWave; } if (fireMode == FireMode.BurstNoCannon){ myShootingMode = burstNoCannon; } if (fireMode == FireMode.SineWave){ myShootingMode = SineWave; } }
public void ShootsInBatchesSetup(int batchSize, double batchDelay) { shootingMode = ShootingMode.Batches; this.batchSize = batchSize; this.batchDelay = batchDelay; }
protected void ShootsOnce(int delay) { shootingDelay = delay; shootingMode = ShootingMode.Single; }
void Awake() { mainCharacter = GameObject.FindWithTag("Player").GetComponent <ShootingMode> (); imageComponent = GetComponent <Image>(); }
public void AddSecondaryModule(float delay, ShootingMode shootingMode) { secondaryModule = new ShootingModule(delay, shootingMode); shootingModules.Add(secondaryModule); }
public void AddPrimaryModule(float delay, ShootingMode shootingMode) { primaryModule = new ShootingModule(delay, shootingMode); shootingModules.Add(primaryModule); }