示例#1
0
    public virtual bool checkPushable(Direction direction, List <SuckerbanObject> alreadyPushedObjects)
    {
        // Check if pushable and calculate what objects should be pushed.
        // returns True if pushable

        // To circumvent recursions
        if (alreadyPushedObjects.Contains(this))
        {
            return(true);
        }
        alreadyPushedObjects.Add(this);


        foreach (IntVector2 sub_position in positions)
        {
            IntVector2      positionInFront = sub_position + (IntVector2)direction.GetIntVector2();
            SuckerbanObject objInFront      = level.GetObjectInPosition(positionInFront);
            if (objInFront == null)
            {
                // There's nothing in front
                continue;
            }
            if (!objInFront.isPushable)
            {
                // Unpushable object is in front
                return(false);
            }
            if (objInFront == this)
            {
                // Ignore if it's me
                continue;
            }
            if (direction == Direction.Down && (this is Player) && (objInFront is Spike))
            {
                // If facing spike can't push
                continue;
            }

            bool pushSuccess = objInFront.checkPushable(direction, alreadyPushedObjects);
            if (!pushSuccess)
            {
                return(false); // Propagate failness
            }
        }
        return(true);
    }
示例#2
0
 public void Explode()
 {
     BombFlame.Create(position, 0.5f);
     foreach (Direction direction in Enum.GetValues(typeof(Direction)))
     {
         for (int l = 1; l < bombLength + 1; l++)
         {
             IntVector2      positionToFlame = position + direction.GetIntVector2() * l;
             SuckerbanObject obj             = level.GetObjectInPosition(positionToFlame);
             if (obj is SteelWall)
             {
                 break;
             }
             if (obj is BrickWall)
             {
                 ((BrickWall)obj).Destroy();
                 break;
             }
             BombFlame.Create(positionToFlame, 0.5f);
         }
     }
     Destroy(transform.gameObject);
 }
示例#3
0
 public bool RemoveFromGrid(SuckerbanObject obj)
 {
     return(allObjectsOnGrid.Remove(obj));
 }
示例#4
0
 public void PlaceOnGrid(SuckerbanObject obj)
 {
     allObjectsOnGrid.Add(obj);
 }