public void TryMove(ITilePlaceable obj, int dirX, int dirY) { Tile dest = GetTile(obj.GetX() + dirX, obj.GetY() + dirY); if(dest != null) { dest.TryIncomingMove (obj, dirX, dirY); } }
public bool CanMove(ITilePlaceable obj, int dirX, int dirY) { Tile dest = GetTile(obj.GetX() + dirX, obj.GetY() + dirY); if (dest != null && dest.AllowIncomingMove(obj, dirX, dirY)) { return true; } return false; }
public bool TryDeselectObject() { if (placedObject == null) { return(false); } ITilePlaceable tilePlaceable = placedObject.GetComponent <ITilePlaceable>(); if (tilePlaceable == null) { return(false); } tilePlaceable.Deselect(); return(true); }
public void Attach(ITilePlaceable follower) { mFollowers.Add(follower); }
public void TryIncomingMove(ITilePlaceable incomingPlaceable, int dirX, int dirY) { if(!mProperties.canBeWalkedOver) { TryMove(dirX, dirY); if (mProperties.sticksInUpdateFor > 0) { mOwningTile.mParentNavGrid.AddToUpdateList(this, dirX, dirY, mProperties.sticksInUpdateFor); } } if(mProperties.attachable && !mProperties.isAttached) { incomingPlaceable.Attach(this); mProperties.isAttached = true; } }
public void TryIncomingMove(ITilePlaceable incomingPlaceable, int dirX, int dirY) { // Should never occur }
public bool AllowIncomingMove(ITilePlaceable incomingPlaceable, int dirX, int dirY) { return false; }
public bool AllowIncomingMove(ITilePlaceable interferingObj, int dirX, int dirY) { if (!mPlayerPassable && interferingObj.GetProperties().isPlayer) { return false; } if(!mBlockPassable && !interferingObj.GetProperties().isPlayer) { return false; } foreach (ITilePlaceable obj in mPlaceables) { if (!obj.AllowIncomingMove(interferingObj, dirX, dirY)) { return false; } } return true; }
public void RemoveFromUpdateList(ITilePlaceable placeable) { if (placeable.GetProperties().inUpdateSequenceFor > 0) { ArrayList removeUpdates = new ArrayList(); foreach (PlaceableUpdate rUpdate in mPlaceableUpdates) { if (rUpdate.placeable == placeable) { removeUpdates.Add(rUpdate); } } foreach (PlaceableUpdate rUpdate in removeUpdates) { mPlaceableUpdates.Remove(rUpdate); } } }
public void LockToPosition(ITilePlaceable placeable) { placeable.SetX(mX); placeable.SetY(mY); if(mTileObject != null) { placeable.SetVisualPosition(mTileObject.transform.position); } }
public void Unsubscribe(ITilePlaceable placeable) { mPlaceables.Remove(placeable); if (mType == TerrainType.kPressure && mPlaceables.Count == 0) { DelegateHost.PressureChange(false, mSpecialCaseID); } }
public void Subscribe(ITilePlaceable placeable) { mPlaceables.Add(placeable); if(mType == TerrainType.kPressure && mPlaceables.Count == 1) { DelegateHost.PressureChange(true, mSpecialCaseID); } }
public void TriggerSpecialMoveConditions(ITilePlaceable interferingObj) { if (mType == TerrainType.kBlockHole && !interferingObj.GetProperties().isPlayer) { mParentNavGrid.RemoveFromUpdateList(interferingObj); interferingObj.PrepForRemoval(); mParentNavGrid.Delete(interferingObj.GetConnectedObject()); interferingObj.Clear(); } else { interferingObj.SetAsOwningTile(this); LockToPosition(interferingObj); if (mPushDirX != 0 || mPushDirY != 0) { int forcedPushAmount = Math.Max(interferingObj.GetProperties().sticksInUpdateFor, 1); mParentNavGrid.AddToUpdateList(interferingObj, mPushDirX, mPushDirY, forcedPushAmount); } } }
public void TryIncomingMove(ITilePlaceable interferingObj, int dirX, int dirY) { ArrayList moveList = new ArrayList(); foreach (ITilePlaceable obj in mPlaceables) { if(obj.GetProperties().canBeWalkedOver) { obj.TryIncomingMove(interferingObj, dirX, dirY); } else { moveList.Add(obj); } } if(moveList.Count > 0) { foreach (ITilePlaceable obj in moveList) { obj.TryIncomingMove(interferingObj, dirX, dirY); } if(interferingObj.GetProperties().isPlayer) { return; } } TriggerSpecialMoveConditions(interferingObj); interferingObj.PostMove(); }
public void Detach(ITilePlaceable follower) { mFollowers.Remove(follower); }
public bool AllowIncomingMove(ITilePlaceable incomingPlaceable, int dirX, int dirY) { if (mProperties.canBeWalkedOver) { return true; } if (!incomingPlaceable.GetProperties().canPushBlocks) { return false; } ITile siblingTile = mOwningTile.GetSiblingTile(dirX, dirY); if(siblingTile == null) { return false; } return siblingTile.AllowIncomingMove(this, dirX, dirY); }
public void AddToUpdateList(ITilePlaceable placeable, int dirX, int dirY, int duration) { // Don't duplicate RemoveFromUpdateList(placeable); PlaceableUpdate update = new PlaceableUpdate(); update.placeable = placeable; update.dirX = dirX; update.dirY = dirY; update.delayUntilNextMove = kDelays; update.placeable.GetProperties().inUpdateSequenceFor = duration; mPlaceableUpdates.Add(update); }