예제 #1
0
    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);
        }
    }
예제 #2
0
    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;
    }
예제 #3
0
    public bool TryDeselectObject()
    {
        if (placedObject == null)
        {
            return(false);
        }
        ITilePlaceable tilePlaceable = placedObject.GetComponent <ITilePlaceable>();

        if (tilePlaceable == null)
        {
            return(false);
        }
        tilePlaceable.Deselect();
        return(true);
    }
예제 #4
0
 public void Attach(ITilePlaceable follower)
 {
     mFollowers.Add(follower);
 }
예제 #5
0
    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;
        }
    }
예제 #6
0
 public void TryIncomingMove(ITilePlaceable incomingPlaceable, int dirX, int dirY)
 {
     // Should never occur
 }
예제 #7
0
 public bool AllowIncomingMove(ITilePlaceable incomingPlaceable, int dirX, int dirY)
 {
     return false;
 }
예제 #8
0
    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;
    }
예제 #9
0
 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);
         }
     }
 }
예제 #10
0
 public void LockToPosition(ITilePlaceable placeable)
 {
     placeable.SetX(mX);
     placeable.SetY(mY);
     if(mTileObject != null)
     {
         placeable.SetVisualPosition(mTileObject.transform.position);
     }
 }
예제 #11
0
 public void Unsubscribe(ITilePlaceable placeable)
 {
     mPlaceables.Remove(placeable);
     if (mType == TerrainType.kPressure && mPlaceables.Count == 0)
     {
         DelegateHost.PressureChange(false, mSpecialCaseID);
     }
 }
예제 #12
0
 public void Subscribe(ITilePlaceable placeable)
 {
     mPlaceables.Add(placeable);
     if(mType == TerrainType.kPressure && mPlaceables.Count == 1)
     {
         DelegateHost.PressureChange(true, mSpecialCaseID);
     }
 }
예제 #13
0
    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);
            }
        }
    }
예제 #14
0
	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();
    }
예제 #15
0
 public void Detach(ITilePlaceable follower)
 {
     mFollowers.Remove(follower);
 }
예제 #16
0
    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);
    }
예제 #17
0
    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);
    }