Exemplo n.º 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);
        }
    }
Exemplo n.º 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;
    }
Exemplo n.º 3
0
    public bool TryDeselectObject()
    {
        if (placedObject == null)
        {
            return(false);
        }
        ITilePlaceable tilePlaceable = placedObject.GetComponent <ITilePlaceable>();

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