// Update is called once per frame void Update() { // NOTE: This way of automating movement works, // but think about how to do it with a Rigidbody and FixedUpdate() // for more realistic movement and quaternion rotation playerTransform = GameObject.FindGameObjectWithTag("Player").transform; playerPosition = playerTransform.position.x; if (moving == IsMoving.Left && playerTransform.position.x <= enemyPosition) // enemy and player x positions are the same, so just fire { Debug.Log("enemy is at the same x position as player"); // Instantiate shot here moving = IsMoving.None; } else if (moving == IsMoving.Right && playerTransform.position.x >= enemyPosition) { Debug.Log("enemy was on the right but is at same x pos as player now"); // Instantiate shot here moving = IsMoving.None; } if (moving == IsMoving.Left) { playerTransform.Translate(Vector3.left * Time.deltaTime); //StartCoroutine(SmoothMove(left, 1f)); // .0001f is the speed } if (moving == IsMoving.Right) { playerTransform.Translate(Vector3.right * Time.deltaTime); //StartCoroutine(SmoothMove(right, 1f)); // .0001f is the speed } }
public void WaveTwoAction() { playerTransform = GameObject.FindGameObjectWithTag("Player").transform; testVector = new Vector3(13, 0, 0); Debug.Log("WaveTwoAction invoked..."); Debug.Log("Player location is: " + playerTransform.position); for (int i = 0; i < 4; i++) { if (i == 0) { enemyPosition = 3; } else { enemyPosition = i * 3; } //enemyPosition = i + 3;// enemyXPositions[i]; //enemyTransform.position = enemyPositions[i]; Debug.Log("Enemy's position: " + enemyPosition); //while (playerTransform.position.x < enemyPosition) if (playerTransform.position.x < enemyPosition) {//Using update to capture the keypress. Debug.Log("player is farther right than enemy"); //playerTransform.Translate(Vector3.right);// * Time.deltaTime); moving = IsMoving.Right; // tells Update() to call SmoothMove() Coroutine with a right direction //levelOnePlayerController.MoveRight(playerTransform, 3f); } //while (playerTransform.position.x > enemyPosition) if (playerTransform.position.x > enemyPosition) { Debug.Log("player is farther right than enemy"); //playerTransform.Translate(Vector3.left);// * Time.deltaTime); moving = IsMoving.Left; // tells Update() to call SmoothMove() Coroutine with a left direction //levelOnePlayerController.MoveLeft(playerTransform, 3f); } Wait(); } }
// Update is called once per frame void FixedUpdate() { playerTransform = GameObject.FindGameObjectWithTag("Player").transform; // NOTE: This way of automating movement works (but with bugs), // think about how to do it with a Rigidbody and FixedUpdate() // for more realistic movement and quaternion rotation if (wave == Waves.One) { if (moving == IsMoving.Left && playerTransform.position.x <= waveOneEnemyLocations[enemyCount]) // enemy and player x positions are the same, so just fire { moving = IsMoving.None; StopAndShoot(); enemyCount++; if (enemyCount < waveOneEnemyLocations.Length) { EnactWaveOne(enemyCount); } else /* all enemies are destroyed */ } { } else if (moving == IsMoving.Right && playerTransform.position.x >= waveOneEnemyLocations[enemyCount]) { moving = IsMoving.None; StopAndShoot(); enemyCount++; if (enemyCount < waveOneEnemyLocations.Length) { EnactWaveOne(enemyCount); } else /* all enemies are destroyed */ } { } if (moving == IsMoving.Left) { playerTransform.Translate(Vector3.left * thrust * Time.deltaTime); } if (moving == IsMoving.Right) { playerTransform.Translate(Vector3.right * thrust * Time.deltaTime); } }
private void EnactWaveOne(float enemyLocation) { playerTransform = GameObject.FindGameObjectWithTag("Player").transform; Debug.Log("****WaveTwoAction invoked..."); Debug.Log("Player location is: " + playerTransform.position); Debug.Log("Enemy's position: " + enemyLocations[enemyCount]); if (playerTransform.position.x < enemyLocation) { Debug.Log("player is farther right than enemy"); moving = IsMoving.Right; // tells Update() to move player right } else if (playerTransform.position.x > enemyLocation) { Debug.Log("player is farther right than enemy"); moving = IsMoving.Left; // tells Update() to move player left } }
//**** each wave and the wave's enemy information ****// void Update() { if (moving == IsMoving.Left && playerTransform.position.x <= enemyLocations[enemyCount]) // enemy and player x positions are the same, so just fire { moving = IsMoving.None; StopAndShoot(); enemyCount++; if (enemyCount < enemyLocations.Length) { EnactWaveOne(enemyCount); } else { /* all enemies are destroyed */ } } else if (moving == IsMoving.Right && playerTransform.position.x >= enemyLocations[enemyCount]) { moving = IsMoving.None; StopAndShoot(); enemyCount++; if (enemyCount < enemyLocations.Length) { EnactWaveOne(enemyCount); } else { /* all enemies are destroyed */ } } }
public override int GetHashCode() { int hash = 1; if (PositionX != 0D) { hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(PositionX); } if (PositionY != 0D) { hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(PositionY); } if (Direction != 0) { hash ^= Direction.GetHashCode(); } if (ObjType != 0) { hash ^= ObjType.GetHashCode(); } if (BlockType != 0) { hash ^= BlockType.GetHashCode(); } if (DishType != 0) { hash ^= DishType.GetHashCode(); } if (ToolType != 0) { hash ^= ToolType.GetHashCode(); } if (TriggerType != 0) { hash ^= TriggerType.GetHashCode(); } if (IsMoving != false) { hash ^= IsMoving.GetHashCode(); } if (RecieveText.Length != 0) { hash ^= RecieveText.GetHashCode(); } if (Team != 0) { hash ^= Team.GetHashCode(); } if (SightRange != 0) { hash ^= SightRange.GetHashCode(); } if (MoveSpeed != 0D) { hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(MoveSpeed); } if (MaxThrowDistance != 0) { hash ^= MaxThrowDistance.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (PositionX != 0D) { hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(PositionX); } if (PositionY != 0D) { hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(PositionY); } if (Width != 0) { hash ^= Width.GetHashCode(); } if (Height != 0) { hash ^= Height.GetHashCode(); } if (Direction != 0) { hash ^= Direction.GetHashCode(); } if (ObjType != 0) { hash ^= ObjType.GetHashCode(); } if (BlockType != 0) { hash ^= BlockType.GetHashCode(); } if (DishType != 0) { hash ^= DishType.GetHashCode(); } if (ToolType != 0) { hash ^= ToolType.GetHashCode(); } if (TriggerType != 0) { hash ^= TriggerType.GetHashCode(); } if (IsMoving != false) { hash ^= IsMoving.GetHashCode(); } hash ^= buff_.GetHashCode(); if (SpeakText.Length != 0) { hash ^= SpeakText.GetHashCode(); } if (Team != 0) { hash ^= Team.GetHashCode(); } if (SightRange != 0) { hash ^= SightRange.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }