private void pushNextIfNotThis(Floor floor, MoveType moveType, Vector2Int truePos, Vector2Int displacement) { Vector2Int targetPos = truePos + displacement; ForegroundObject foregroundObj = floor.getForegroundObj(targetPos); if (foregroundObj != null && foregroundObj != this) { foregroundObj.OnInteraction(moveType, displacement); } }
// Make private public void updateForegroundObj(Vector2Int truePos, ForegroundObject newObj) { Vector2Int gridVect = truePosToGridVect(truePos); if (gridVect.x < 0 || gridVect.x >= gridWidth || gridVect.y < 0 || gridVect.y >= gridHeight) { return; } //Debug.Log("Updating position: " + truePos + " to object: " + newObj); foregroundGrid[gridVect.x, gridVect.y] = newObj; }
protected override void LoadComponentsInUIContext() { ForegroundObject.AssertIsForeground(); // Ensure the nuget package services are initialized after we've loaded // the solution. _packageInstallerService = Workspace.Services.GetService <IPackageInstallerService>() as PackageInstallerService; _symbolSearchService = Workspace.Services.GetService <ISymbolSearchService>() as SymbolSearchService; _packageInstallerService?.Connect(this.RoslynLanguageName); _symbolSearchService?.Connect(this.RoslynLanguageName); }
// Predicate to check if the player can move usign the normal movetype in a certain direction public bool canMoveNormal(Vector2Int displacement, Vector2Int targetPos) { if (Employee.willEmployeeMoveInto(targetPos) || Employee.willEmployeeSwapWith(truePos, targetPos)) { return(false); } Tile tile = LevelManager.getTile(targetPos); ForegroundObject foregroundObj = LevelManager.getForegroundObject(targetPos); return((tile != null && tile.isSteppable()) && (foregroundObj == null || foregroundObj.IsSteppable(MoveType.normal, displacement))); }
protected override void LoadComponentsInUIContext() { ForegroundObject.AssertIsForeground(); // Ensure the nuget package services are initialized after we've loaded // the solution. _packageInstallerService = Workspace.Services.GetService <IPackageInstallerService>() as PackageInstallerService; _symbolSearchService = Workspace.Services.GetService <ISymbolSearchService>() as VisualStudioSymbolSearchService; _packageInstallerService?.Connect(this.RoslynLanguageName); _symbolSearchService?.Connect(this.RoslynLanguageName); HACK_AbstractCreateServicesOnUiThread.CreateServicesOnUIThread(ComponentModel, RoslynLanguageName); }
public bool canMoveNormal(Vector2Int displacement, Vector2Int targetPos) { Tile tile = LevelManager.getTile(targetPos); ForegroundObject foregroundObj = LevelManager.getForegroundObject(targetPos); if (foregroundObj) { return(false); } Vector2Int playerTruePos = GM.Instance.currentLevelManager.player.truePos; return(tile != null && (tile.isSteppableForNPC() || tile is Hole) && playerTruePos != targetPos); }
// Update the foregroundGrid for this objects position, and all its additionalCoords public void updateFgGridForAllPos(ForegroundObject obj, Vector2Int truePos, List <Vector2Int> additionalCoords, bool initializing) { updateForegroundObj(truePos, obj); foreach (Vector2Int relativePos in additionalCoords) { Vector2Int pos = truePos + relativePos; if (initializing && getForegroundObj(pos) != null) { Debug.LogError("Two foregroundObject objects were found at (" + pos.x + ", " + pos.y + "). Please delete one."); } else { updateForegroundObj(pos, obj); } } }
// Moves the player using the given moveType, with the given displacement to the target position public void move(MoveType moveType, Vector2Int displacement, Vector2Int targetPosition) { StartSuccessfulStep.Invoke(); Tile prevTile = LevelManager.getTile(truePos); prevTile.OnLeave(); Tile nextTile = LevelManager.getTile(targetPosition); nextTile.OnStep(); ForegroundObject foregroundObject = LevelManager.getForegroundObject(targetPosition); if (foregroundObject != null) { foregroundObject.OnInteraction(moveType, displacement); } switch (moveType) { case (MoveType.normal): if (foregroundObject is Pushable) { playerMoveAnim("Pushing", displacement); } else { playerMoveAnim("Walking", displacement); } placeByDisplacement(displacement); MusicManager.play_by_name("footstep"); break; case (MoveType.jumpTwoTiles): playerMoveAnim("Jumping", displacement); MusicManager.play_by_name("coffee_jump"); placeByDisplacement(displacement); break; } CompleteSuccessfulStep.Invoke(); }
// Predicate to check if the player can move using the jumpTwoTiles movetype in a certain direction public bool canMoveJumpTwoTiles(Vector2Int displacement, Vector2Int jumpOverPos, Vector2Int targetPos) { Tile tileToJump = LevelManager.getTile(jumpOverPos); ForegroundObject foregroundObjToJump = LevelManager.getForegroundObject(jumpOverPos); if ((tileToJump != null && !tileToJump.CanBeJumpedOver()) || (foregroundObjToJump != null && !foregroundObjToJump.CanBeJumpedOver())) { return(false); } if (Employee.willEmployeeMoveInto(targetPos)) { return(false); } Tile tile = LevelManager.getTile(targetPos); ForegroundObject foregroundObj = LevelManager.getForegroundObject(targetPos); return((tile != null && tile.isSteppable()) && (foregroundObj == null || foregroundObj.IsSteppable(MoveType.jumpTwoTiles, displacement))); }
// Private predicate to check if a particular position in this pushable can be // pushed to the respective position given incoming displacement private bool posCanBePushedInto(Vector2Int truePos, Vector2Int incomingDisplacement) { Vector2Int targetPos = truePos + incomingDisplacement; Floor floor = LevelManager.getFloor(); Tile tile = floor.getTile(targetPos); if (tile == null || !tile.CanBePushedOnto()) { return(false); } ForegroundObject foregroundObj = floor.getForegroundObj(targetPos); if (foregroundObj != null && (foregroundObj != this && !foregroundObj.CanBePushedInto(incomingDisplacement))) { return(false); } return(true); }
protected override void LoadComponentsInUIContext() { ForegroundObject.AssertIsForeground(); }