private static PortTownIndividualPacket createNewPortTownAtLocation(SimplifiedLayoutReturnPacket simplifiedLayout, UpscaledLayoutReturnPacket upscaledLayout, byte roomX, byte roomY, float roomWidthHeight, int numOfVertsPerEdge, System.Random random_forThread) { PortTownIndividualPacket portTownIndividual = new PortTownIndividualPacket(); portTownIndividual.setPortTownPierCoords_simple(roomX, roomY); Vector2 waterPosition = new Vector2((roomX + 0.5f) * roomWidthHeight, (roomY + 0.5f) * -roomWidthHeight); Vector2 landPosition = findPortTownPierLandPoint(simplifiedLayout.getSimplifiedRoomArray()[roomX, roomY], waterPosition, roomWidthHeight, random_forThread); portTownIndividual.setPortTownYRotation(Vector2.SignedAngle(waterPosition - landPosition, Vector2.up)); Vector2 stepAmount = (landPosition - waterPosition).normalized * Constants.shipMoveSpeed; do { waterPosition += stepAmount; } while (BoolArrayManager.checkForConflict_V2_noDoors(upscaledLayout.getBoolArray(), waterPosition)); stepAmount = stepAmount / Constants.shipMoveSpeed * Constants.portTownDistanceFromLand; waterPosition -= stepAmount; portTownIndividual.setPortTownPierCoords_upscaled(waterPosition.x, waterPosition.y); addHousesAroundPier(portTownIndividual, upscaledLayout.getLandVertexHeights(), random_forThread); return(portTownIndividual); }
private void checkVulnerability() { if (!isVulnerable) { if (isBeingKnockedBack) { knockbackDirection_current *= Constants.knockback_dragMultiplier_player; if (BoolArrayManager.checkForConflict_V3(boolArray, doorHitboxManager, playerBoatTransform_target.position + knockbackDirection_current)) { playerBoatTransform_target.position += knockbackDirection_current; playerBoatTransform_delayed.position += knockbackDirection_current; } if (knockbackDuration_current > 0) { knockbackDuration_current--; if (knockbackDuration_current == 0) { isBeingKnockedBack = false; } } } if (--invulnerabilityDuration_current <= 5) { isVulnerable = true; // playerBoat_actual.GetComponent<Renderer>().material.SetColor("_Color", new Color32(255, 255, 255, 255)); playerBoat_actual_renderer_main.material.SetColor("_Color", new Color32(255, 255, 255, 255)); playerBoat_actual_renderer_sail.material.SetColor("_Color", new Color32(255, 255, 255, 255)); } } }
public static void moveGameObject_andChangeForward(Transform objectTransform, Vector3 moveVec, bool[,] boolArray, DoorHitboxManager doorHitboxManager) { if (moveVec.magnitude > 0.05f) { objectTransform.forward = moveVec.normalized; objectTransform.position += BoolArrayManager.adjustMovementBasedOnWalls(boolArray, objectTransform.position, moveVec, doorHitboxManager); } }
public void slideRaftBackwards(GameObject raftEnemy, Vector3 slideAmount) { if (BoolArrayManager.checkForConflict_V3(boolArray, doorHitboxManager, raftEnemy.transform.position + slideAmount)) { raftEnemy.transform.position += slideAmount; } // raftEnemy.transform.position += BoolArrayManager.adjustMovementBasedOnWalls(boolArray, raftEnemy.transform.position, slideAmount, doorHitboxManager); }
private void checkEnemyKnockback(int index) { if (enemyArray_class[index].getIsBeingKnockedBack()) { enemyArray_class[index].updateKnockbackVector(cannonData.getKnockback_dragMultiplier()); if (BoolArrayManager.checkForConflict_V3(boolArray, doorHitboxManager, enemyArray_object[index].transform.position + enemyArray_class[index].getKnockbackVector())) { enemyArray_object[index].transform.position += enemyArray_class[index].getKnockbackVector(); } } }
private bool checkIfPositionIsInWater(Vector3 position, bool[,] boolArray, DoorHitboxManager doorHitboxManager) { return(BoolArrayManager.checkForConflict_V3(boolArray, doorHitboxManager, position)); }
public static void moveGameObject_sameForward(Transform objectTransform, Vector3 moveVec, bool[,] boolArray, DoorHitboxManager doorHitboxManager) { objectTransform.position += BoolArrayManager.adjustMovementBasedOnWalls(boolArray, objectTransform.position, moveVec, doorHitboxManager); }
private void checkForDeactivateCannonball(CannonballIndividual cannonballClass, bool isEnemyCannonball) { // if cannonball is currently inactive, return if (!cannonballClass.getIsMoving()) { return; } // if cannonball's lifetime is 0, or if it hits a wall/door (enemy collision will happen someplace else) // call a 'makeInactive' funcion on the cannonball, and place two new wakes there. // if (cannonballClass.checkForTimeout() || !BoolArrayManager.checkForConflict_V3(boolArray, doorHitboxManager, cannonballClass.getCannonballPosition())) // if (cannonballClass.checkForTimeout() || !BoolArrayManager.checkForConflict_V3_noDoors(boolArray, cannonballClass.getCannonballPosition())) // if (cannonballClass.checkForTimeout() || // ((isEnemyCannonball || !cannonData.getPassesThroughWalls()) && !BoolArrayManager.checkForConflict_V3_noDoors(boolArray, cannonballClass.getCannonballPosition()))) // { // deactivateCannonball(cannonballClass); // } // Check to see if the cannonball has timed out: if (cannonballClass.checkForTimeout()) { deactivateCannonball(cannonballClass); return; } // Then check to see if it has hit a target: if (isEnemyCannonball) { // The enemy's cannonballs: if (gameView.checkIfCannonballHasHitPlayer(cannonballClass.getCannonballPosition(), cannonballClass.getCannonballDirection())) { deactivateCannonball(cannonballClass); cannonBonkManager.placeNewBonk(cannonballClass.getCannonballPosition(), 1f, false); return; } if (!BoolArrayManager.checkForConflict_V3_noDoors(boolArray, cannonballClass.getCannonballPosition())) { deactivateCannonball(cannonballClass); return; } } else { // The player's cannonballs: if (enemyManager.checkIfCannonballHasHitEnemy(cannonballClass.getCannonballPosition(), cannonballClass.getCannonballDirection())) { deactivateCannonball(cannonballClass); // cannonBonkManager.placeNewBonk(cannonballClass.getCannonballPosition() + cannonballClass.getCannonballDirection() * 2f, cannonData.getBonkSize(), true); if (cannonData.getExplodes()) { makeCannonballExplode(cannonballClass.getCannonballPosition()); } else { cannonBonkManager.placeNewBonk(cannonballClass.getCannonballPosition() + cannonballClass.getCannonballDirection() * 2f, cannonData.getBonkSize(), true); } return; } if (!cannonData.getPassesThroughWalls() && !BoolArrayManager.checkForConflict_V3_noDoors(boolArray, cannonballClass.getCannonballPosition())) { deactivateCannonball(cannonballClass); if (cannonData.getExplodes()) { makeCannonballExplode(cannonballClass.getCannonballPosition()); } return; } } }