private void FromMoving(GameShape shape, GameShapeState shapeState)
    {
        GamePipe pipe = GetShapePipePair(shape).AttachedPipe;

        switch (shapeState)
        {
        case GameShapeState.CORRECT_MOVING:
            if (pipe != null)
            {
                pipe.RemoveShape(shape);
            }
            shape.SetState(GameShapeState.CORRECT_MOVING);
            break;

        case GameShapeState.FINISHED:
            if (pipe != null)
            {
                pipe.RemoveShape(shape);
            }
            shape.SetState(GameShapeState.FINISHED);
            shape.OnShapeFinished(false);
            break;

        default:
            break;
        }
    }
    private void UpdateState(GameShape shape, GameShapeState shapeState)
    {
        switch (shape.State)
        {
        case GameShapeState.SPAWNING:
            FromSpawning(shape, shapeState);
            break;

        case GameShapeState.MOVING:
            FromMoving(shape, shapeState);
            break;

        case GameShapeState.CORRECT_MOVING:
            FromCorrectMoving(shape, shapeState);
            break;

        case GameShapeState.EXPLODING:
            FromExploding(shape, shapeState);
            break;

        case GameShapeState.FINISHED:
            FromFinished(shape, shapeState);
            break;

        default:

            break;
        }
    }
Ejemplo n.º 3
0
 public void SetState(GameShapeState newState)
 {
     if (newState != State)
     {
         State = newState;
         if (onStateChanged != null)
         {
             onStateChanged(this);
         }
     }
 }
    private void FromCorrectMoving(GameShape shape, GameShapeState shapeState)
    {
        switch (shapeState)
        {
        case GameShapeState.FINISHED:
            shape.SetState(GameShapeState.FINISHED);
            shape.OnShapeFinished(true);
            break;

        default:
            break;
        }
    }
    private void FromFinished(GameShape shape, GameShapeState shapeState)
    {
        switch (shapeState)
        {
        case GameShapeState.TO_DESTROY:
            int shapeIndex = GetPairIndex(shape);
            shape.SetState(GameShapeState.TO_DESTROY);
            Pairs.RemoveAt(shapeIndex);
            break;

        default:
            break;
        }
    }
    private void FromSpawning(GameShape shape, GameShapeState shapeState)
    {
        switch (shapeState)
        {
        case GameShapeState.MOVING:
            GamePipe pipe = GetShapePipePair(shape).AttachedPipe;

            if (pipe == null)
            {
                shape.SetState(GameShapeState.EXPLODING);
                shape.OnShapeFinished(false);
            }
            else
            {
                shape.SetState(GameShapeState.MOVING);
            }
            break;

        default:
            break;
        }
    }